A Simple 3-TCP-Connections and One-Bottleneck
Example
July 07, 2001
Figure 1: The network scenario constructed in this example

This example extends Example 2 to the
case of multiple TCP connections of fixed durations (i.e., the
start and stop times of each connection is specified). As
most of the commands and classes used in this example have been
introduced in Example
2, we will given explanations only when we encounter new
commands/classes.
Step 1. Creating the network topology
Step 1.1. We create a component directory to hold
the components created for this example:
cd [mkdir drcl.comp.Component /example3]
Step 1.2. We create the topology:
puts "create topology..."
set link_ [java::new drcl.inet.Link]
$link_ setPropDelay 0.3; # 300ms
set adjMatrix_ [java::new {int[][]} 8 {{3} {3} {3} {0 1 2 4} {3 5 6 7} {4} {4} {4}}]
java::call drcl.inet.InetUtil createTopology [! .] $adjMatrix_ $link_
Step 2. Configuring the nodal structure
Step 2.1. We first create a router builder, a
source host builder and a sink host builder. Then, we build
and configure the nodes (with the build method in the NodeBuilder
class) and configure the bottleneck bandwidth and buffer size:
puts "create builders..."
# router builder:
set rb [mkdir drcl.inet.NodeBuilder .routerBuilder]
$rb setBandwidth 1.0e7; #10Mbps
# source builder:
set hb1 [cp $rb .hostBuilder1]
[mkdir drcl.inet.transport.TCP $hb1/tcp] setMSS 512; # bytes
set src_ [mkdir drcl.inet.application.BulkSource $hb1/source]
$src_ setDataUnit 512
connect -c $src_/down@ -and $hb1/tcp/up@
# sink builder:
set hb2 [cp $rb .hostBuilder2]
mkdir drcl.inet.transport.TCPSink $hb2/tcpsink
set sink_ [mkdir drcl.inet.application.BulkSink $hb2/sink]
connect -c $sink_/down@ -and $hb2/tcpsink/up@
puts "build..."
$rb build [! n?]
$hb1 build [! h0-2]
$hb2 build [! h5-7]
# Configure the bottleneck bandwidth and buffer size
! n3 setBandwidth 3 1.0e4; # 10Kbps at interface 3
! n3 setBufferSize 3 6000; # ~10 packets at interface 3
Recall that "n?" is a wildcard
path expression, and [! n?] returns a Java array consisting of
n3 and n4.
Another legal wildcard path expression is "<number>-<number>".
For example, [! h0-2] returns an array of h0, h1 and
h2; [! h5-7]
returns an array of h5, h6 and h7.
Sidebar: Node Map
Similar to what we have done with node
map in Example 2, we may use "node map" here to replace
step 2.1 above:
set nb [mkdir drcl.inet.NodeBuilder .nodeBuilder] $nb setBandwidth 1.0e7; #10Mbps $nb build [! n?] $nb build [! h0-2] { tcp drcl.inet.transport.TCP source -/tcp drcl.inet.application.BulkSource } $nb build [! h5-7] { tcpsink drcl.inet.transport.TCPSink sink -/tcpsink drcl.inet.application.BulkSink } ! h?/tcp* setMSS 512 ! h?/s* setDataUnit 512 ! n3 setBandwidth 3 1.0e4; # 10Kbps at interface 3 ! n3 setBufferSize 3 6000; # ~10 packets at interface 3
|
Step 2.2. We set up the TCP connections. For each
TCP connection, we set up a static route between the source and
sink nodes:
# Set up the TCP connections
! h0/tcp setPeer 5
! h1/tcp setPeer 6
! h2/tcp setPeer 7
puts "setup static routes..."
java::call drcl.inet.InetUtil setupRoutes [! h0] [! h5] "bidirection"
java::call drcl.inet.InetUtil setupRoutes [! h1] [! h6] "bidirection"
java::call drcl.inet.InetUtil setupRoutes [! h2] [! h7] "bidirection"
Step 2.3. We set up a TrafficMonitor component
and a Plotter component (as shown in Figure 2) to on-line
keep track of the instantaneous throughput, the sequence
numbers of packets received, the size of the congestion window,
and the smoothed RTT. Note that we set up three data sets in
each of the four plots:
Figure 2: How the TrafficMonitor
component and the Plotter component are used in this example.

puts "Set up TrafficMonitor & Plotter..."
set plot_ [mkdir drcl.comp.tool.Plotter .plot]
foreach i {5 6 7} {
set tm$i\_ [mkdir drcl.net.tool.TrafficMonitor .tm$i]
connect -c h$i/csl/6@up -to .tm$i/in@
set j [expr $i-5]
connect -c .tm$i/bytecount@ -to $plot_/$j@0
connect -c h$i/tcpsink/seqno@ -to $plot_/$j@2
}
! .tm? configure 10.0 4.0; # window size, update interval
foreach i {0 1 2} {
connect -c h$i/tcp/cwnd@ -to $plot_/$i@1
connect -c h$i/tcp/srtt@ -to $plot_/$i@3
}
The only new command introduced is ".tm? configure 10.0 4.0."
The command invokes all the TrafficMonitor componets to configure
the window size to be 10.0 seconds, and the update interval to be
4 seconds. It tells each TrafficMonitor component to keep
statistics for the past time window of size 10 seconds, and
updates the parameters of interest every 4 seconds.
Step 3. Starting the Simulation
Step 3.1. Now we attach the simulator runtime and
conduct the simulation for 1200 seconds. Also, we specify the
start and stop times for each TCP connection: the source
host h0 starts at time 0.0 s and stops at time 800.0 s, the
source host h1 starts at 100.0 s and stops at 1000.0 s, and the
source host h2 starts at 400.0 and runs until the simulation
stops:
puts "simulation begins..."
set sim [attach_simulator .]
run h0/source
script {run h1/source} -at 100.0 -on $sim
script {run h2/source} -at 400.0 -on $sim
script {stop h0/source} -at 800.0 -on $sim
script {stop h1/source} -at 1000.0 -on $sim
script {puts [$sim getTime]} -period 50.0 -on $sim
$sim stopAt 1200
The first new command introduced in the above script is the
RUV command, "script".
It allows scripts to start execution at some specific simulation
times. The syntax is as follows:
script <script> ?-at <time>? ?-period <period>? ?-on <runtime>? ?-shell <shell>?
The command will execute (in the runtime specified by
<runtime>) the comands in <script>
at the future time specified by <time> and repeat execution once every time period of duration
<period>. The default
value for <time> is 0.0; for <period> is -1.0 (only
executed once); for <runtime> is the system default
runtime; for <shell> is the current shell. In network
simulation, we should always set the runtime to the simulation
runtime.
Results: After executing the above script, four
windows pop up to display on the fly the instantaneous
throughput, congestion window size, the sequence number of
packets received, and the smoothed RTT, respectively. These
parameters are continuously updated.




The source code of this example is avalable here. We have also validated our classes
by comparing the simulation results obtained here against those
obtained in ns-2. The results are in extremely good
agreement.
In summary, we have shown in this example that:
- How to set up multiple TCP connections of fixed durations.
- How to use the RUV command,
script, to execute scripts at
specified simulation time.
Where we go next
Example 4: four-host, four-router, UDP and
FSP example.