Re: Simulating DSR protocol in NAB - quick question

Henri DF <[email protected]> Mon, 13 Dec 2004 19:06:27 +0100 (CET)
Newsgroups gmane.network.simulator.epfl
Message-ID <[email protected]>
Hello Robin, 

Not silly, your question seems perfectly reasonable to me ;)

[ Independent of the prog. language used, the terminology of the ietf doc 
seems a bit poor - i don't know what it means to "conceptually" copy a 
data structure...
Anyway, I'll assume this means to make a full copy, ie a memcpy(..) in c.]

Yes, you've got it figured out: use L3pkt.clone_l3pkt, passing it the 
packet you would like to get a copy of. This will return you a new l3pkt 
which is an exact copy of the one you pass it.

Note that clone_l3pkt calls clone_l3hdr_ext, so you should add to the 
latter function a call to a Dsr_pkt.clone (assuming you have defined 
dsr packet fields in dsr_pkt.ml, along the lines of what is done 
for AODV). 
Then you must of course implement Dsr_pkt.clone that returns a copy of the 
passed dsr-specific hdr. 

If your packet definitions are non mutable, then this is as simple as:

let clone dsr_pkt = dsr_pkt  (* as in aodv_pkt *)

(ie no need to make a physical copy of  data structure which cannot be 
modified)

If they are mutable, then you must make a physical copy, along the lines 
of what is done in the clone function of Ler_pkt.ml.

Hope this helps - let me know if you have any problems.

Henri



> Dear Henri,
> I was wondering if you could help me out with a quick question. I'm currently
> implementing Route Discovery for DSR at the moment and one of the parts in the
> IETF documentation says 'Conceptually create a copy of this entire packet..'.
> Whats the best way to do this? Can I just use the 'clone' method of the l3pkt
> to create a copy of the l3pkt and then work from there or is that not the best
> thing to do? Also, if this is the case how would I initalise a new l3pkt? can i
> just do somethin like val pktcopy: l3pkt; and then set it to be the clone of the
> existing packets. I'm still not exactly fluent in OCaml so I hope this isnt a
> silly question!
> Thanks
> Robin
>