#
# test.tcl
#
# TCP (telnet) connection between two nodes

source sendmail.tcl

set ns [new Simulator]

# $ns color 0 blue
# $ns color 1 red
# $ns color 2 white

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

set n0 [$ns node]
set n1 [$ns node]

# $n0 color red
# $n1 color green

$ns duplex-link $n0 $n1 10Mb 2ms DropTail

set tcp0  [new Agent/TCP]
set sink0 [new Agent/TCPSink]
$ns attach-agent $n0 $tcp0
$ns attach-agent $n1 $sink0

$ns connect $tcp0 $sink0

set telnet [new Source/sendmail]
# $telnet set interval_ 0.01
$telnet attach $tcp0 $ns

$ns at 0.0 "$telnet start"
$ns at 1.0 "$telnet stop"
$ns at 1.0 "finish"

proc finish {} {
  global ns f nf
  $ns flush-trace
  close $f
  close $nf
  puts "finished."
  exec nam out.nam &
  exit 0
}

$ns run
