Operating System - Linux
1828003 Members
2529 Online
109973 Solutions
New Discussion

Hi, question about the codes for Exeaed/linux

 
marek linkiewicz
New Member

Hi, question about the codes for Exeaed/linux

Hi, i am traying to setup a network topology with 6 nodes and 5 links as shown below, but i am not sure is my code is correct to the parameters below, can anyone chack this Thanks for any help
mlinkiewicz@yahoo.co.uk
(the code is below the graph)

TCP1src TCP1dest
(0)------------------(1)--------------------(2)------------------(3)
10Mbps 2ms 1.5Mbps 10ms 10Mbps 2ms

(4) (5)
TCP2src TCP2dest
(4)is connect to (1), and (5) is connect to (2)


Link parameters between nodes 0-1, 4-1, 2-3, and 2-5 are identical (10Mbps capacity, 2ms delay).


# USING FTP OVER FULLTCP:
set ns [new Simulator]
set nf [open outpt2.nam w]
$ns namtrace-all $nf

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

# FINISH PROCEDURE:
proc finish {} {
global ns nf tcp0 tcp1 totalBytes0 totalBytes1 time
$ns flush-trace
close $nf

# TOTALBYTES SENT OVER TCP CONNECTION:
set totalBytes0 [$tcp0 set ndatabytes_]
set totalBytes1 [$tcp1 set ndatabytes_]

# CURRECT TIME(10s):
set time [$ns now]

# PRINTING THROUGHPUT INFORMATION FOR TCP CONNECTIONS:
puts "\n\nTotal throughput of TCP0: (transmission time of [expr $time - 0.4033571])\nis: [expr $totalBytes0 / [expr $time - 0.4033571]] bytes per second"
puts "\nTotal throughput of TCP1: (transmission time of [expr $time - 0.5533571])\nis: [expr $totalBytes1 / [expr $time - 0.5533571]] bytes per second"
puts "\n\nTotal throughput for both TCP: [expr [expr $totalBytes0 + $totalBytes1] / 10] bytes per second\n"
exec nam outpt2.nam &
exit 0
}

# CREATE NODES(6):
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

# CREATE DUPLEX LINK BETWEEN NODES:
$ns duplex-link $n2 $n0 5Mb 10ms DropTail
$ns duplex-link-op $n2 $n0 orient left
$ns duplex-link $n2 $n1 5Mb 10ms DropTail
$ns duplex-link-op $n2 $n1 orient left-down
$ns duplex-link $n2 $n3 1.5Mb 10ms DropTail
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link $n3 $n4 5Mb 10ms DropTail
$ns duplex-link-op $n3 $n4 orient right
$ns duplex-link $n3 $n5 5Mb 10ms DropTail
$ns duplex-link-op $n3 $n5 orient right-down

# TCP CONNECTION 1 FOR NODE n0:
set tcp0 [new Agent/TCP/FullTcp]
$ns attach-agent $n0 $tcp0
$tcp0 set fid_ 1
$tcp0 set window_ 200

# ATTACH SINK AT NODE n4:
set sink0 [new Agent/TCP/FullTcp]
$ns attach-agent $n4 $sink0
$ns connect $tcp0 $sink0
$sink0 set fid_ 1
$sink0 listen

# CREATE FTP TRAFFIC AND ATTACHING IT TO tcp0:
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0

# TCP CONNECTION 2 FOR NODE n1:
set tcp1 [new Agent/TCP/FullTcp]
$ns attach-agent $n1 $tcp1
$tcp1 set fid_ 1
$tcp1 set window_ 200

# ATTACH SINK AT NODE n5:
set sink1 [new Agent/TCP/FullTcp]
$ns attach-agent $n5 $sink1
$ns connect $tcp1 $sink1
$sink1 set fid_ 1
$sink1 listen

# CREATE FTP TRAFFIC AND ATTACHING IT TO tcp1:
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1

# START THE TRAFFIC FLOW:
$tcp0 set class_ 1
$tcp1 set class_ 2
$ns color 1 Blue
$ns color 2 Red

# MONITOR QUEUE BETWEEN NODES n2 AND n3:
$ns queue-limit $n2 $n3 05
$ns duplex-link-op $n2 $n3 queuePos 0.5

# START AND END THE SIMULATION:
$ns at (06039062)"$ftp0 start"
$ns at (06039062)"$ftp1 start"
$ns at 10.0 "$ftp0 stop"
$ns at 10.0 "$ftp1 stop"
$ns at 10.0 "finish"


# RUN SIMULATION:
$ns run