[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Closing TCP connections
Hello
Using the standard one way TCP implementation, I have the below code to
simulate many TCP connections being initiated over time from a set of
source hosts to a set of sinks. I am concerned that I may not be causing
connections to be closed properly, meaning that if I run a larger
simulation, the maximum number of connections from source to sink will be
reached - is this possible?
If I use FullTCP, what would cause a FIN packet to be sent?
Any help would be most appreciated.
Christopher Clark
(20 source hosts named h1 to h20; twenty sinks name sk1 to sk20)
(initial test code:)
set hnum 1
while { [info exists node_(h$hnum)] } {
set fid_(h$hnum) 1
$self hostKick $hnum 1
incr hnum
}
...
Test/transatlantic instproc hostKick { hnum sknum } {
$self instvar ns_ node_ rng_ fid_
if [info exists node_(h$hnum)] {
# this ensures the 'kicks' cycle through the target hosts
set skdest $sknum
incr sknum
if ![info exists node_(sk$sknum)] {
set sknum 1
}
# we're taking the mean delay between kicks at .5 second
# (exponentially distributed, mean rate of connections per
host 0.5s)
set delay [expr [$rng_ exponential] / 2]
# schedule the next kick for this host
# this delay is also used below as the start time of
# connection
$ns_ at [expr [$ns_ now] + $delay] "$self hostKick $hnum
$sknum "
set fid $fid_(h$hnum)
set tcplocal [$ns_ create-connection TCP $node_(h$hnum)
TCPSink $node_(sk$skdest) $fid]
incr fid_(h$hnum)
set ftplocal [$tcplocal attach-source FTP]
$ns_ at [expr [$ns_ now] + $delay] "$ftplocal produce
1000"
}
}