VPN sur MPLS et simulation

rachidTAZA Messages postés 3 Statut Membre -  
 adi -
Bonjour,
je suis etudiant en master2 je dois effectuer une etudes théorique sur vpn sur mpls et une simulation en utilisant un logiciel de simulation convenable.
je vous remerci d avance de me soutenir
j attend vous aide sur la simulation de vpn sur mpls
A voir également:

3 réponses

adi
 
peut m'aider et me donner une idée de simuler MPLS avec Local Recovery rediriger et PSL orienté protection chemin ns-2.
Je fais actuellement un projet qui vise à simuler MPLS Local Recovery rediriger et PSL orienté protection chemin ns-2.
merci de m'aider et de me donner des documents ou des sites qui contiennent des informations différentes.
1
Sophie
 
salut
tu fais ou ton master M2 stp ?? ton nom ne m'est pas bizar
0
rachidTAZA
 
bonjour Sophie
je fais mon master à l'institut supérieure du génie appliqué
alors tu me connais.
bonne réception.
0
Gentleman56 Messages postés 43 Statut Membre 11 > rachidTAZA
 
Salut à toi !

As tu des infos sur la mise en place d'un VPN mpls ?

Pour ma part, je dois réaliser un cahier des charges fictif d'une entreprise souhaitant utiliser cette technologie.

Or, pour juste réaliser une "maquette" un peu graphique du VPN, packet tracer v5 ne le prend pas en charge et avec GNS (un simulateur libre) je dois me procurer des IOS Cisco illégalement.

Merci de votre écoute.
0
walha12
 
bonjour
pouvez m'aidez et me donnez la manière de la simulation du vpn mpls sur ns-2.
je suis en cours de la réalisation d'un projet qui a pour but la simulation d'un réseau mpls.
merci de m'avoir aidé et de me donner les document ou les sites qui contiennent les différent informations.
0
rachidTAZA
 
APPENDIX B : Simulation scripts
This is the simulation scripts in TCL used for the simulations in ns-2.

Fast_reroute_one-to-one.tcl
#Create a new simulator object
set ns [new Simulator]
#create tracefiles
set na [open fully_local.tr w]
set nf [open fully_local.nam w]
$ns trace-all $na
$ns namtrace-all $nf
set f0 [open fully_local-bw.tr w]
set fs [open fully_local-seq.tr w]
# Set the colors for the different packets
$ns color 0 black
$ns color 100 blue
$ns color 2 green
$ns color 50 black
$ns color 46 purple
$ns color 3 red
$ns color 4 magenta
proc finish {} {
global ns na nf f0 fs
$ns flush-trace
close $na
close $nf
close $f0
close $fs
exec nam fully_local.nam &
exec xgraph -m fully_local-bw.tr -geometry 800x400 &
exit 0
}
proc attach-expoo-traffic {node sink size burst idle rate} {
global ns
set source [new Agent/CBR/UDP]
$ns attach-agent $node $source
set traffic [new Traffic/Expoo]
$traffic set packet-size $size
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
$source attach-traffic $traffic
$ns connect $source $sink
return $source
}
# Define a procedure which periodically records the bandwidth received by the
# traffic sink sink0 and writes it to the file f0.
set totalpkt 0
proc record {} {
global sink0 f0 totalpkt
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.065
#How many bytes have been received by the traffic sink?
set bw0 [$sink0 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the file
puts $f0 "$now [expr $bw0/$time*8/1000000]"
#Reset the bytes_ values on the traffic sink
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
set bw0 [expr $bw0 / 200]
set totalpkt [expr $totalpkt + $bw0]
}
proc recv-pkts {} {
global totalpkt seqerrnb prvseqnb
puts "The Number of Total sent packages are $prvseqnb"
puts "The Number of Total received packages are $totalpkt"
puts "The number of dropped packages are [expr $prvseqnb - $totalpkt]"
puts "The Number of Total recieved unordered packages are $seqerrnb"
}
set prvseqnb -1
set seqerrnb 0
proc seq-record {size rate ftime} {
global prvseqnb seqerrnb sink0 fs
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set tsize [parse-bw $size]
set trate [parse-bw $rate]
set time [expr double($tsize)/double($trate)/8.0]
#Get the current time
set now [$ns now]
# seek the sequence number of packet.
set revseqnb [$sink0 set expected_]
if {$prvseqnb > $revseqnb} {
incr seqerrnb 1
}
# write the sequence number of packet to the file
if {$prvseqnb != $revseqnb} {
puts $fs "$now [$sink0 set expected_]"
set prvseqnb $revseqnb
}
#Re-schedule the procedure
if { [expr $now+$time] < $ftime } {
$ns at [expr $now+$time] "seq-record $size $rate $ftime"
}
}
# routing protocol Distance Vector
$ns rtproto DV
#
# make nodes & MPLSnodes
#
set n0 [$ns node]
set n1 [$ns mpls-node]
set n2 [$ns mpls-node]
set n3 [$ns mpls-node]
set n4 [$ns mpls-node]
set n5 [$ns mpls-node]
set n6 [$ns mpls-node]
set n7 [$ns mpls-node]
set n8 [$ns mpls-node]
set n9 [$ns mpls-node]
set n10 [$ns node]
# Add RSVP-TE agents to all nodes
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]
set rsvp6 [$n6 add-rsvp-agent]
set rsvp7 [$n7 add-rsvp-agent]
set rsvp8 [$n8 add-rsvp-agent]
set rsvp9 [$n9 add-rsvp-agent]
# add variables for mpls modules
set LSRmpls1 [eval $n1 get-module "MPLS"]
set LSRmpls2 [eval $n2 get-module "MPLS"]
set LSRmpls3 [eval $n3 get-module "MPLS"]
set LSRmpls4 [eval $n4 get-module "MPLS"]
set LSRmpls5 [eval $n5 get-module "MPLS"]
set LSRmpls6 [eval $n6 get-module "MPLS"]
set LSRmpls7 [eval $n7 get-module "MPLS"]
set LSRmpls8 [eval $n8 get-module "MPLS"]
set LSRmpls9 [eval $n9 get-module "MPLS"]
#
# make links
#
$ns duplex-rsvp-link $n0 $n1 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n3 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n5 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n7 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n2 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n4 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n6 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n8 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n9 $n10 10Mb 1ms 0.99 1000 10000 Param Null
# Create a traffic sink and attach it to the node node10
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n10 $sink0
$sink0 clear
# Create a traffic source
set src0 [attach-expoo-traffic $n0 $sink0 200 0 0 5000k]
$src0 set fid_ 100
$ns color 100 magenta
# Enable upcalls on all nodes
Agent/RSVP set noisy_ 255
# Set re-route option to drop
$ns enable-reroute drop
# Start recording
$ns at 0.0 "record"
$ns at 0.3 "seq-record 200 5000k 2.0"
# The setup of working LSP
$ns at 0.0 "$LSRmpls1 create-crlsp $n0 $n9 0 100 1000 +400000 5000 32 1_3_5_7_9_"
# setup of the local recovery paths
$ns at 0.2 "$LSRmpls1 create-erlsp $n0 $n5 1 100 2000 1_2_4_6_5_"
$ns at 0.3 "$LSRmpls3 create-erlsp $n0 $n9 1 100 3000 3_4_6_8_9_"
$ns at 0.4 "$LSRmpls5 create-erlsp $n0 $n9 2 100 4000 5_6_8_9_"
$ns at 0.5 "$LSRmpls7 create-erlsp $n0 $n9 1 100 5000 7_8_9_"
# bind a flow to working LSP
$ns at 0.4 "$LSRmpls1 bind-flow-erlsp 10 100 1000"
#bind backup path to lsp
$ns at 0.7 "$LSRmpls1 reroute-lsp-binding 1000 2000"
$ns at 0.7 "$LSRmpls3 reroute-lsp-binding 1000 3000"
$ns at 0.7 "$LSRmpls5 reroute-lsp-binding 1000 4000"
$ns at 0.7 "$LSRmpls7 reroute-lsp-binding 1000 5000"
#start to send
$ns at 0.5 "$src0 start"
#active failure detection
$ns at 0.1 "$ns activate-rsvp-hello 0.005 3.5"
#break link
$ns rtmodel-at 0.8 down $n5 $n7
#stop sending
$ns at 1.8 "$src0 stop"
#finish simulation
$ns at 2.0 "recv-pkts"
$ns at 2.0 "record"
$ns at 2.0 "finish"
$ns run
Haskin.tcl
#Create a new simulator object
set ns [new Simulator]
set na [open haskin.tr w]
set nf [open haskin.nam w]
$ns trace-all $na
$ns namtrace-all $nf
set f0 [open haskin-bw.tr w]
set fs [open haskin-seq.tr w]
#set colors of messages
$ns color 0 black
$ns color 1 blue
$ns color 2 green
$ns color 50 black
$ns color 46 purple
$ns color 3 red
proc finish {} {
global ns na nf f0 fs
$ns flush-trace
close $na
close $nf
close $f0
close $fs
exec nam haskin.nam &
exec xgraph -m haskin-bw.tr -geometry 800x400 &
exit 0
}
# used to setup the sender
proc attach-expoo-traffic {node sink size burst idle rate} {
global ns
set source [new Agent/CBR/UDP]
$ns attach-agent $node $source
set traffic [new Traffic/Expoo]
$traffic set packet-size $size
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
$source attach-traffic $traffic
$ns connect $source $sink
return $source
}
# Define a procedure which periodically records the bandwidth received by the
# traffic sink sink0 and writes it to the file f0.
set totalpkt 0
proc record {} {
global sink0 f0 totalpkt
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.03532
#How many bytes have been received by the traffic sink?
set bw0 [$sink0 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the file
puts $f0 "$now [expr $bw0/$time*8/1000000]"
#Reset the bytes_ values on the traffic sink
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
set bw0 [expr $bw0 / 200]
set totalpkt [expr $totalpkt + $bw0]
}
proc recv-pkts {} {
global totalpkt seqerrnb prvseqnb
puts "The Number of Total sent packages are $prvseqnb"
puts "The Number of Total received packages are $totalpkt"
puts "The number of dropped packages are [expr $prvseqnb - $totalpkt]"
puts "The Number of Total recieved unordered packages are $seqerrnb"
}
set prvseqnb -1
set seqerrnb 0
proc seq-record {size rate ftime} {
global prvseqnb seqerrnb sink0 fs
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set tsize [parse-bw $size]
set trate [parse-bw $rate]
set time [expr double($tsize)/double($trate)/8.0]
#Get the current time
set now [$ns now]
# seek the sequence number of packet.
set revseqnb [$sink0 set expected_]
if {$prvseqnb > $revseqnb} {
incr seqerrnb 1
}
# write the sequence number of packet to the file
if {$prvseqnb != $revseqnb} {
puts $fs "$now [$sink0 set expected_]"
set prvseqnb $revseqnb
}
#Re-schedule the procedure
if { [expr $now+$time] < $ftime } {
$ns at [expr $now+$time] "seq-record $size $rate $ftime"
}
}
# routing protocol distance vector
$ns rtproto DV
# make nodes & MPLSnodes
set n0 [$ns node]
set n1 [$ns mpls-node]
set n2 [$ns mpls-node]
set n3 [$ns mpls-node]
set n4 [$ns mpls-node]
set n5 [$ns mpls-node]
set n6 [$ns mpls-node]
set n7 [$ns mpls-node]
set n8 [$ns mpls-node]
set n9 [$ns mpls-node]
set n10 [$ns node]
# Add RSVP-TE agents to all nodes
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]
set rsvp6 [$n6 add-rsvp-agent]
set rsvp7 [$n7 add-rsvp-agent]
set rsvp8 [$n8 add-rsvp-agent]
set rsvp9 [$n9 add-rsvp-agent]
# add variables for mpls modules
set LSRmpls1 [eval $n1 get-module "MPLS"]
set LSRmpls2 [eval $n2 get-module "MPLS"]
set LSRmpls3 [eval $n3 get-module "MPLS"]
set LSRmpls4 [eval $n4 get-module "MPLS"]
set LSRmpls5 [eval $n5 get-module "MPLS"]
set LSRmpls6 [eval $n6 get-module "MPLS"]
set LSRmpls7 [eval $n7 get-module "MPLS"]
set LSRmpls8 [eval $n8 get-module "MPLS"]
set LSRmpls9 [eval $n9 get-module "MPLS"]
# make links
$ns duplex-rsvp-link $n0 $n1 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n3 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n5 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n7 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n2 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n4 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n6 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n8 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n9 $n10 10Mb 1ms 0.99 1000 10000 Param Null
# Create a traffic sink and attach it to the node node10
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n10 $sink0
$sink0 clear
# Create a traffic source
set src0 [attach-expoo-traffic $n0 $sink0 200 0 0 5000k]
$src0 set fid_ 100
$ns color 100 magenta
# Enable upcalls on all nodes
Agent/RSVP set noisy_ 255
# Set re-route option to drop
$ns enable-reroute drop
# Start recording
$ns at 0.0 "record"
$ns at 0.3 "seq-record 200 5000k 2.0"
# The setup of working LSP
$ns at 0.0 "$LSRmpls1 create-erlsp $n0 $n9 0 100 1000 1_3_5_7_9_"
# The setup of global recovery LSP
$ns at 0.1 "$LSRmpls1 create-erlsp $n1 $n9 1 100 2000 1_2_4_6_8_9_"
#activate the hello mechanism
$ns at 0.1 "$ns activate-rsvp-hello 0.005 3.5"
#Setup of reverse path. php used..
$ns at 0.4 "$LSRmpls7 create-erlsp $n7 $n2 1 100 2005 7_5_3_1_2_"
# bind a flow to working LSP
$ns at 0.4 "$LSRmpls1 bind-flow-erlsp 10 100 1000"
#start sending traffic
$ns at 0.5 "$src0 start"
#binding working LSP to alternative LSP
$ns at 0.6 "$LSRmpls1 reroute-lsp-binding 1000 2000"
$ns at 0.6 "$LSRmpls3 reroute-lsp-binding 1000 2005"
$ns at 0.6 "$LSRmpls5 reroute-lsp-binding 1000 2005"
$ns at 0.6 "$LSRmpls7 reroute-lsp-binding 1000 2005"
#break link
$ns rtmodel-at 0.8 down $n5 $n7
#stop trffic
$ns at 1.8 "$src0 stop"
#end simulation
$ns at 2.0 "recv-pkts"
$ns at 2.0 "record"
$ns at 2.0 "finish"
$ns run
Local_Reroute.tcl
#Create a new simulator object
set ns [new Simulator]
set na [open local_precalc_shortest.tr w]
set nf [open local_precalc_shortest.nam w]
$ns trace-all $na
$ns namtrace-all $nf
set f0 [open local_precalc_shortest-bw.tr w]
set fs [open local_precalc_shortest-seq.tr w]
#colors for the message types
$ns color 0 yellow
$ns color 100 blue
$ns color 2 green
$ns color 50 black
$ns color 46 purple
$ns color 3 red
$ns color 4 magenta
proc finish {} {
global ns na nf f0 fs
$ns flush-trace
close $na
close $nf
close $f0
close $fs
exec nam local_precalc_shortest.nam &
exec xgraph -m local_precalc_shortest-bw.tr -geometry 800x400 &
exit 0
}
proc attach-expoo-traffic {node sink size burst idle rate} {
global ns
set source [new Agent/CBR/UDP]
$ns attach-agent $node $source
set traffic [new Traffic/Expoo]
$traffic set packet-size $size
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
$source attach-traffic $traffic
$ns connect $source $sink
return $source
}
# Define a procedure which periodically records the bandwidth received by the
# traffic sink sink0 and writes it to the file f0.
set totalpkt 0
proc record {} {
global sink0 f0 totalpkt
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.065
#How many bytes have been received by the traffic sink?
set bw0 [$sink0 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the file
puts $f0 "$now [expr $bw0/$time*8/1000000]"
#Reset the bytes_ values on the traffic sink
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
set bw0 [expr $bw0 / 200]
set totalpkt [expr $totalpkt + $bw0]
}
proc recv-pkts {} {
global totalpkt seqerrnb prvseqnb
puts "The Number of Total sent packages are $prvseqnb"
puts "The Number of Total received packages are $totalpkt"
puts "The number of dropped packages are [expr $prvseqnb - $totalpkt]"
puts "The Number of Total recieved unordered packages are $seqerrnb"
}
set prvseqnb -1
set seqerrnb 0
proc seq-record {size rate ftime} {
global prvseqnb seqerrnb sink0 fs
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set tsize [parse-bw $size]
set trate [parse-bw $rate]
set time [expr double($tsize)/double($trate)/8.0]
#Get the current time
set now [$ns now]
# seek the sequence number of packet.
set revseqnb [$sink0 set expected_]
if {$prvseqnb > $revseqnb} {
incr seqerrnb 1
}
# write the sequence number of packet to the file
if {$prvseqnb != $revseqnb} {
puts $fs "$now [$sink0 set expected_]"
set prvseqnb $revseqnb
}
#Re-schedule the procedure
if { [expr $now+$time] < $ftime } {
$ns at [expr $now+$time] "seq-record $size $rate $ftime"
}
}
# routing protocol
$ns rtproto DV
#
# make nodes & MPLSnodes
#
set n0 [$ns node]
set n1 [$ns mpls-node]
set n2 [$ns mpls-node]
set n3 [$ns mpls-node]
set n4 [$ns mpls-node]
set n5 [$ns mpls-node]
set n6 [$ns mpls-node]
set n7 [$ns mpls-node]
set n8 [$ns mpls-node]
set n9 [$ns mpls-node]
set n10 [$ns node]
# Add RSVP-TE agents to all nodes
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]
set rsvp6 [$n6 add-rsvp-agent]
set rsvp7 [$n7 add-rsvp-agent]
set rsvp8 [$n8 add-rsvp-agent]
set rsvp9 [$n9 add-rsvp-agent]
# add variables for mpls modules
set LSRmpls1 [eval $n1 get-module "MPLS"]
set LSRmpls2 [eval $n2 get-module "MPLS"]
set LSRmpls3 [eval $n3 get-module "MPLS"]
set LSRmpls4 [eval $n4 get-module "MPLS"]
set LSRmpls5 [eval $n5 get-module "MPLS"]
set LSRmpls6 [eval $n6 get-module "MPLS"]
set LSRmpls7 [eval $n7 get-module "MPLS"]
set LSRmpls8 [eval $n8 get-module "MPLS"]
set LSRmpls9 [eval $n9 get-module "MPLS"]
#
# make links
#
$ns duplex-rsvp-link $n0 $n1 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n3 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n5 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n7 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n2 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n4 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n6 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n8 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n9 $n10 10Mb 1ms 0.99 1000 10000 Param Null
# Create a traffic sink and attach it to the node node10
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n10 $sink0
$sink0 clear
# Create a traffic source
set src0 [attach-expoo-traffic $n0 $sink0 200 0 0 5000k]
$src0 set fid_ 100
$ns color 100 magenta
# Enable upcalls on all nodes
Agent/RSVP set noisy_ 255
#function that calculates a new recovery path
proc setup_backup_path {lspid} {
global ns LSRmpls5 n0 n9
set oiface [$LSRmpls5 get-outgoing-iface $lspid]
set fec [$LSRmpls5 get-fec-for-lspid $lspid]
set qosid [$LSRmpls5 get-flowid-for-lspid $lspid]
set failnext [$LSRmpls5 get-failnext-for-lspid $lspid]
if {$failnext != -1} {
set fnodes [split $failnext "_"]
set fnodes [linsert $fnodes 0 $oiface]
} else {
set fnodes $oiface
}
set er [$ns get-shortest-path [[$LSRmpls5 node] id] $fec $fnodes "" ]
while { $er == -1 } {
if { [llength $fnodes] == 0} {
puts "error: routing failure"
return -1
}
set dst [lindex $fnodes end]
set fnodes [lreplace $fnodes end end]
set er [$ns get-shortest-path [[$LSRmpls5 node] id] $dst $fnodes "" ]
}
set er [append $er $er _]
puts "Setting up recovery path $er"
$ns at [$ns now] "$LSRmpls5 create-crlsp $n0 $n9 1 100 2000 +400000 5000 32 $er"
#bind backup path to lsp, value for time found in tracefiles
$ns at 0.8263 "$LSRmpls5 reroute-lsp-binding 1000 2000"
}
# Set re-route option to drop
$ns enable-reroute drop
# Start recording
$ns at 0.0 "record"
$ns at 0.3 "seq-record 200 5000k 2.0"
# The setup of working LSP
$ns at 0.0 "$LSRmpls1 create-crlsp $n0 $n9 0 100 1000 +400000 5000 32 1_3_5_7_9_"
# bind a flow to working LSP
$ns at 0.4 "$LSRmpls1 bind-flow-erlsp 10 100 1000"
#start sending
$ns at 0.5 "$src0 start"
#break link
$ns rtmodel-at 0.8 down $n5 $n7
#active failure detection
$ns at 0.1 "$ns activate-rsvp-hello 0.005 3.5"
# The setup of backup LSP, time added for path calculation
$ns at 0.81949 "setup_backup_path 1000"
$ns at 1.8 "$src0 stop"
$ns at 2.0 "recv-pkts"
$ns at 2.0 "record"
$ns at 2.0 "finish"
$ns run
Makam.tcl
#Create a new simulator object
set ns [new Simulator]
set na [open prealloc.tr w]
set nf [open prealloc.nam w]
$ns trace-all $na
$ns namtrace-all $nf
set f0 [open prealloc-bw.tr w]
set fs [open prealloc-seq.tr w]
#colors for the different message types
$ns color 0 yellow
$ns color 100 blue
$ns color 2 green
$ns color 50 black
$ns color 46 purple
$ns color 3 red
$ns color 4 magenta
proc finish {} {
global ns na nf f0 fs
$ns flush-trace
close $na
close $nf
close $f0
close $fs
exec nam prealloc.nam &
exec xgraph -m prealloc-bw.tr -geometry 800x400 &
exit 0
}
proc attach-expoo-traffic {node sink size burst idle rate} {
global ns
set source [new Agent/CBR/UDP]
$ns attach-agent $node $source
set traffic [new Traffic/Expoo]
$traffic set packet-size $size
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
$source attach-traffic $traffic
$ns connect $source $sink
return $source
}
# Define a procedure which periodically records the bandwidth received by the
# traffic sink sink0 and writes it to the file f0.
set totalpkt 0
proc record {} {
global sink0 f0 totalpkt
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.065
#How many bytes have been received by the traffic sink?
set bw0 [$sink0 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the file
puts $f0 "$now [expr $bw0/$time*8/1000000]"
#Reset the bytes_ values on the traffic sink
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
set bw0 [expr $bw0 / 200]
set totalpkt [expr $totalpkt + $bw0]
}
proc recv-pkts {} {
global totalpkt seqerrnb prvseqnb
puts "The Number of Total sent packages are $prvseqnb"
puts "The Number of Total received packages are $totalpkt"
puts "The number of dropped packages are [expr $prvseqnb - $totalpkt]"
puts "The Number of Total recieved unordered packages are $seqerrnb"
}
set prvseqnb -1
set seqerrnb 0
proc seq-record {size rate ftime} {
global prvseqnb seqerrnb sink0 fs
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set tsize [parse-bw $size]
set trate [parse-bw $rate]
set time [expr double($tsize)/double($trate)/8.0]
#Get the current time
set now [$ns now]
# seek the sequence number of packet.
set revseqnb [$sink0 set expected_]
if {$prvseqnb > $revseqnb} {
incr seqerrnb 1
}
# write the sequence number of packet to the file
if {$prvseqnb != $revseqnb} {
puts $fs "$now [$sink0 set expected_]"
set prvseqnb $revseqnb
}
#Re-schedule the procedure
if { [expr $now+$time] < $ftime } {
$ns at [expr $now+$time] "seq-record $size $rate $ftime"
}
}
# routing protocol
$ns rtproto DV
#
# make nodes & MPLSnodes
#
set n0 [$ns node]
set n1 [$ns mpls-node]
set n2 [$ns mpls-node]
set n3 [$ns mpls-node]
set n4 [$ns mpls-node]
set n5 [$ns mpls-node]
set n6 [$ns mpls-node]
set n7 [$ns mpls-node]
set n8 [$ns mpls-node]
set n9 [$ns mpls-node]
set n10 [$ns node]
# Add RSVP-TE agents to all nodes
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]
set rsvp6 [$n6 add-rsvp-agent]
set rsvp7 [$n7 add-rsvp-agent]
set rsvp8 [$n8 add-rsvp-agent]
set rsvp9 [$n9 add-rsvp-agent]
# add variables for mpls modules
set LSRmpls1 [eval $n1 get-module "MPLS"]
set LSRmpls2 [eval $n2 get-module "MPLS"]
set LSRmpls3 [eval $n3 get-module "MPLS"]
set LSRmpls4 [eval $n4 get-module "MPLS"]
set LSRmpls5 [eval $n5 get-module "MPLS"]
set LSRmpls6 [eval $n6 get-module "MPLS"]
set LSRmpls7 [eval $n7 get-module "MPLS"]
set LSRmpls8 [eval $n8 get-module "MPLS"]
set LSRmpls9 [eval $n9 get-module "MPLS"]
#
# make links
#
$ns duplex-rsvp-link $n0 $n1 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n3 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n5 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n7 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n2 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n4 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n6 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n8 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n9 $n10 10Mb 1ms 0.99 1000 10000 Param Null
# Create a traffic sink and attach it to the node node10
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n10 $sink0
$sink0 clear
# Create a traffic source
set src0 [attach-expoo-traffic $n0 $sink0 200 0 0 5000k]
$src0 set fid_ 100
$ns color 100 magenta
# Enable upcalls on all nodes
Agent/RSVP set noisy_ 255
# Set re-route option to drop
$ns enable-reroute drop
# Start recording
$ns at 0.0 "record"
$ns at 0.3 "seq-record 200 5000k 2.0"
# The setup of working LSP
$ns at 0.0 "$LSRmpls1 create-crlsp $n0 $n9 0 100 1000 +400000 5000 32 1_3_5_7_9_"
# The setup of backup LSP
$ns at 0.2 "$LSRmpls1 reroute-prealloc $n0 $n9 $n10 0 1 100 2000 +400000 5000 32 1_2_4_6_8_9_"
# bind a flow to working LSP
$ns at 0.4 "$LSRmpls1 bind-flow-erlsp 10 100 1000"
# start sending traffic
$ns at 0.5 "$src0 start"
#Break link
$ns rtmodel-at 0.8 down $n5 $n7
#activate hello
$ns at 0.1 "$ns activate-rsvp-hello 0.005 3.5"
$ns at 1.8 "$src0 stop"
$ns at 2.0 "recv-pkts"
$ns at 2.0 "record"
$ns at 2.0 "finish"
$ns run
Best_Effort.tcl
#Create a new simulator object
set ns [new Simulator]
set na [open precalc.tr w]
set nf [open precalc.nam w]
$ns trace-all $na
$ns namtrace-all $nf
set f0 [open precalc-bw.tr w]
set fs [open precalc-seq.tr w]
#colors for the different message types
$ns color 0 yellow
$ns color 100 blue
$ns color 2 green
$ns color 50 black
$ns color 46 purple
$ns color 3 red
$ns color 4 magenta
proc finish {} {
global ns na nf f0 fs
$ns flush-trace
close $na
close $nf
close $f0
close $fs
exec nam precalc.nam &
exec xgraph -m precalc-bw.tr -geometry 800x400 &
exit 0
}
proc attach-expoo-traffic {node sink size burst idle rate} {
global ns
set source [new Agent/CBR/UDP]
$ns attach-agent $node $source
set traffic [new Traffic/Expoo]
$traffic set packet-size $size
$traffic set burst-time $burst
$traffic set idle-time $idle
$traffic set rate $rate
$source attach-traffic $traffic
$ns connect $source $sink
return $source
}
# Define a procedure which periodically records the bandwidth received by the
# traffic sink sink0 and writes it to the file f0.
set totalpkt 0
proc record {} {
global sink0 f0 totalpkt
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.065
#How many bytes have been received by the traffic sink?
set bw0 [$sink0 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the file
puts $f0 "$now [expr $bw0/$time*8/1000000]"
#Reset the bytes_ values on the traffic sink
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
set bw0 [expr $bw0 / 200]
set totalpkt [expr $totalpkt + $bw0]
}
proc recv-pkts {} {
global totalpkt seqerrnb prvseqnb
puts "The Number of Total sent packages are $prvseqnb"
puts "The Number of Total received packages are $totalpkt"
puts "The number of dropped packages are [expr $prvseqnb - $totalpkt]"
puts "The Number of Total recieved unordered packages are $seqerrnb"
}
set prvseqnb -1
set seqerrnb 0
proc seq-record {size rate ftime} {
global prvseqnb seqerrnb sink0 fs
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set tsize [parse-bw $size]
set trate [parse-bw $rate]
set time [expr double($tsize)/double($trate)/8.0]
#Get the current time
set now [$ns now]
# seek the sequence number of packet.
set revseqnb [$sink0 set expected_]
if {$prvseqnb > $revseqnb} {
incr seqerrnb 1
}
# write the sequence number of packet to the file
if {$prvseqnb != $revseqnb} {
puts $fs "$now [$sink0 set expected_]"
set prvseqnb $revseqnb
}
#Re-schedule the procedure
if { [expr $now+$time] < $ftime } {
$ns at [expr $now+$time] "seq-record $size $rate $ftime"
}
}
# routing protocol
#$ns rtproto DV
#
# make nodes & MPLSnodes
#
set n0 [$ns node]
set n1 [$ns mpls-node]
set n2 [$ns mpls-node]
set n3 [$ns mpls-node]
set n4 [$ns mpls-node]
set n5 [$ns mpls-node]
set n6 [$ns mpls-node]
set n7 [$ns mpls-node]
set n8 [$ns mpls-node]
set n9 [$ns mpls-node]
set n10 [$ns node]
# Add RSVP-TE agents to all nodes
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]
set rsvp6 [$n6 add-rsvp-agent]
set rsvp7 [$n7 add-rsvp-agent]
set rsvp8 [$n8 add-rsvp-agent]
set rsvp9 [$n9 add-rsvp-agent]
# add variables for mpls modules
set LSRmpls1 [eval $n1 get-module "MPLS"]
set LSRmpls2 [eval $n2 get-module "MPLS"]
set LSRmpls3 [eval $n3 get-module "MPLS"]
set LSRmpls4 [eval $n4 get-module "MPLS"]
set LSRmpls5 [eval $n5 get-module "MPLS"]
set LSRmpls6 [eval $n6 get-module "MPLS"]
set LSRmpls7 [eval $n7 get-module "MPLS"]
set LSRmpls8 [eval $n8 get-module "MPLS"]
set LSRmpls9 [eval $n9 get-module "MPLS"]
#
# make links
#
$ns duplex-rsvp-link $n0 $n1 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n3 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n5 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n7 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n2 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n4 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n6 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n8 $n9 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n1 $n2 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n3 $n4 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n5 $n6 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n7 $n8 10Mb 1ms 0.99 1000 10000 Param Null
$ns duplex-rsvp-link $n9 $n10 10Mb 1ms 0.99 1000 10000 Param Null
# Create a traffic sink and attach it to the node node10
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n10 $sink0
$sink0 clear
# Create a traffic source
set src0 [attach-expoo-traffic $n0 $sink0 200 0 0 5000k]
$src0 set fid_ 100
$ns color 100 magenta
# Enable upcalls on all nodes
Agent/RSVP set noisy_ 255
# Set re-route option to drop
$ns enable-reroute drop
# Start recording
$ns at 0.0 "record"
$ns at 0.3 "seq-record 200 5000k 2.0"
# The setup of working LSP
$ns at 0.0 "$LSRmpls1 create-crlsp $n0 $n9 0 100 1000 +400000 5000 32 1_3_5_7_9_"
# The setup of backup LSP
$ns at 0.2 "$LSRmpls1 reroute-precalc $n0 $n9 $n10 0 100 2000 +400000 5000 32 1_2_4_6_8_9_"
# bind a flow to working LSP
$ns at 0.4 "$LSRmpls1 bind-flow-erlsp 10 100 1000"
#start traffic sending
$ns at 0.5 "$src0 start"
#break link
$ns rtmodel-at 0.8 down $n5 $n7
#activate hello
$ns at 0.1 "$ns activate-rsvp-hello 0.005 3.5"
$ns at 1.8 "$src0 stop"
$ns at 2.0 "recv-pkts"
$ns at 2.0 "record"
$ns at 2.0 "finish"
$ns run






APPENDIX C : Ns-2 modifications
This is some of the modifications that had to bee done to implement failure detection by RSVP-TE hellos in ns-2. For the full implementation a patch is available for download from [68].
Ns-mpls-node.tcl
RtModule/MPLS instproc activate_rsvp_hello {Dest Hinterv Dinterv} {
global ns
set class [$self set classifier_]
set node1 [$class set mpls_node_]
set agent1 [$node1 set rsvp_]
set node1_ID [$node1 set id_]
set dest_ [$Dest set id_]
$agent1 start-hello $dest_ $Hinterv
$agent1 hello_check_failure $dest_ $Hinterv $Dinterv $node1_ID
}
Agent/RSVP instproc reschedule_hello_request {Dest H_interv} {
global ns
$ns at [expr [$ns now] + $H_interv] "$self start-hello $Dest $H_interv"
}
Agent/RSVP instproc hello_check_failure {Dest Hintervall Dintervall my_id} {
global ns
set intervall [expr $Hintervall * $Dintervall]
set check_time [expr [$ns now] + $Hintervall * $Dintervall]
$ns at $check_time "$self hello_check $Dest $intervall $my_id"
}
Agent/RSVP instproc reschedule_hello_check {Dest interv my_id} {
global ns
set check_time [expr [$ns now] + $interv]
$ns at $check_time "$self hello_check $Dest $interv $my_id"
}
Agent/RSVP instproc hello_set_lib_error {from_node to_node lspid} {
global ns
puts "Breaking connection for LSP $lspid at [$ns now]"
$self instvar node_
set MPLSnode [eval $node_ get-module "MPLS"]
$ns at [$ns now] "$MPLSnode set-lib-error-for-lspid $lspid 1"
}
Simulator instproc activate-rsvp-hello {hello_int fail_int} {
$self instvar linked_mplsnodes_
set len [llength $linked_mplsnodes_]
for {set i 0} {$i < $len} {incr i} {
set me [lindex $linked_mplsnodes_ $i]
set class [$me set classifier_]
set node1 [$class set mpls_node_]
set agent1 [$me set rsvp_]
set node1_ID [$me set id_]
set mpls_node1 [eval $node1 get-module "MPLS"]
RSVP-objects.h
class HELLO : public RSVPobject {
public:
HELLO(long src, long dst,int ctype);
HELLO(unsigned char *cont);
virtual ~HELLO() {};
inline long get_src_inst() { return con->src_inst;}
inline long get_dst_inst() { return con->dst_inst;}
void dump_object();
private:
struct construct {
long src_inst;
long dst_inst;
};
struct construct *con;
};
RSVP-objects.cc
HELLO::HELLO(long src, long dest, int ctype) {
int cl;
cl = sizeof(struct objheader) + sizeof(struct construct);
contents = new unsigned char[cl];
header = (objheader *)contents;
con = (construct *)(contents + sizeof(struct objheader));
header->ctype = ctype; // 1 is for REQUEST , 2 is for ACK
header->length = 12;
con->src_inst = src;
con->dst_inst = dest;
header->classnum = 22;
header->conlength = cl;
}
HELLO::HELLO(unsigned char *cont) {
header = (objheader *)cont;
contents = new unsigned char[header->conlength];
memcpy(contents, cont, header->conlength);
header = (objheader *)contents;
con = (construct *)(contents + sizeof(struct objheader));
}
void HELLO::dump_object() {
RSVPobject::dump_object();
printf(" HELLO: src instance: %ld dst instance: %ld\n",
con->src_inst, con->dst_inst);
}
RSVP.cc
if (strcmp(argv[1], "start-hello") == 0) {
nsaddr_t destination;
if (argc != 4) {
return (TCL_ERROR);
}
destination = atoi(argv[2]);
send_hello_message(destination, 1); // start by sending a REQUEST message
//reschedule a new REQUEST message
tcl.evalf("%s reschedule_hello_request %i %f", name(), atoi(argv[2]),atof(argv[3]));
return (TCL_OK);
}
// Used to check if HELLO has detected a failure
if(strcmp(argv[1],"hello_check") == 0) {
nsaddr_t destination;
nsaddr_t this_node;
float intervall;
hello_values *hello_req;
hello_values *hello_ack;
hello_req = hello_requested_;
hello_ack = hello_acked_;
double req_time;
double ack_time;
if(argc != 5) {
return (TCL_ERROR);
}
destination = atoi(argv[2]);
intervall = atof(argv[3]);
this_node = atoi(argv[4]);
if(hello_req != NULL){
while((hello_req->node != destination) && (hello_req != NULL)){
hello_req = hello_req->next;
}
if(hello_req->node == destination){
ack_time = hello_req->acked_time;
}
else {
printf("[HELLO] Something is wrong, didn't find instance value for node %i in node %i instance list\n",destination,this_node);
}
}
else {
printf("[HELLO] Something is wrong, there is no instance values list for node % in node %i \n",destination,this_node);
}
if((Scheduler::instance().clock() - intervall) > ack_time ) { // did I loose the connection ?
// set instance value for neighbor to 0
hello_req->neighbor_instance = 0;
// take a new instance value to send to this neighbor
hello_req->my_instance = rand();
elem *node_list;
session *s_list;
psb *p_list;
s_list = s_list_;
while (s_list != NULL) {
p_list = s_list->psb_list;
while (p_list != NULL){
node_list = p_list->ero->get_ero();
while (node_list != NULL) {
if((node_list->nodo == this_node) && (node_list->pun != NULL)){
if(node_list->pun->nodo == destination){
tcl.evalf("%s hello_set_lib_error %i %i %i",name(),destination,this_node,p_list->tid);
tcl.evalf("%s break-link-hello %i", name(),destination);
}
else {break;}
}
node_list = node_list->pun;
}
p_list = p_list->next;
}
s_list = s_list->next;
}
//reschedule a new failure check
tcl.evalf("%s reschedule_hello_check %i %f %i", name(), destination ,atof(argv[3]),this_node);
return (TCL_OK);
}
return (Agent::command(argc, argv));
}
void RSVPAgent::process_hello_message(RSVPmessage *msg, nsaddr_t fromhop) {
hello_values *hello_list;
long src_inst;
long dst_inst;
int c_type;
int rand_int;
HELLO *he = (HELLO *)msg->get_first(22);
src_inst = he->get_src_inst();
dst_inst = he->get_dst_inst();
c_type = he->get_ctype();
if(c_type == 1) { // This is a REQUEST message
hello_list = hello_acked_; // get the instance list
if (dst_inst == 0) { // is this the first message recieved or the sender has lost connection
// during the set time period.
if(hello_list != NULL){
while(hello_list->next != NULL){
if(hello_list->node == fromhop)
{break;}
else {
hello_list = hello_list->next;
}
}
if(hello_list->node != fromhop) {
hello_list->next = new hello_values();
hello_list = hello_list->next;
hello_list->neighbor_instance = src_inst;
rand_int = rand();
hello_list->my_instance = rand_int;
hello_list->node = fromhop;
}
else {
// this node has restarted
hello_list->neighbor_instance = src_inst;
hello_list->my_instance = rand(); // create a new instance for my self since i have restarted
}
}
else // hello_list == NULL
{
hello_list = new hello_values();
hello_list->neighbor_instance = src_inst;
rand_int = rand();
hello_list->my_instance = rand_int; // the instance value is a random number
hello_list->node = fromhop;
hello_acked_ = hello_list;
}
}
send_hello_message(fromhop,2); // send ACK message
}
else if(c_type == 2) { // recieved an ACK message
hello_list = hello_requested_;
if(hello_list == NULL){
printf("Something is wrong, recieved an HELLO ACK object but there is no instance value for this node in the list\n");
}
else {
while(hello_list->next != NULL) {
if(hello_list->node != fromhop){
hello_list = hello_list->next;
}
else {
break;
}
}
if(hello_list->node == fromhop){ // check if the node has restarted
if(hello_list->neighbor_instance != src_inst){
if(hello_list->neighbor_instance == 0){
hello_list->neighbor_instance = src_inst;
}
else {
// printf("Node has restarted\n");
hello_list->neighbor_instance == src_inst;
}
}
hello_list->acked_time = Scheduler::instance().clock(); // updates time for hello_requested
}
}
}
}
void RSVPAgent::send_hello_message(nsaddr_t destination, int ctype) {
if (nam_) {
type_ = PT_HELLO;
}
int rand_int;
hello_values *hello_sessions;
if (ctype == 1) {
hello_sessions = hello_requested_;
}
else if (ctype == 2){
hello_sessions = hello_acked_;
}
long src_inst;
long dst_inst;
// save the values internally in the agent.
if (hello_sessions == NULL){ // shall we make a new record
hello_sessions = new hello_values();
hello_sessions->node = destination;
rand_int = rand();
hello_sessions->my_instance = rand_int;
hello_sessions->neighbor_instance = 0;
if(ctype == 1){
hello_requested_ = hello_sessions; // saves the newly created list object
}
}
else {
while (hello_sessions->next != NULL) { // find this HELLO session
if (hello_sessions->node == destination)
{ break; }
else
{ hello_sessions = hello_sessions->next; }
}
if(hello_sessions->node != destination) {
hello_sessions->next = new hello_values();
hello_sessions = hello_sessions->next;
hello_sessions->node = destination;
if(ctype == 1){
hello_sessions->neighbor_instance = 0;
rand_int=rand();
hello_sessions->my_instance = rand_int;
}
}
}//else (hello_sessions == NULL)
if (ctype == 1) { // This is a REQUEST message
src_inst = hello_sessions->my_instance;
dst_inst = hello_sessions->neighbor_instance;
hello_sessions->old_time = Scheduler::instance().clock();
// printf("REQUEST src_inst : %i dst_inst : %i\n",src_inst,dst_inst);
}
if (ctype == 2) { // This is an ACK message
src_inst = hello_sessions->my_instance; // instance values for ACK
dst_inst = hello_sessions->neighbor_instance; // is created in the recieving function
//printf("ACK src_inst : %i dst_inst : %i\n",src_inst,dst_inst);
}
// Create and send out the HELLO message
RSVPmessage *msg = new RSVPmessage(HELLO_TYPE, 1); // ttl set to 1
msg->add_object(new HELLO(src_inst, dst_inst, ctype));
if (ip6_) {
size_ = msg->get_length() + 40;
} else {
size_ = msg->get_length() + 24;
}
dst_.addr_ = destination;
fid_ = 46; // needs to be 46 to be assosiated with RSVP
Packet *pkt = allocpkt();
pkt->allocdata(msg->get_conlength());
memcpy(pkt->accessdata(), msg->get_contents(), msg->get_conlength());
send(pkt, 0);
delete msg;
}
0