Skip to content

Commit c4dcfea

Browse files
committed
fix bug, recover the protocol number before remove header.
1 parent c3be442 commit c4dcfea

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

model/p4-switch-net-device.cc

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -546,18 +546,13 @@ P4SwitchNetDevice::SendNs3Packet(Ptr<Packet> packetOut,
546546
if (packetOut)
547547
{
548548
// Print the packet's header
549-
// EthernetHeader eeh_1;
550-
// if (packetOut->PeekHeader (eeh_1))
551-
// {
552-
// NS_LOG_DEBUG ("Ethernet packet");
553-
// // log the ethernet header information
554-
// Mac48Address src_mac = eeh_1.GetSource ();
555-
// Mac48Address dst_mac = eeh_1.GetDestination ();
556-
// uint16_t protocol_eth = eeh_1.GetLengthType ();
557-
// protocol = protocol_eth; // Keep the protocol number of the packet
558-
// NS_LOG_DEBUG ("Source MAC: " << src_mac << ", Destination MAC: " << dst_mac
559-
// << ", Protocol: " << protocol_eth);
560-
// }
549+
EthernetHeader eeh_1;
550+
551+
if (packetOut->PeekHeader(eeh_1))
552+
{
553+
NS_LOG_DEBUG("Ethernet packet");
554+
protocol = eeh_1.GetLengthType(); // recover the protocol number
555+
}
561556

562557
EthernetHeader eeh;
563558
packetOut->RemoveHeader(eeh); // keep the ethernet header

0 commit comments

Comments
 (0)