[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Misfeature (or bug) when generating packetheaders



On Wed, 8 Sep 1999, Henrik Eriksson wrote:

> I have found a misfeature (and/or a bug) in the way that
> packetheaders and their offsets are created.

I believe not...

> Consider the case where you have added a packetheader by
> subclassing PacketHeader e.g. (in C++)
>
> BluetoothPacketHeaderClass():
> PacketHeaderClass("PacketHeader/Mac/Bluetooth", sizeof(bt_hdr)){}
>
> To use the packet header we add in ~ns/tcl/lib/nspacket.tcl:
> 
> {Mac/Bluetooth, off_bt_}

If you want the hierarchy of Mac handling, I think you should be
modifying ~ns/lan/ns-mac.tcl to add Bluetooth there instead. Or
else skipping that entirely by saying

PacketHeaderClass("PacketHeader/MacBluetooth", sizeof(bt_hdr)){}
[..]
{MacBluetooth, off_bt_}

as you see for:

{ Mac802_11 off_mac802_11_ }

...which had better be a legacy entry predating a proper Mac class,
since Mac/802_11 also exists in ~ns/lan/ns-mac.tcl and mac-802_11.cc
in my reasonably current snapshot says:

 Mac802_11Class() : TclClass("Mac/802_11") {}

I believe that header entry in ns-packet.tcl is bogus and needs
removing, and that modifying ~ns/lan/ns-mac.tcl is the better (ie
workable) approach.

 
> BUT no packetheader will be created due to how the code in
> 'Simulator instproc create_packetformat' works (also located in
> ~ns/tcl/lib/nspacket.tcl).
> 
> The problem is the line:
> set off [$pm allochdr [lindex [split $cl  /] 1]]

a local fix to your problem/approach as stated could probably be
something like:

  set clist [split $cl /]
  set clist [lrange $clist 1 [llength $clist]]
  set off [$pm allochdr [join $clist /]]

but that would break everything BUT Mac/Bluetooth; it's really
addressing the wrong problem. Since cl is:

  set cl PacketHeader/[lindex $pair 0]

you're misusing naming/hierarchy, and if that fix is necessary
something has gone severely wrong somewhere else.

Here, / is a reserved separator between classes and subclasses, not a
name element.

hth,

L. 

> I assume that the purpose of split is to remove "PacketHeader"
> from "PacketHeader/Mac/Bluetooth" and get the rest of the name.

> If the name of the packetheader contains just one '/', the code
> above will work but if it contains more /'s, it will not. no
> packetheader for "Mac/Bluetooth" will be created, just for "Mac"
> (if enabled by {Mac off_mac_}).
> 
> So if you want to use names for packetheaders with multiple /'s in
> it, this code must be fixed (I have no fix since I'm not that good
> at TCL)
> 
> Best regards, Henrik Eriksson
> Ericsson Research

<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>