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

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Tue Jul 22 16:25:28 PDT 2008


On Wed, 2008-07-23 at 01:08 +0200, Florian Westphal wrote:
> Hello ns-3 developers,
> 
> i'm currently writing a few ns-3 simulations to
> demonstrate some of NSCs features.
> 
> I have encountered the following problem:
> In my script[1], i'm building a simple csma network with a few TCP flows.
> Now, all the trace files look bogus when viewed with tools like
> tcpdump or wiresharhark, that is, I often see 'Ethernet 2 Frames'
> without tcpdump or wireshark decoding the next protocol header.
> 
> The problem is that the MTU that is currently hardcoded
> to 1500 byte in nsc is too large.
> (I'd like to use the actual device MTU, but ->GetMtu()
> just returns 0xFFFF...)

This looks like a bug in the csma code which, indeeds, hardcodes this
value to 0xffff. A patch to make that be an attribute and maybe change
it to a more sane default value would be probably a step in the right
direction.

> Now, length values are not allowed to exceed 1500 bytes
> when a 802.3 LLC header is added (Values above are reserved for
> Type-Ids).
> 
> Now, i worked around this by hardcoding an MTU of 1482.
> This still looked strange to me, as this would not show
> 1514 bytes for the whole ethernet packet, as i expected.
> 
> So, i took a look at the csma code.
> 
> In CsmaNetDevice::AddHeader we have this:
>     case LLC: {
>       lengthType = p->GetSize () + header.GetSerializedSize () + 
>         trailer.GetSerializedSize ();
>       LlcSnapHeader llc;
>       llc.SetType (protocolNumber);
>       p->AddHeader (llc);
>     } break;
> 
> This looks bogus -- Why is the LLC header size ignored?
> And is the ethernet header really expected to be accounted for in the length field?

no idea.

> Also, could we add an NS_ASSERT in there that checks that the length is <= 1500 inside
> the LLC label?

+1

> 
> If I replace that header.GetSerializedSize() with an llc.GetSerializedSize()
> the tcpdump/wireshark outputs look much saner to me, i.e.
> I see an 1514 byte ethernet frame with a length field of 1500.
> 
> Of course this doesn't solve my actual problem, namely
> how do I avoid hardcoding MTU values in the nsc glue?

CsmaNetDevice::GetMtu should return the right value.

Mathieu



More information about the Ns-developers mailing list