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

Re: delaying packets



> 
> Thanks so much for getting back in touch with me.  I have already done 
> what you have suggested so far.  However, I am interested in adding another 
> parameter to simplex link, for example:
> 
>  $ns simplex-link $n0 $n1 1.5Mb 50ms DropTail
> 
> add a parameter, delay
> 
>  $ns simplex-link $n0 $n1 1.5Mb 50ms *delay* DropTail
> 
> so that I can state whether or not I would like to read/receive a specific 
> delay from an unput file of sorts.  This delay would then be read when
> a specific packet traverses the simplex link (only looking at one direction) -
> which is done in delay.cc.  This shouldn't be too hard.... any suggestions?
> Thanks so much for your time, I look forward to hearing from you again.
> Have a pleasant day.
> 

	Hi Tiki

What you are suggesting is possible, but doing the above delay stuff entirely in Tcl is quite messy, since you would have to recode lots of the link stuff in the Tcl libraries (at least we think you have to...:-)

However, there is a much easier solution to your problem... Here is what you could do: add a new command entry into LinkDelay::command in delay.cc where you take your delay as a parameter.

Then, in your tcl-script you can obtain a handle to the link and set the value from there.

For example:

(in delay.cc)
int LinkDelay::command(int argc, const char*const* argv)
{
  if (argc == 3) {
    if (strcmp(argv[1], "setDelay") == 0) {
       yourdelay_ = atof(argv[2]);
       return TCL_OK;
  }
// rest of the code
}

And then in your Tcl-script:

SimpleLink instproc doIt { delay } {
    $self instvar link_

    $link_ setDelay delay
}

Simulator instproc setDelay { src dst delay } {
    $self instvar link_

    # get a pointer to the link
    set lnk $link_([$src id]:[$dst id])
    $lnk doIt $delay
}

$ns setDelay $node1 $node2 $yourdelay

Hope this helps you out.

/ wesa & johan