You are on page 1of 7

QoS in Network Simulator 2

This experiment provides experience in how to apply and simulate QoS mechanisms in
communication networks by means of NS2. We focus on RSVP in this experiment.

1. RSVP in NS2 HowTo


This section provides a fast overview on how to use RSVP in NS2 scenarios, see [1].

1.1.

Setting an RSVP Link between Two Nodes

An RSVP link between two nodes, node_1 and node_2 is created with the following Tcl
command:
ns duplex-rsvp-link <node_1> <node_2> <bw> <delay> <reservable> <rsvp> <queue>
<adc> <est>
where:

ns is an instance of the simulator.

bw expresses the bandwidth of the link.

delay stands for the link delay.

reservable determines the amount of bandwidth able to be reserved by RSVP.

rsvp stands for the bandwidth (bits per second) reserved for RSVP control messages. If
this value is set to zero, all RSVP control messages will be transmitted as best effort
packets. Otherwise, a WFQ class with the specified bandwidth will be reserved for RSVP
control messages to avoid control messages loss.

queue is the size of the queue (in bytes) assigned to serve best-effort packets.

adc determines the used admission control algorithm. There are currently five admission
control algorithms implemented [2], namely Parameter-based Simple Sum algorithm
(Param), Measured Sum (MS), Hoeffding Bounds (HB), Acceptance Region-Tangent at
Origin (ACTO) and Acceptance Region-Tangent at Peak (ACTP).

est is the estimator used by measurement-based admission control algorithms. Currently,


there are four different estimators implemented, namely Null (for Param), TimeWindow
(for MS), ExpAvg (for HB) and PointSample (for ACTO and ACTP).

Example: $ns duplex-rsvp-link $a $b 1Mb 10ms 0.5 100 50000 Param Null

1.2.

Setting Up and Creation of RSVP Agents

The following creates an RSVP-agent named rsvpagent and adds it to the node node_1.
set rsvpagent [$node_1 add-rsvp-agent]
Another way to add the rsvpagent to the node node_1 is the following:
$node_1 add-rsvp-agent

1.3.

TCL Commands

The following lists some useful commands for RSVP

Create a session:

<rsvp-agent> session <destination> <flow-id>

Release a session:

<rsvp-agent> release <session-id>

Send path messages

<rsvp-agent> sender <session-id> <rate> <bucket> <ttl>

Reserve bandwidth

<rsvp-agent> reserve <session-id> <style> <flow descriptor list>

Send a RESV CONFIRM object with the next reservation message

<rsvp-agent> confirm <session-id>

Get a list of all sessions in an agent:

<rsvp-agent> sessions

Set the status value for a session

<rsvp-agent> set-status <session-id> <value>

Get the status value of a session

<rsvp-agent> get-status <session-id>

2. RSVP in NS2 Practice


Assume the network provided in figure 1. All links have a bandwidth of 1 Mbit/sec. The delay
on each link is 10 msec. 90% of each link bandwidth can be reserved by RSVP, while 100
bit/sec is reserved for RSVP control messages. Each queue of network nodes reserves 5000
bytes to serve best effort packets. Resources are reserved for two UDP sessions. One is
between nodes 1 and 2, while the other is between nodes 0 and 5. The RSVP session between
nodes 1 and 4 is observed during this experiment. We measure the sending rate (in kbit/s) and
the bandwidth loss (in packets/s). The sending rate is stored in a file named rate.tr, while the
bandwidth loss is stored in a file named loss.tr.

Figure 1: An example network operating RSVP

2.1.

Measuring the Sending Rate and Bandwidth Loss

During the experiment, the following should be done.


1. Run the file rsvp-scenario.tcl by typing ns rsvp-scenario.tcl.
2. See the scenario using nam. What do you notice? What kind of traffic do we have?
3. Present the measured sending rates and bandwidth loss using xgraph. Interpret the
results.
4. Go to the Tcl script and try to highlight, how the sending rate as well as the bandwidth
loss has been measured.

2.2.

Impact of Sending Rate

During the experiment, the following should be done.


1. Change the sending rate of the CBR source attached to node 1 between 100000 until
900000 bits/s (actual rate is 800000 bits/s). The change can be done by updating this
command in the script <set r [define_cbr_traffic $n1 $n4 800000 1]>.
2. After each change, run the simulation again and stores the results files.
3. See the measured rates for all sending rates values and interpret the results.
4. Do the same for the bandwidth loss.

2.3.

Impact of Best Effort Traffic

The following task aims at analyzing how best effort traffic affects RSVP session. For this
purpose, do the following:
1. Build a normal UDP session with a CBR source sending 500 bytes packets each 5 ms
between both nodes 1 and 4.
2. Change the rate of the normal UDP session and notice how this affects the sending
rate as well as the bandwidth loss of RSVP session between 1 and 4.

3. TCL Script
# Create the scheduler and define the nam file and where the sending rates as well as
bandwidth loss will be stored.
set ns [new Simulator]
set nf [open out.nam w]
set ratef [open rate.tr]
set lossf [open loss.tr]
$ns namtrace-all $nf
# Define two colors, each will be used for an RSVP session
$ns color 1 Blue
$ns color 2 Red
# Create network nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
# Write a procedure named "create_link" This procedure is used to create an RSVP
connection between two nodes, namely src_node and dst_node
proc create_link {src_node dst_node} {
global ns
set rate 1Mb
set delay 10ms
set reservable 0.9
set rsvp_rate 100
set bo_queue_size 5000
$ns duplex-rsvp-link $src_node $dst_node $rate $delay $reservable $rsvp_rate
$bo_queue_size Param Null;
}
# create RSVP connections between network nodes
create_link $n0 $n2
create_link $n1 $n2
create_link $n2 $n3
create_link $n3 $n4

create_link $n3 $n5


# create RSVP connections between network nodes
set rsvp0 [$n0 add-rsvp-agent]
set rsvp1 [$n1 add-rsvp-agent]
set rsvp2 [$n2 add-rsvp-agent]
set rsvp3 [$n3 add-rsvp-agent]
set rsvp4 [$n4 add-rsvp-agent]
set rsvp5 [$n5 add-rsvp-agent]
# create a UDP association between src_node and dst_node with a cbr_rate
proc define_cbr_traffic {src_node dst_node cbr_rate class} {
global ns
set udp_src [new Agent/UDP]
$udp_src set class_ $class
$ns attach-agent $src_node $udp_src
set cbr_src [new Application/Traffic/CBR]
set cbr_interval 0.005
set packet_size_unit 8;
$cbr_src set packetSize_ [expr $cbr_rate*$cbr_interval/$packet_size_unit]
$cbr_src set interval_ $cbr_interval
$cbr_src attach-agent $udp_src
set null_sink [new Agent/LossMonitor]
$ns attach-agent $dst_node $null_sink
$ns connect $udp_src $null_sink
return "$cbr_src $null_sink"
}
set r [define_cbr_traffic $n1 $n4 800000 1]
set cbr0 [lindex $r 0]
set null0 [lindex $r 1]
$null0 set name "rsvp"
set r [define_cbr_traffic $n0 $n5 500000 2]
set cbr1 [lindex $r 0]
set null1 [lindex $r 1]
$null1 set name "norm"
proc print-sessions {} {
global rsvp1 ns
set sessions [$rsvp1 sessions]

set now [$ns now]


puts "time = $now: sessions - $sessions"
}
# write a procedure named "monitor" to measure the sending rates and bandwidth loss
proc monitor {loss_monitor prev} {
global ns ratef lossf
set name [$loss_monitor set name]
set bytes [$loss_monitor set bytes_]
set nlost [$loss_monitor set nlost_]
set now [$ns now]
set time [expr $now-$prev]
if {$time!=0} {
set rate [expr $bytes/$time*8/1000]
set lrate [expr $nlost/$time]
} else {
set rate 0
set lrate 0
}
puts "$name $now $rate Kbit/s"
puts "$name $now $lrate pkt/s lost"
puts $ratef "$now $rate"
puts $lossf "$now $lrate"
$loss_monitor set bytes_ 0
$loss_monitor set nlost_ 0
set period 0.05
$ns at [expr $now+$period] "monitor $loss_monitor $now"
}
set flow_id0 1
set rsvp_session0 [$rsvp1 session $n4 $flow_id0]
$ns at 0 "monitor $null0 0"
$ns at 0 "monitor $null1 0"
$ns at 0.01 "$rsvp1 sender $rsvp_session0 +700000 2000 20"
$ns at 0.1 "$rsvp4 reserve $rsvp_session0 FF +700000 2000 $n1"
$ns at 0.2 "$cbr1 start"
$ns at 0.35 "$cbr0 start"
$ns at 1.8 "$cbr0 stop"

$ns at 1.9 "$cbr1 stop"


$ns at 2.0 "finish"
proc finish {} {
global ns nf ratef lossf
$ns flush-trace
close $nf
close $ratef
close $lossf
exec nam out.nam &
exit 0
}
$ns run

4. References
[1]
[2]

M. Greis. RSVP/ns: An implementation of RSVP for the network simulator ns-2.


RSVP/ns Documentation, 2000.
S. Jamin, S. J. Shenker, P. B. Danzig, Comparison of Measurement-based Admission
Control Algorithms for Controlled-Load Service", Proc. IEEE INFOCOM 97, April
97.

You might also like