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

About the TcpApp. help!!!



Hi, 

I just run the TcpApp example file in the ns doc. But it seems work bad,
who can help me???

many thanks,
------------------error data:
ns tcpapp.tcl
1 app2 receives data 100 from app1
Bus error (core dumped)
----------------------------
prog:
#Create a simulator object
set ns [new Simulator]

#Open a trace file
set nf [open out.nam w]
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
        global ns nf
        $ns flush-trace
        close $nf
        exec nam out.nam &
        exit 0
}

#Create three nodes
set n2 [$ns node]
set n1 [$ns node]

######################
# Link definition
######################
$ns duplex-link $n1 $n2 10Mb 2ms DropTail


# Set up TCP connection
    #    set tcp1 [$ns_ create-connection TCP $n1 TCPSink $n2 0]
    #    $tcp1 set window_ 30
set tcp1 [new Agent/TCP/FullTcp]
set tcp2 [new Agent/TCP/FullTcp]

$ns attach-agent $n1 $tcp1
$ns attach-agent $n2 $tcp2
$ns connect $tcp1 $tcp2
$tcp2 listen

Application/TcpApp instproc app-recv {size} {
        global ns
        puts "[$ns now] app2 receives data $size from app1"
}

set app1 [new Application/TcpApp $tcp1]
set app2 [new Application/TcpApp $tcp2]

$ns at 1.0 "$app1 send 100"
$ns at 1.0 "$app2 app-recv 100"
$ns at 1.5 "finish"

#Run the simulation
$ns run