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

[ns] done callback in tcp-full.cc



Hi,

In the current implementation, the done callback is invoked every time a
packet is acknowledged, instead of being called only when the connection is
closed. The problem seems to be in the following code:

        // haoboy: Is here the place for done{} of active close?
        // It cannot be put in the switch above because we might need to do
        // send_much() (an ACK)
        Tcl::instance().evalf("%s done", this->name());

I think it can be fixed with

        if (state_ == TCPS_CLOSED)
                Tcl::instance().evalf("%s done", this->name());

but I'm not familiar enough with code to be sure this covers all the cases.
Any feedback will be appreciated.

-- Felix Hernandez

P.S. I have used the following script to test FullTcp:

set ns [new Simulator]

$ns namtrace-all [open test.nam w]

set n1 [$ns node]
set n2 [$ns node]

$ns duplex-link $n1 $n2 1Mb 10ms DropTail

set src [new Agent/TCP/FullTcp]
set sink [new Agent/TCP/FullTcp]

$ns attach-agent $n1 $src
$ns attach-agent $n2 $sink

$src set fid_ 0
$sink set fid_ 0

$ns connect $src $sink

$sink listen

$ns at 10.0 "$src advanceby 1"

$ns at 20.0 "$sink advanceby 5"

$ns at 30.0 "$sink close"

proc time {} {
    global ns
    puts "[$ns now]"
}

$src proc done {} "puts -nonewline \"src done \"; time"
$sink proc done {} "puts -nonewline \"sink done \"; time"

$ns at 1000.0 "finish"

proc finish {} {
 global ns
 $ns flush-trace
 puts "running nam..."
 exec nam test.nam &
 exit 0
}

$ns run