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

TCP example in NS Doc




I tried using the "create-connection" function in section 19.1.3 of NS
documentation, but the trace files were empty. NS did not return any error
message.

Could someone comment on the correctness of the following code?

Thanks,

Eddie


------------------------
set ns [new Simulator]

set node1 [$ns node]
set node2 [$ns node]

set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

set tcp1 [$ns create-connection TCP $node1 TCPSink $node2 42]
$tcp1 set window_ 50
set ftp1 [$tcp1 attach-source FTP]

$ns at 0.0 "$ftp1 start"
$ns at 2.0 "finish"

proc finish {} {
    global ns f nf
    $ns flush-trace
    close $f
    close $nf

    puts "running nam..."
    exec nam out.nam &
}
------------------------