[Ns-developers] Csma, ethernet length field, NSC and the link mtu...

Florian Westphal fw at strlen.de
Wed Jul 23 05:09:37 PDT 2008


craigdo at ee.washington.edu <craigdo at ee.washington.edu> wrote:
> > Yes, but I'd like fix this up properly. I'm too tired right 
> > now to read
> > docs, i'll check this tomorrow (i'm fairly certain the ethernet header
> > doesn't belong there; think about it -- if you're not using LLC, there
> > is no length field in the first place, and if you use LLC adding the
> > ethernet header length reduces the maximum data you can carry 
> > by 14 bytes,
> > since the length field isn't allowed to exceed 1500).
> 
> See RFC 1042, page two.  First comes 802.3 MAC, then 802.2 LLC then 802.2
> SNAP.

Yes, but when you look at page 6 (For IEEE 802.3), it says:

"This allows 1518 - 18 (MAC header+trailer) - 8 (LLC+SNAP header) =
1492 for the IP datagram (including the IP header).  Note that
1492 is not equal to 1500 which is the MTU for Ethernet networks."

Also,
http://standards.ieee.org/getieee802/download/802.3-2005_section1.pdf
Section 3.2.6
a) says:
[..] indicates the number of MAC client data octets contained
in the _subsequent_ data field of the frame [..] (emphasis mine)

In fact, 'data field' sounds to me as if the trailer doesn't belong there
either.
Just using llc header length and the payload size results in
1500 (maximum length allowed) - 8 (llc header length) = 1492 (for the
actual payload without Llc header)  which conveniently matches the
RFC 1042 quote above.
I propose something like this:

csma: Fix LLC header length calculation

Must only count the actual data payload (including LLC header).
The ethernet header/trailer must not be counted.

Also, add NS_ASSERT to make sure the LLC length does not exceed the 1500
byte limit.

diff -r 6cd7d91ba8c8 -r 8101ec181e2b src/devices/csma/csma-net-device.cc
--- a/src/devices/csma/csma-net-device.cc	Tue Jul 22 20:09:07 2008 +0200
+++ b/src/devices/csma/csma-net-device.cc	Wed Jul 24 14:04:32 2008 +0200
@@ -201,11 +201,16 @@
       lengthType = protocolNumber;
       break;
     case LLC: {
-      lengthType = p->GetSize () + header.GetSerializedSize () + 
-        trailer.GetSerializedSize ();
       LlcSnapHeader llc;
       llc.SetType (protocolNumber);
       p->AddHeader (llc);
+      /*
+       * the ethernet header and trailer are not counted, see RFC 1042 and
+       * http://standards.ieee.org/getieee802/download/802.3-2005_section1.pdf,
+       * Section 3.2.6 a)
+       */
+      lengthType = p->GetSize ();
+      NS_ASSERT_MSG (lengthType <= 1500, "802.3/LLC length must not exceed 1500; reduce MTU");
     } break;
     case RAW:
       NS_ASSERT (false);


More information about the Ns-developers mailing list