Examples of use

Using NSC is no harder than using the TCP agents that come with ns-2. An example script is below:


set ns [new Simulator]
set stacks(0) [new Agent/TCP/Linux24]
set stacks(1) [new Agent/TCP/FreeBSD5]

for {set i 0} {$i < 6} {incr i} {
    set nodes($i) [$ns node]
}

$ns duplex-link $nodes(0) $nodes(1) 100Mb 0.115ms DropTail
$ns duplex-link $nodes(4) $nodes(1) 100Mb 0.115ms DropTail
$ns duplex-link $nodes(3) $nodes(2) 100Mb 0.115ms DropTail
$ns duplex-link $nodes(5) $nodes(2) 100Mb 0.115ms DropTail

# Forward path
$ns simplex-link $nodes(1) $nodes(2) 2Mb 40ms DropTail
$ns queue-limit $nodes(1) $nodes(2) 30
# Reverse path
$ns simplex-link $nodes(2) $nodes(1) 256Kb 40ms DropTail
$ns queue-limit $nodes(2) $nodes(1) 30

$ns attach-agent $nodes(0) $stacks(0)
$ns attach-agent $nodes(3) $stacks(1)

$ns connect $stacks(0) $stacks(1)

set app [new Application/Traffic/CBR]
$app set rate_ [expr 3000000]
$app set packetSize_ 1024
$app attach-agent $stacks(0)

$ns at 0.0 "$app start"
$ns at 60.0 "puts [$stacks(1) set goodput_]"
$ns at 60.0 "finish"

$ns run

The only change in the above example from an existing ns-2 script is the creation of the TCP agents: something such as Agent/TCP/Newreno changed to Agent/TCP/Linux24. For convinience, goodput is recorded in the receiver and is accessable as shown above. There are some caveats, but the above example works the same whether it is using ns-2 agents or NSC agents.

The NSC agents have a different set of options than those found in ns-2 currently. It is possible to configure sysctls and also to produce dumps in pcap/tcpdump format. Doing so is simple:


# Enable pcap dump creation for this node.
$stacks(0) enable-packet-dump

# Configure our Linux node: turn Westwood on and SACK off
$stacks(0) sysctl net/ipv4/tcp_westwood 1
$stacks(0) sysctl net/ipv4/tcp_sack 0

Case studies

Many simulations have already been run using NSC stacks, some producing interesting results.

Bidirectional uniform random loss

One simple scenario to study was the effect of bidirectional random loss. Simulating a simple scenario measuring a the goodput of a single TCP connection produced the results shown in the following graph:

Bidirectional random loss