0% found this document useful (0 votes)
8 views

Routingalgo TCL

Uploaded by

toklesreeja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Routingalgo TCL

Uploaded by

toklesreeja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Create a simulator object

set ns [new Simulator]

# Open the NAM trace file


set nf [open out.nam w]
$ns namtrace-all $nf

# Open the trace file


set tr [open out.tr w]
$ns trace-all $tr

# Define a finish procedure


proc finish {} {
global nf ns tr
$ns flush-trace
close $tr
exec nam out.nam &
exit 0
}

# Create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

# Create duplex links between nodes


$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n3 10Mb 10ms DropTail
$ns duplex-link $n2 $n1 10Mb 10ms DropTail

# Set link orientation


$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n1 orient right-up

# Create TCP agent and attach it to node n0


set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp

# Create FTP application and attach it to the TCP agent


set ftp [new Application/FTP]
$ftp attach-agent $tcp

# Create a TCP sink agent and attach it to node n3


set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink

# Create UDP agent and attach it to node n2


set udp [new Agent/UDP]
$ns attach-agent $n2 $udp

# Create CBR application and attach it to the UDP agent


set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp

# Create a Null agent and attach it to node n3


set null [new Agent/Null]
$ns attach-agent $n3 $null

# Connect TCP and UDP agents with their respective receiving agents
$ns connect $tcp $sink
$ns connect $udp $null

# Simulate link failure and recovery


$ns rtmodel-at 1.0 down $n1 $n3
$ns rtmodel-at 2.0 up $n1 $n3

# Set Distance Vector routing protocol


$ns rtproto DV

# Schedule events
$ns at 0.0 "$ftp start"
$ns at 0.0 "$cbr start"
$ns at 5.0 "finish"

# Run the simulation


$ns run

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy