diff --git a/src/devices/csma/csma-net-device.cc b/src/devices/csma/csma-net-device.cc index a1e42361c..d2ed00edb 100644 --- a/src/devices/csma/csma-net-device.cc +++ b/src/devices/csma/csma-net-device.cc @@ -393,6 +393,20 @@ CsmaNetDevice::AddHeader (Ptr p, Mac48Address source, Mac48Address de // in the old Ethernet Blue Book. // lengthType = protocolNumber; + + // + // All Ethernet frames must carry a minimum payload of 46 bytes. We need + // to pad out if we don't have enough bytes. These must be real bytes + // since they will be written to pcap files and compared in regression + // trace files. + // + if (p->GetSize () < 46) + { + uint8_t buffer[46]; + memset (buffer, 0, 46); + Ptr padd = Create (buffer, 46 - p->GetSize ()); + p->AddAtEnd (padd); + } break; case LLC: { @@ -401,6 +415,21 @@ CsmaNetDevice::AddHeader (Ptr p, Mac48Address source, Mac48Address de LlcSnapHeader llc; llc.SetType (protocolNumber); p->AddHeader (llc); + + // + // All Ethernet frames must carry a minimum payload of 46 bytes. The + // LLC SNAP header counts as part of this payload. We need to padd out + // if we don't have enough bytes. These must be real bytes since they + // will be written to pcap files and compared in regression trace files. + // + if (p->GetSize () < 46) + { + uint8_t buffer[46]; + memset (buffer, 0, 46); + Ptr padd = Create (buffer, 46 - p->GetSize ()); + p->AddAtEnd (padd); + } + // // This corresponds to the length interpretation of the lengthType field, // but with an LLC/SNAP header added to the payload as in IEEE 802.2