[ns] transmission b/w nodes, packet no.,
packet size and calculating no. of hops.
swapna
mfnfn at yahoo.co.in
Mon Apr 18 04:28:53 PDT 2005
hi folks,
#Define variables
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 16
set val(rp) AODV
set val(X) 600
set val(Y) 600
#Create simulator
set ns [new Simulator]
#Create trace-files
set f [open output.tr w]
$ns trace-all $f
#Create nam-trace-files
set nf [open output.nam w]
$ns namtrace-all-wireless $nf $val(X) $val(Y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(X) $val(Y)
# Create God
create-god $val(nn)
#Node Configurations
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON \
-movementTrace OFF
#Creating nodes
for {set i 0} {$i < $val(nn) } {incr i} {
set node($i) [$ns node]
$node($i) random-motion 0
}
#Specifying node initial positions
$node(0) set X_ 30.0
$node(0) set Y_ 150.0
$node(0) set Z_ 0.0
$node(1) set X_ 20.0
$node(1) set Y_ 100.0
$node(1) set Z_ 0.0
$node(2) set X_ 80.0
$node(2) set Y_ 180.0
$node(2) set Z_ 0.0
$node(3) set X_ 40.0
$node(3) set Y_ 120.0
$node(3) set Z_ 0.0
$node(4) set X_ 40.0
$node(4) set Y_ 120.0
$node(4) set Z_ 0.0
$node(5) set X_ 40.0
$node(5) set Y_ 120.0
$node(5) set Z_ 0.0
$node(6) set X_ 50.0
$node(6) set Y_ 120.0
$node(6) set Z_ 0.0
$node(7) set X_ 40.0
$node(7) set Y_ 120.0
$node(7) set Z_ 0.0
$node(8) set X_ 40.0
$node(8) set Y_ 120.0
$node(8) set Z_ 0.0
$node(9) set X_ 40.0
$node(9) set Y_ 120.0
$node(9) set Z_ 0.0
$node(10) set X_ 40.0
$node(10) set Y_ 120.0
$node(10) set Z_ 0.0
$node(11) set X_ 40.0
$node(11) set Y_ 120.0
$node(11) set Z_ 0.0
$node(12) set X_ 40.0
$node(12) set Y_ 120.0
$node(12) set Z_ 0.0
$node(13) set X_ 40.0
$node(13) set Y_ 120.0
$node(13) set Z_ 0.0
$node(14) set X_ 40.0
$node(14) set Y_ 120.0
$node(14) set Z_ 0.0
$node(15) set X_ 40.0
$node(15) set Y_ 120.0
$node(15) set Z_ 0.0
#Specifying node movements
$ns at 0.3 "$node(0) setdest 10.0 10.0 1500.0"
$ns at 0.3 "$node(1) setdest 10.0 100.0 1500.0"
$ns at 0.3 "$node(2) setdest 100.0 10.0 1500.0"
$ns at 0.3 "$node(3) setdest 200.0 200.0 1500.0"
$ns at 0.3 "$node(4) setdest 400.0 200.0 1500.0"
$ns at 0.3 "$node(5) setdest 490.0 10.0 1500.0"
$ns at 0.3 "$node(6) setdest 590.0 10.0 1500.0"
$ns at 0.3 "$node(7) setdest 590.0 100.0 1500.0"
$ns at 0.3 "$node(8) setdest 400.0 400.0 1500.0"
$ns at 0.3 "$node(9) setdest 590.0 490.0 2000.0"
$ns at 0.3 "$node(10) setdest 590.0 590.0 2000.0"
$ns at 0.3 "$node(11) setdest 490.0 590.0 2000.0"
$ns at 0.3 "$node(12) setdest 200.0 400.0 1500.0"
$ns at 0.3 "$node(13) setdest 110.0 590.0 1500.0"
$ns at 0.3 "$node(14) setdest 10.0 590.0 1500.0"
$ns at 0.3 "$node(15) setdest 10.0 490.0 1500.0"
#Defining connections
# TCP CONNECTIONS
set tcp0_10 [new Agent/TCP]
set tcp1_15 [new Agent/TCP]
set tcp3_7 [new Agent/TCP]
set tcp6_14 [new Agent/TCP]
set tcp7_9 [new Agent/TCP]
set tcp9_13 [new Agent/TCP]
set tcp11_3 [new Agent/TCP]
set tcp13_5 [new Agent/TCP]
# TCP SINKS
set sink3 [new Agent/TCPSink]
set sink5 [new Agent/TCPSink]
set sink7 [new Agent/TCPSink]
set sink9 [new Agent/TCPSink]
set sink10 [new Agent/TCPSink]
set sink13 [new Agent/TCPSink]
set sink14 [new Agent/TCPSink]
set sink15 [new Agent/TCPSink]
# FTP GENERATORS
set ftp0_10 [new Application/FTP]
set ftp1_15 [new Application/FTP]
set ftp3_7 [new Application/FTP]
set ftp6_14 [new Application/FTP]
set ftp7_9 [new Application/FTP]
set ftp9_13 [new Application/FTP]
set ftp11_3 [new Application/FTP]
set ftp13_5 [new Application/FTP]
#Connecting agents to nodes
$ns attach-agent $node(0) $tcp0_10
$ns attach-agent $node(1) $tcp1_15
$ns attach-agent $node(3) $tcp3_7
$ns attach-agent $node(6) $tcp6_14
$ns attach-agent $node(7) $tcp7_9
$ns attach-agent $node(9) $tcp9_13
$ns attach-agent $node(11) $tcp11_3
$ns attach-agent $node(13) $tcp13_5
$ns attach-agent $node(3) $sink3
$ns attach-agent $node(5) $sink5
$ns attach-agent $node(7) $sink7
$ns attach-agent $node(9) $sink9
$ns attach-agent $node(10) $sink10
$ns attach-agent $node(13) $sink13
$ns attach-agent $node(14) $sink14
$ns attach-agent $node(15) $sink15
#Connecting TCP and Sink
$ns connect $tcp0_10 $sink10
$ns connect $tcp1_15 $sink15
$ns connect $tcp3_7 $sink7
$ns connect $tcp6_14 $sink14
$ns connect $tcp7_9 $sink9
$ns connect $tcp9_13 $sink13
$ns connect $tcp11_3 $sink3
$ns connect $tcp13_5 $sink5
#Connecting FTP
$ftp0_10 attach-agent $tcp0_10
$ftp1_15 attach-agent $tcp1_15
$ftp3_7 attach-agent $tcp3_7
$ftp6_14 attach-agent $tcp6_14
$ftp7_9 attach-agent $tcp7_9
$ftp9_13 attach-agent $tcp9_13
$ftp11_3 attach-agent $tcp11_3
$ftp13_5 attach-agent $tcp13_5
#Starting FTP
$ns at 0.8 "$ftp0_10 start"
$ns at 1.0 "$ftp1_15 start"
$ns at 1.1 "$ftp6_14 start"
$ns at 1.2 "$ftp7_9 start"
$ns at 1.3 "$ftp9_13 start"
$ns at 1.4 "$ftp3_7 start"
$ns at 1.5 "$ftp11_3 start"
$ns at 1.6 "$ftp13_5 start"
#Reset nodes
for {set i 0} {$i < $val(nn) } {incr i} {
$ns at 3.0 "$node($i) reset";
}
#Finishing tracing, starting NAM
$ns at 3.0 "finish"
proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf
# exec ../nam-1.9/nam output4.nam &
exit 0
}
#Start simulation
$ns run
this is my tcl program for 16 nodes,here i randomly
connected nodes for their communication.
here my problem is i want to allow the communication b/w
any pair of nodes/2 pair of nodes,what ever may be the nodes according to my wish, how can i.
and also i want to limit the packets no.,packet size
b/w the perticular nodes.
suppose there is a communication b/w node1 and 15 in other
words packet is sending by node1 to node 15,to reach the packet
from 1 to 15 how many inermediate path it will take or how many hops it will
take to reach from source to destination.
regarding all above things how can i find the solution plz help me as soon as possible.
regards.
Yahoo! India Matrimony: Find your life partneronline.
More information about the Ns-users
mailing list