Sie sind auf Seite 1von 11

Network Simulator:

Routing
[Examples taken from E. Altman notes]

Daniele Messina, Ilenia Tinnirello


Routing
 Four routing strategies:
Static
Session
Dynamic
Manual
 A routing protocol is a realization of a specific algorithm.
 rtproto{} is the instance procedure in the class Simulator
that specifies the unicast routing protocol to be used in
the simulation

$ns rtproto Static ;# Enable static route strategy for the simulation
$ns rtproto Session ;# Enable session routing for this simulation
$ns rtproto DV $n1 $n2 $n3 ;# Run DV agents on nodes $n1, $n2, and $n3
$ns rtproto LS $n1 $n2 ;# Run link state routing on specified nodes

Daniele Messina, Ilenia Tinnirello


Link costs
 In the currently implemented route protocols, the metric
of a route to a destination, at a node is the cost to reach
the destination from that node. It is possible to change the
link costs at each of the links.

$ns cost $n1 $n2 10 ;# set cost of link from $n1 to $n2 to 10
$ns cost $n2 $n1 5 ;# set cost of link in reverse direction to 5
[$ns link $n1 $n2] cost? ;# query cost of link from $n1 to $n2
[$ns link $n2 $n1] cost? ;# query cost of link in reverse direction

Daniele Messina, Ilenia Tinnirello


Routing strategies

Static routing:
The static route computation strategy is the
default route computation mechanism in ns.
Uses the Dijkstras all-pairs SPF algorithm.
The route computation algorithm is run exactly
once prior to the start of the simulation.

Daniele Messina, Ilenia Tinnirello


Routing strategies
 Session routing:
provides complete and instantaneous routing changes in the
presence of topology dynamics.
 DV Routing (Agent/rtProto/DV):
is the implementation of Distributed Bellman-Ford (or Distance
Vector) routing in ns.
periodic route updates every advertInterval (default 2secs)
triggered updates:
changes in the topology
received route update
employs the split horizon with poisoned reverse mechanisms to
advertise its routes to adjacent peers.

Daniele Messina, Ilenia Tinnirello


Routing strategies
 Manual Routing:
user may configure the routing table by hand

$ns rtproto Manual


set n1 [$ns node]
set n2 [$ns node]
$ns duplex-link $n1 $n2 10Mb 100ms DropTail
[$n1 get-module "Manual"] add-route-to-adj-node -default $n2
[$n1 get-module "Manual"] add-route-to-adj-node $n2
[$n2 get-module "Manual"] add-route-to-adj-node -default $n1

#file:manual-routing.tcl

Daniele Messina, Ilenia Tinnirello


Routing commands
 $ns get_routelogic
 $route_logic lookup <src> <dst>
 $rtobj rtProto?
 $rtobj nexthop? <dst>
 $rtobj metric? <dst>
 ...

Daniele Messina, Ilenia Tinnirello


Network Dynamics
 The instance procedure rtmodel{} defines a model to be
applied to the nodes and links in the topology.

#<start> <on> <off> <end>


$ns rtmodel Exponential 0.5 1.0 1.0 5.0 $n1 ;#apply to node
$ns rtmodel Trace dynamics.trc $n2 $n3 ;#apply to link
$ns rtmodel Deterministic 20.0 20.0 $node(1) $node(5)

 The instance procedure rtmodel-at{} is a special interface to


the Manual model of network dynamics. The command
takes the time, operation, and node or link as arguments,
and applies the operation at the specified time.

$ns rtmodel-at 3.5 up $n0


$ns rtmodel-at 3.9 up $n3 $n5
$ns rtmodel-at 40 down $n4

Daniele Messina, Ilenia Tinnirello


Routing Examples
Suppose there is a session between node 0
and node 5
The default static routing used by ns will choose route 0-1-4-5
Conversely, it is possible to set a dynamic routing protocol
 $ns rtproto DV

Daniele Messina, Ilenia Tinnirello


Exercises
See the nam animation of ex1.tcl by activating or
deactivating the dynamic routing protocol. What happens
in presence of static routing?
Run the ex2.tcl file by commenting or not the $ns cost
$n1 $n4 5 line. What is the effect of such a line?

Daniele Messina, Ilenia Tinnirello


Hierarchical routing
 Setting the hierarchical address format
$ns set-address-format hierarchical
 32 bits for port-id, 32 bits in 3 levels for node id (10, 11, 11)
$ns set-address-format hierarchical <#n hierarchy levels>
<#bits for level1> <#bits for level 2> ....<#bits for nth
level>

 The AddrParams class is used to store the topology hierarchy.


AddrParams set domain_num_ 2
lappend cluster_num 2 2
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 2 3 2 3
AddrParams set nodes_num_ $eilastlevel
 This defines a topology with 2 domains, say D1 and D2 with 2 clusters each
(C11 & C12 in D1 and C21 & C22 in D2). Then number of nodes in each of
these 4 clusters is specified as 2,3,2 and 3 respectively.

Daniele Messina, Ilenia Tinnirello

Das könnte Ihnen auch gefallen