MTECH PROJECTS
NS2 TCP
What is TCP:
Common TCP protocols:
TCP Protocols for Email:
Other TCP Protocols:
TCP Sink Agents in ns2:
TCP../ns-2/tcp.h is a simplified TCP sender which sends data packets to a TCPSink agent after that processes its acknowledgments.
TCP connection termination:
TCP connection termination phase uses a four-way handshake.
CODE:
proc build-fore-tcp { idx size intv stime } {
global ns ftcp fsink
set ftcp($idx) [new Agent/TCP/Newreno]
set fsink($idx) [new Agent/TCPSink]
$ns at $stime “start-conn 1 $idx $intv $size”
}
proc start-conn
{ firsttime idx intv size
}
{ global ns ftcp fsink s r
set now [$ns now]
if { $firsttime == 0 }
{
$ns detach-agent $s([expr $idx%2]) $ftcp($idx)
$ns detach-agent $r([expr $idx%2]) $fsink($idx)
$ftcp($idx) reset
$fsink($idx) reset
}
$ns attach-agent $s([expr $idx%2]) $ftcp($idx)
$ns attach-agent $r([expr $idx%2]) $fsink($idx)
$ns connect $ftcp($idx) $fsink($idx)
$ftcp($idx) set fid_ 0
$ftcp($idx) proc done {} “close-conn $idx $intv $size”
$ftcp($idx) advanceby $size
}
proc close-conn { idx intv size }
{
global ns
set now [$ns now]
$ns at [expr $now + $intv] “start-conn 0 $idx $intv $size”
puts “at $now + $intv start next”
}
set forel_intv 1
set fores_intv 0.05
set ssize 4
set lsize 1000
build-fore-tcp 1 $ssize 1 0.1
build-fore-tcp 0 $lsize $forel_intv 0.5
for {set i 0} {$i < 5} { incr i} {
build-fore-tcp [expr 2*$i+3] $ssize $fores_intv [expr 1.2+$i*0.1]
}