inet-framework / inet

INET Framework for the OMNeT++ discrete event simulator
https://inet.omnetpp.org
Other
442 stars 488 forks source link

Header converting erro when enabling gPTP (802.1as) with frame preemption #932

Open howhangliu opened 11 months ago

howhangliu commented 11 months ago

Hi all,

In the TSN showcases, I am experimenting with the gPTP and FP features. I discovered that when enabling both together, there is an issue as follows:

Cannot convert chunk from type inet::physicallayer::EthernetFragmentPhyHeader to type inet::physicallayer::EthernetPhyHeader. The most likely cause of this error is that a packet header is being misinterpreted while processing a received packet. The most likely fix is to find the code where the misinterpretation happens and change it.If the intention is to reinterpret the chunk via serialization/deserialization, then it needs to be enabled by passing the PF_ALLOW_REINTERPRETATION flag into the peek() or similar function.The automatic conversion is disabled by default to prevent unexpected behavior due to unintended data reinterpretation. -- in module (inet::Gptp) fp_gptp.switch1_fibrolan.gptp (id=248), at t=0.0000092825s, event 71

Note: The link between switch1-eth[1] and swtich2-eth[0] is the FP-capable link. It seems that when switch2 received the peer delay response message from switch1, it could not convert the header. I would appreciate it if you could point me to the file where I should look to fix the problem.

You can find the ned and ini files in the attachments. fp_gptp.zip

Thank you Best regards,

Ganht99 commented 5 months ago

Hi,

I met the same problem and figured it out.

In source file Gptp.cc, there is a function named void Gptp::receiveSignal. When the frame is trasmitted to the node, it will produce transmissionEndedSignal and receptionEndedSignal .And Gptp will use that signal to check whether that frame is an AS frame.During the judging process, it uses the chunk named EthernetPhyHeader as followed.

const auto& ethPhyHeader = packet->peekAtFront();

However, when using frame preemption and AS, preemptable frame does not have that chunk. It has a chunk named EthernetFramentHeader .That's the reason.

Here is a solution.Since the judging process does not actually use the phyheader chunk, it only use its length as followed const auto& ethMacHeader = packet->peekAt(ethPhyHeader->getChunkLength()); const auto& gptp = packet->peekAt(ethPhyHeader->getChunkLength() + ethMacHeader->getChunkLength()); Thus we can modify the sentence like this: const auto& ethMacHeader = packet->peekAt(b(64)); const auto& gptp = packet->peekAt(b(64) + ethMacHeader->getChunkLength());

You can have a try.

Best wishes