padd out CSMA payloads to 46 bytes if needed
This commit is contained in:
@@ -393,6 +393,20 @@ CsmaNetDevice::AddHeader (Ptr<Packet> 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<Packet> padd = Create<Packet> (buffer, 46 - p->GetSize ());
|
||||
p->AddAtEnd (padd);
|
||||
}
|
||||
break;
|
||||
case LLC:
|
||||
{
|
||||
@@ -401,6 +415,21 @@ CsmaNetDevice::AddHeader (Ptr<Packet> 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<Packet> padd = Create<Packet> (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
|
||||
|
||||
Reference in New Issue
Block a user