[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] your help needed



Dear Sir;

As I am doing my final year project I was asked to do a model of one of our existing networking site of our University, can you pls help me showing me how to get started, to do develop the Network simulation / Network animation tools by providing the code (C language) so i can amend it in a way suitable to the model ...

So far I have prepared the following (attached) code can you please amed it in a way that I can run it in my Solaris (UNIX) of my UNi to demonstrate it to my supervisor...

The network is composed of the following:

- 7 mini hubs

-7 switches

- 100 terminals

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#Declaration of new simulation
set ns [new Simulator]

#Declaration that contain the result
set ftrace [open ftp1.tr w]
set nf [open tp1.nam w]
$ns namtrace-all $nf

#Procedure launched at the end of the simulation
proc finish {} {
 global ns ftrace nf
 $ns flush-trace
 close $nf
 close $ftrace
 exit 0
}

#Procedure that recover the size of window's congestion that transmit the time function
proc traceWindow {} {
global tcp0 ftrace
set ns [Simulator instance]
set time 0.01
set now [$ns now]
puts $ftrace "$now [$tcp0 set cwnd_]"
$ns at [expr $now+$time] "traceWindow"
}

 

#Declaration of characteristiques of TCP agent
Agent/TCP set packetSize_  1500
Agent/TCP set maxcwnd_  30
Agent/TCPSink/DelAck  set interval_ 0.00001


#Declaration of the nodes
set n0 [$ns node]

#### we need to declare the other nodes in here


#Declaration of TCP agents and ftp application of n0 (source)
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set ftp [new Source/FTP]
$ftp set agent_ $tcp0
  
#Declaration of TCP agent of n4 (sources)
set tcp1 [new Agent/TCPSink/DelAck]
$ns attach-agent $n4 $tcp1


#Declaration of links between nodes
$ns duplex-link $n0 $n2 10Mb 10ms DropTail

####We need to declare the other links in here as before


#The Attachement of TCP agents of the nodes n0 and n4
$ns connect $tcp0 $tcp1


#Time of events
$ns at 0.8 "finish"
$ns at 0.0 "$ftp start"
$ns at 0.0 "traceWindow"
###The applicable FTP layer from the attached source n0
set ftp [new Application/FTP]
$ftp set agent_ $tcp0

### we can run it by typing ns tp1.tcl
### the file tp1.nam will be generated by ns; to open it with NAM type
### nam tp1.nam
### to see the graph congestion open "ftp1.tr" with "gnuplot"
#Finally, start the simulation
$ns run

//////////////////////////////////////////////////////////////////////////////////////////////////////

### Dynamic Routage
set ns [new Simulator]
set nf [open tp2.nam w]
$ns namtrace-all $nf proc finish {} { global ns ftrace nf 
$ns flush-trace close
$nf exit 0 }
#Colors Definition
$ns color 2 black
$ns color 1 blue
$ns color 0 purple
$ns color 30 yellow
$ns color 31 red
#The TCP traffic is in red
$tcp set class_ 31
#### Dynamique Routage Mode
$ns rtproto DV
#----------------- For You ! ---------------------
#### We Can Define the nodes & the links in here
#### We define the TCP Agents & The FTP Application in here
#### We need to connect the TCP Agents in here
#------------------------------------------------
#### Link between n0 & n1  would fail between 1.0 et 1.2 seconds
$ns rtmodel-at 1.0 down
$n1
$n2
$ns rtmodel-at 1.2 up
$n1
$n2
$ns at 0.1 "$ftp start"
$ns at 1.6 "finish"
$ns run

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Many Thanks

Nicolas krim

[email protected]



Join the world�s largest e-mail service with MSN Hotmail. Click Here