1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
|
# -*- Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
#
# Time-stamp: <2000-09-11 15:22:45 haoboy>
#
# Copyright (c) 1995 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the Computer Systems
# Engineering Group at Lawrence Berkeley Laboratory.
# 4. Neither the name of the University nor of the Laboratory may be used
# to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-mpls.tcl,v 1.6 2005/06/11 04:42:09 sfloyd Exp $
remove-all-packet-headers ; # removes all except common
add-packet-header Flags IP RTP TCP MPLS LDP ; # hdrs reqd for validation test
# FOR UPDATING GLOBAL DEFAULTS:
Class TestSuite
TestSuite instproc init { name } {
$self instvar ns_ totalpkt_ testname_
set testname_ $name
set ns_ [new Simulator]
set totalpkt_ 0
}
TestSuite instproc finish args {
$self instvar traceFile_ ns_
$self recv-pkts
global quiet
if { $quiet != "true" } {
$ns_ flush-trace
close $traceFile_
}
exit 0
}
TestSuite instproc openTrace { stopTime } {
$self instvar ns_ traceFile_ testname_
global quiet
if { $quiet != "true" } {
set traceFile_ [open $testname_.nam w]
$ns_ namtrace-all $traceFile_
}
$ns_ at $stopTime "$self finish"
}
TestSuite instproc attach-expoo-traffic { node sink size burst idle rate } {
$self instvar ns_
set udp [new Agent/UDP]
$ns_ attach-agent $node $udp
set traffic [new Application/Traffic/Exponential]
$traffic set packetSize_ $size
$traffic set burst_time_ $burst
$traffic set idle_time_ $idle
$traffic set rate_ $rate
$traffic attach-agent $udp
$ns_ connect $udp $sink
return $traffic
}
TestSuite instproc record {} {
$self instvar sink0_ totalpkt_ ns_
# Set the time after which the procedure should be called again
set time 0.005
# 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 "$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] "$self record"
set bw0 [expr $bw0 / 200]
set totalpkt_ [expr $totalpkt_ + $bw0]
}
TestSuite instproc recv-pkts {} {
$self instvar totalpkt_
flush stdout
puts "The Number of Total received packet is $totalpkt_"
}
TestSuite instproc run {} {
$self instvar ns_
$ns_ run
}
proc usage {} {
global argv0
puts stderr "usage: ns $argv0 <tests> \[<quiet>\]"
puts stderr "Valid tests are:\t[get-subclasses TestSuite Test/]"
exit 1
}
proc isProc? {cls prc} {
if [catch "Object info subclass $cls/$prc" r] {
global argv0
puts stderr "$argv0: no such $cls: $prc"
usage
}
}
proc get-subclasses {cls pfx} {
set ret ""
set l [string length $pfx]
set c $cls
while {[llength $c] > 0} {
set t [lindex $c 0]
set c [lrange $c 1 end]
if [string match ${pfx}* $t] {
lappend ret [string range $t $l end]
}
eval lappend c [$t info subclass]
}
set ret
}
TestSuite proc runTest {} {
global argc argv quiet
set quiet false
switch $argc {
1 {
set test $argv
isProc? Test $test
set topo ""
}
2 {
set test [lindex $argv 0]
isProc? Test $test
set extra [lindex $argv 1]
if {$extra == "QUIET"} {
set quiet true
}
}
default {
usage
}
}
set t [new Test/$test $test]
$t run
}
Class Test/simple -superclass TestSuite
Test/simple instproc recv-pkts {} {
# Nothing, since we do not do record{}.
}
Test/simple instproc init args {
eval $self next $args
$self instvar ns_
Classifier/Addr/MPLS set control_driven_ 1
# Turn on all traces to stdout
Agent/LDP set trace_ldp_ 1
Classifier/Addr/MPLS set trace_mpls_ 1
$self openTrace 5.0
set Node0 [$ns_ node]
set Node1 [$ns_ node]
$ns_ node-config -MPLS ON
set LSR2 [$ns_ node]
set LSR3 [$ns_ node]
set LSR4 [$ns_ node]
set LSR5 [$ns_ node]
set LSR6 [$ns_ node]
set LSR7 [$ns_ node]
set LSR8 [$ns_ node]
$ns_ node-config -MPLS OFF
set Node9 [$ns_ node]
set Node10 [$ns_ node]
$ns_ duplex-link $Node0 $LSR2 1Mb 10ms DropTail
$ns_ duplex-link $Node1 $LSR2 1Mb 10ms DropTail
$ns_ duplex-link $LSR2 $LSR3 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR4 $LSR8 1Mb 10ms DropTail
$ns_ duplex-link $LSR2 $LSR5 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR6 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR6 $LSR8 1Mb 10ms DropTail
$ns_ duplex-link $LSR7 $LSR8 1Mb 10ms DropTail
$ns_ duplex-link $LSR7 $Node9 1Mb 10ms DropTail
$ns_ duplex-link $LSR8 $Node10 1Mb 10ms DropTail
#
# configure ldp agents on all mpls nodes
#
for {set i 2} {$i < 9} {incr i} {
for {set j [expr $i+1]} {$j < 9} {incr j} {
set a LSR$i
set b LSR$j
eval $ns_ LDP-peer $$a $$b
}
}
#
# set ldp-message clolr
#
$ns_ ldp-request-color blue
$ns_ ldp-mapping-color red
$ns_ ldp-withdraw-color magenta
$ns_ ldp-release-color orange
$ns_ ldp-notification-color yellow
#
# make agent to send packets
#
set Src0 [new Application/Traffic/CBR]
set udp0 [new Agent/UDP]
$Src0 attach-agent $udp0
$ns_ attach-agent $Node0 $udp0
$Src0 set packetSize_ 500
$Src0 set interval_ 0.010
set Src1 [new Application/Traffic/CBR]
set udp1 [new Agent/UDP]
$Src1 attach-agent $udp1
$ns_ attach-agent $Node1 $udp1
$Src1 set packetSize_ 500
$Src1 set interval_ 0.010
set Dst0 [new Agent/Null]
$ns_ attach-agent $Node9 $Dst0
set Dst1 [new Agent/Null]
$ns_ attach-agent $Node10 $Dst1
$ns_ connect $udp0 $Dst0
$ns_ connect $udp1 $Dst1
$ns_ at 0.1 "$Src0 start"
$ns_ at 0.1 "$Src1 start"
for {set i 2} {$i < 9} {incr i} {
set a LSR$i
set m [eval $$a get-module "MPLS"]
eval set LSR$i $m
}
$ns_ at 0.2 "$LSR7 ldp-trigger-by-withdraw 9 -1"
$ns_ at 0.2 "$LSR8 ldp-trigger-by-withdraw 10 -1"
$ns_ at 0.3 "$LSR2 flow-aggregation 9 -1 6 -1"
$ns_ at 0.3 "$LSR2 flow-aggregation 10 -1 6 -1"
$ns_ at 0.5 "$LSR6 ldp-trigger-by-withdraw 6 -1"
$ns_ at 0.7 "$Src1 stop"
$ns_ at 0.7 "$LSR2 make-explicit-route 7 5_4_8_6_7 3000 -1"
$ns_ at 0.9 "$LSR2 flow-erlsp-install 9 -1 3000"
$ns_ at 1.1 "$LSR2 ldp-trigger-by-release 7 3000"
$ns_ at 1.2 "$LSR4 make-explicit-route 8 4_5_6_8 3500 -1"
$ns_ at 1.4 "$LSR2 make-explicit-route 7 2_3_4_3500_7 3600 -1"
$ns_ at 1.6 "$LSR2 flow-erlsp-install 9 -1 3600"
$ns_ at 2.0 "$Src0 stop"
$ns_ at 2.1 "$LSR2 pft-dump"
$ns_ at 2.1 "$LSR2 erb-dump"
$ns_ at 2.1 "$LSR2 lib-dump"
$ns_ at 2.1 "$LSR3 pft-dump"
$ns_ at 2.1 "$LSR3 erb-dump"
$ns_ at 2.1 "$LSR3 lib-dump"
$ns_ at 2.1 "$LSR4 pft-dump"
$ns_ at 2.1 "$LSR4 erb-dump"
$ns_ at 2.1 "$LSR4 lib-dump"
$ns_ at 2.1 "$LSR5 pft-dump"
$ns_ at 2.1 "$LSR5 erb-dump"
$ns_ at 2.1 "$LSR5 lib-dump"
$ns_ at 2.1 "$LSR6 pft-dump"
$ns_ at 2.1 "$LSR6 erb-dump"
$ns_ at 2.1 "$LSR6 lib-dump"
$ns_ at 2.1 "$LSR7 pft-dump"
$ns_ at 2.1 "$LSR7 erb-dump"
$ns_ at 2.1 "$LSR7 lib-dump"
$ns_ at 2.1 "$LSR8 pft-dump"
$ns_ at 2.1 "$LSR8 erb-dump"
$ns_ at 2.1 "$LSR8 lib-dump"
}
Class Test/control-driven -superclass TestSuite
Test/control-driven instproc init args {
Classifier/Addr/MPLS set control_driven_ 1
Agent/LDP set trace_ldp_ 1
Classifier/Addr/MPLS set trace_mpls_ 1
eval $self next $args
$self instvar ns_
$ns_ use-scheduler List
$self openTrace 0.7
$ns_ rtproto DV
set node0 [$ns_ node]
$ns_ node-config -MPLS ON
set LSR1 [$ns_ node]
set LSR2 [$ns_ node]
set LSR3 [$ns_ node]
set LSR4 [$ns_ node]
set LSR5 [$ns_ node]
set LSR6 [$ns_ node]
set LSR7 [$ns_ node]
$ns_ node-config -MPLS OFF
set node8 [$ns_ node]
$ns_ duplex-link $node0 $LSR1 1Mb 10ms DropTail
$ns_ duplex-link $LSR1 $LSR2 1Mb 10ms DropTail
$ns_ duplex-link $LSR1 $LSR3 1Mb 10ms DropTail
$ns_ duplex-link $LSR2 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR4 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR6 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR5 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR7 $node8 1Mb 10ms DropTail
$ns_ duplex-link-op $node0 $LSR1 orient right
$ns_ duplex-link-op $LSR1 $LSR2 orient down
$ns_ duplex-link-op $LSR1 $LSR3 orient right
$ns_ duplex-link-op $LSR2 $LSR4 orient right
$ns_ duplex-link-op $LSR4 $LSR6 orient right
$ns_ duplex-link-op $LSR6 $LSR7 orient right-up
$ns_ duplex-link-op $LSR3 $LSR5 orient right
$ns_ duplex-link-op $LSR3 $LSR4 orient down
$ns_ duplex-link-op $LSR5 $LSR7 orient right
$ns_ duplex-link-op $LSR5 $LSR6 orient down
$ns_ duplex-link-op $LSR7 $node8 orient right
#
# configure ldp agents on all mpls nodes
#
for {set i 1} {$i < 8} {incr i} {
set a LSR$i
for {set j [expr $i+1]} {$j < 8} {incr j} {
set b LSR$j
eval $ns_ LDP-peer $$a $$b
}
set m [eval $$a get-module "MPLS"]
$m enable-reroute "drop"
}
#
# set ldp-message clolr
#
$ns_ ldp-request-color blue
$ns_ ldp-mapping-color red
$ns_ ldp-withdraw-color magenta
$ns_ ldp-release-color orange
$ns_ ldp-notification-color yellow
#Create a traffic sink and attach it to the node node8
$self instvar sink0_
set sink0_ [new Agent/LossMonitor]
$ns_ attach-agent $node8 $sink0_
# Create a traffic source
set src0 [$self attach-expoo-traffic $node0 $sink0_ 200 0 0 400k]
$ns_ at 0.0 "$self record"
$ns_ at 0.1 "$src0 start"
$ns_ rtmodel-at 0.3 down $LSR3 $LSR5
$ns_ rtmodel-at 0.5 up $LSR3 $LSR5
$ns_ at 0.6 "$src0 stop"
}
Class Test/data-driven -superclass TestSuite
Test/data-driven instproc init args {
eval $self next $args
$self instvar ns_
Agent/LDP set trace_ldp_ 1
Classifier/Addr/MPLS set trace_mpls_ 1
$ns_ use-scheduler List
$self openTrace 0.7
$ns_ rtproto DV
set node0 [$ns_ node]
$ns_ node-config -MPLS ON
set LSR1 [$ns_ node]
set LSR2 [$ns_ node]
set LSR3 [$ns_ node]
set LSR4 [$ns_ node]
set LSR5 [$ns_ node]
set LSR6 [$ns_ node]
set LSR7 [$ns_ node]
$ns_ node-config -MPLS OFF
set node8 [$ns_ node]
$ns_ duplex-link $node0 $LSR1 1Mb 10ms DropTail
$ns_ duplex-link $LSR1 $LSR2 1Mb 10ms DropTail
$ns_ duplex-link $LSR2 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR4 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR6 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR1 $LSR3 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR5 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR7 $node8 1Mb 10ms DropTail
#
# configure ldp agents on all mpls nodes
#
for {set i 1} {$i < 8} {incr i} {
set a LSR$i
for {set j [expr $i+1]} {$j < 8} {incr j} {
set b LSR$j
eval $ns_ LDP-peer $$a $$b
}
set m [eval $$a get-module "MPLS"]
$m enable-reroute "new"
}
#
# set ldp-message clolr
#
$ns_ ldp-request-color blue
$ns_ ldp-mapping-color red
$ns_ ldp-withdraw-color magenta
$ns_ ldp-release-color orange
$ns_ ldp-notification-color yellow
#
# set ldp events
#
Classifier/Addr/MPLS enable-on-demand
Classifier/Addr/MPLS enable-ordered-control
[$LSR1 get-module "MPLS"] enable-data-driven
[$LSR3 get-module "MPLS"] enable-data-driven
# Create a traffic sink and attach it to the node node8
$self instvar sink0_
set sink0_ [new Agent/LossMonitor]
$ns_ attach-agent $node8 $sink0_
# Create a traffic source
set src0 [$self attach-expoo-traffic $node0 $sink0_ 200 0 0 400k]
$ns_ at 0.0 "$self record"
$ns_ at 0.1 "$src0 start"
$ns_ rtmodel-at 0.3 down $LSR3 $LSR5
$ns_ rtmodel-at 0.5 up $LSR3 $LSR5
$ns_ at 0.6 "$src0 stop"
}
Class Test/reroute -superclass TestSuite
Test/reroute instproc init args {
eval $self next $args
$self instvar ns_
Agent/LDP set trace_ldp_ 1
Classifier/Addr/MPLS set trace_mpls_ 1
$ns_ use-scheduler List
$self openTrace 0.7
$ns_ rtproto DV
set node0 [$ns_ node]
$ns_ node-config -MPLS ON
set LSR1 [$ns_ node]
set LSR2 [$ns_ node]
set LSR3 [$ns_ node]
set LSR4 [$ns_ node]
set LSR5 [$ns_ node]
set LSR6 [$ns_ node]
set LSR7 [$ns_ node]
$ns_ node-config -MPLS OFF
set node8 [$ns_ node]
$ns_ duplex-link $node0 $LSR1 1Mb 10ms DropTail
$ns_ duplex-link $LSR1 $LSR2 1Mb 10ms DropTail
$ns_ duplex-link $LSR2 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR4 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR6 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR1 $LSR3 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR5 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR7 1Mb 10ms DropTail
$ns_ duplex-link $LSR3 $LSR4 1Mb 10ms DropTail
$ns_ duplex-link $LSR5 $LSR6 1Mb 10ms DropTail
$ns_ duplex-link $LSR7 $node8 1Mb 10ms DropTail
#
# configure ldp agents on all mpls nodes
#
for {set i 1} {$i < 8} {incr i} {
set a LSR$i
for {set j [expr $i+1]} {$j < 8} {incr j} {
set b LSR$j
eval $ns_ LDP-peer $$a $$b
}
set m [eval $$a get-module "MPLS"]
$m enable-reroute "new"
}
#
# set ldp-message clolr
#
$ns_ ldp-request-color blue
$ns_ ldp-mapping-color red
$ns_ ldp-withdraw-color magenta
$ns_ ldp-release-color orange
$ns_ ldp-notification-color yellow
Classifier/Addr/MPLS enable-on-demand
Classifier/Addr/MPLS enable-ordered-control
[$LSR1 get-module "MPLS"] enable-data-driven
[$LSR3 get-module "MPLS"] enable-data-driven
# Create a traffic sink and attach it to the node node8
$self instvar sink0_
set sink0_ [new Agent/LossMonitor]
$ns_ attach-agent $node8 $sink0_
# Create a traffic source
set src0 [$self attach-expoo-traffic $node0 $sink0_ 200 0 0 400k]
$ns_ at 00 "$self record"
$ns_ at 0.1 "$src0 start"
$ns_ at 0.1 "[$LSR1 get-module MPLS] make-explicit-route 7 2_4_6_7 1000 -1"
$ns_ at 0.2 "[$LSR7 get-module MPLS] make-explicit-route 7 5_3_1_1000 1005 -1"
$ns_ at 0.3 "[$LSR1 get-module MPLS] reroute-binding 8 -1 1005"
$ns_ at 0.3 "[$LSR3 get-module MPLS] reroute-binding 8 -1 1005"
$ns_ at 0.3 "[$LSR5 get-module MPLS] reroute-binding 8 -1 1005"
$ns_ rtmodel-at 0.3 down $LSR3 $LSR5
$ns_ rtmodel-at 0.5 up $LSR3 $LSR5
$ns_ at 0.6 "$src0 stop"
}
TestSuite runTest
### Local Variables:
### mode: tcl
### tcl-indent-level: 8
### tcl-default-application: ns
### End:
|