bug 1056: CSMA: padding not handled correctly for LLC encapsulation

This commit is contained in:
Tom Goff
2011-05-12 21:19:07 -07:00
parent 1717d90e90
commit 4282582535
2 changed files with 17 additions and 6 deletions

View File

@@ -72,6 +72,7 @@ since ns-3.10, in many cases referencing the Bugzilla bug number.
- bug 1038 - Time::Get*Seconds () return signed integer while actually returning unsigned
- bug 445 - Is the class name Scalar in nstime.h appropriate?
- bug 1044 - Seconds (1e-9) creates Time that is not IsPositive ()
- bug 1056 - CSMA: padding not handled correctly for LLC encapsulation
Known issues
------------

View File

@@ -321,6 +321,13 @@ CsmaNetDevice::AddHeader (Ptr<Packet> p, Mac48Address source, Mac48Address de
llc.SetType (protocolNumber);
p->AddHeader (llc);
//
// 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
//
lengthType = p->GetSize ();
//
// 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
@@ -335,12 +342,7 @@ CsmaNetDevice::AddHeader (Ptr<Packet> p, Mac48Address source, Mac48Address de
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
//
lengthType = p->GetSize ();
NS_ASSERT_MSG (lengthType <= GetMtu (),
NS_ASSERT_MSG (p->GetSize () <= GetMtu (),
"CsmaNetDevice::AddHeader(): 802.3 Length/Type field with LLC/SNAP: "
"length interpretation must not exceed device frame size minus overhead");
}
@@ -721,6 +723,14 @@ CsmaNetDevice::Receive (Ptr<Packet> packet, Ptr<CsmaNetDevice> senderDevice)
//
if (header.GetLengthType () <= 1500)
{
NS_ASSERT (packet->GetSize () >= header.GetLengthType ());
uint32_t padlen = packet->GetSize () - header.GetLengthType ();
NS_ASSERT (padlen <= 46);
if (padlen > 0)
{
packet->RemoveAtEnd (padlen);
}
LlcSnapHeader llc;
packet->RemoveHeader (llc);
protocol = llc.GetType ();