문제

I have a problem to realize various delay in TCP packets. I want to use Gamma distribution like this in tcl file :

# Set gamma distribution
set gamma [new RandomVariable/Gamma]
$gamma set alpha_ $alpha
$gamma set beta_ $beta
set gamma2 [$gamma value]

How can I use gamma2 value as new delay for each TCP packet? I want to apply this latency before sending the packet like this (but not sure it is correct or not)

Agent/TCP instproc mysend {size} {
#change delay
$self change_del
$self send $size
}

Thank you for the answer

도움이 되었습니까?

해결책

You're using NS2, so that means you're using the object system OTcl (which is built on top of standard Tcl). To install an override of the send method so that you can apply the delay, you need to use slightly different syntax. This all assumes that Agent/TCP is a subclass of a class that defines send

Agent/TCP instproc send {size} {
    # Change the delay
    $self change_del
    # Chain to the superclass implementation
    $self next $size
}

The next method is rather magical in OTcl; it looks up the caller's superclass implementation and calls that with the arguments provided to it. It's similar (but not identical to) the super keyword in Java and the base keyword in C#.


If Agent/TCP is an instance, you use this instead:

Agent/TCP proc send {size} {
    # Change the delay
    $self change_del
    # Chain to the superclass implementation
    $self next $size
}

That looks almost identical, except now we're using proc instead of instproc.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top