Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
Re #21.
Do you mean "the nodes can't show in network animation" ? Or in the simple.tr ?
Step one is to define the nodes for NAM
Code:
# -----------------------------------
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 4 defines the node size for nam
$ns_ initial_node_pos $node_($i) 4
}
# --------------------------------
Now the nodes show up in NAM, and the simple.tr will show packets sent / received.
#==============================================================================
# SIMULATION PARAMETER SET UP
#==============================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/Shadowing ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/DirAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 4 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(ni) 1
#set val(sc) "./"
#This type of modulation is a new addition
set opt(mod) Modulation/BPSK
# ==========================
# Main Program
# ==========================
# Initialize Global Variables
# Create a Trace Object
set ns_ [new Simulator]
set f [open fanet-out.tr w]
$ns_ trace-all $f
$ns_ eventtrace-all
# Create a NAM trace file
set nf [open fanet-out.nam w]
$ns_ namtrace-all-wireless $nf 100 100
# Set up topography object
set topo [new Topography]
$topo load_flatgrid 100 100
##############################################################
#################### Configure Node ##########################
##############################################################
$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) \
-channel [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-numif $val(ni) \
create-god 4 ;
#############################################################
proc create_node { x y z } {
global ns_
#Mac/802_11 MAC_RTSThreshold 2000
#Mac/802_11 MAC_FragmentationThreshold 2500
#Mac/802_11 DSSS_AirPropagationTime 0.000003
Mac/802_11 set dataRate_ 2mb
Mac/802_11 set basicRate_ 1mb
Phy/WirelessPhy set modulationscheme_ 1
set newnode [$ns_ node]
$newnode random-motion 0
$newnode set X_ $x
$newnode set Y_ $y
$newnode set Z_ $z
return $newnode
}
proc create_cbr_connection { from to startTime interval packetSize } {
global ns_
###################################################################
################# Set up UDP conection ############################
###################################################################
set udp0 [new Agent/UDP]
set src [new Application/Traffic/CBR]
$udp0 set packetSize_ $packetSize
$src set packetSize_ $packetSize
$src set interval_ $interval
set sink [new Agent/Null]
$ns_ attach-agent $from $udp0
$src attach-agent $udp0
$ns_ attach-agent $to $sink
$ns_ connect $udp0 $sink
$ns_ at $startTime "$src start"
return $udp0
}
proc create_tcp_connection { from to startTime } {
global ns_ par
set tcp [new Agent/TCP]
$tcp set packetSize_ 1500
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $from $tcp
$ns_ attach-agent $to $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp set packetSize_ 1500
$ftp attach-agent $tcp
$ns_ at $startTime "$ftp start"
$tcp attach $par
$tcp trace cwnd_
$tcp trace maxseq_
$tcp trace rtt_
$tcp trace dupacks_
$tcp trace ack_
$tcp trace ndatabytes_
$tcp trace ndatapack_
$tcp trace nrexmit_
$tcp trace nrexmitpack_
return $tcp
}
#######################################################
####################### Node 1 ########################
#######################################################
$ns_ node-config -numif 1
set node_(0) [create_node 10 10 0]
[$node_(0) set netif_(0)] set channel_number_ 1
[$node_(0) set netif_(0)] set Pt_ 0.1
set a [new Antenna/DirAntenna]
$a setType 1
$a setAngle 90
#$a setWidth 10
[$node_(0) set netif_(0)] dir-antenna $a
$ns_ node-config -numif 2
set node_(1) [create_node 10 60 0]
[$node_(1) set netif_(0)] set Pt_ 0.1
[$node_(1) set netif_(0)] set channel_number_ 1
[$node_(1) set netif_(1)] set Pt_ 0.1
[$node_(1) set netif_(1)] set channel_number_ 4 #baru ganti
#This is the way a new directional antenna is created
set a [new Antenna/DirAntenna]
#The type can be set to zero if you want to use directional antennae in the following form :
#A packet is received if the path between the sender and receiver fall in the
#cone(parallelogram) formed by the directional antennae of the sender and receiver
$a setType 1
#This sets the start angle of the directional antenna
$a setAngle 265
#This attaches the node to the directional antenna to the interface 0 of node1
[$node_(1) set netif_(0)] dir-antenna $a
set a [new Antenna/DirAntenna]
$a setType 1
$a setAngle 0
$a setWidth 10
#This attaches the node to the directional antenna to the interface 1 of node1
[$node_(1) set netif_(1)] dir-antenna $a
$ns_ node-config -numif 2
set node_(2) [create_node 60 60 0]
[$node_(2) set netif_(0)] set Pt_ 0.1
[$node_(2) set netif_(0)] set channel_number_ 6
[$node_(2) set netif_(1)] set Pt_ 0.1
[$node_(2) set netif_(1)] set channel_number_ 11
set a [new Antenna/DirAntenna]
$a setType 1
$a setAngle 180
$a setWidth 10
[$node_(2) set netif_(0)] dir-antenna $a
set a [new Antenna/DirAntenna]
$a setType 1
$a setAngle 90
#$a setWidth 10
[$node_(2) set netif_(1)] dir-antenna $a
$ns_ node-config -numif 1
set node_(3) [create_node 60 10 0]
[$node_(3) set netif_(0)] set Pt_ 0.1
[$node_(3) set netif_(0)] set channel_number_ 11
set a [new Antenna/DirAntenna]
$a setType 1
$a setAngle 270
#$a setWidth 10
[$node_(3) set netif_(0)] dir-antenna $a
#These following set of commands manually makes a routing table for "wlstatic"
#the syntax is as follows:
#[$node_(0) set ragent_] addstaticroute <number of hops> <next hop> <destination node> <interface to use>
#[$node_(0) set ragent_] addstaticroute 1 1 1 0
#[$node_(0) set ragent_] addstaticroute 2 1 2 0
#[$node_(0) set ragent_] addstaticroute 3 1 3 0
#[$node_(1) set ragent_] addstaticroute 1 0 0 0
#[$node_(1) set ragent_] addstaticroute 1 2 2 1
#[$node_(1) set ragent_] addstaticroute 2 2 3 1
#[$node_(2) set ragent_] addstaticroute 2 1 0 0
#[$node_(2) set ragent_] addstaticroute 1 1 1 0
#[$node_(2) set ragent_] addstaticroute 1 3 3 1
#[$node_(3) set ragent_] addstaticroute 3 2 0 0
#[$node_(3) set ragent_] addstaticroute 2 2 1 0
#[$node_(3) set ragent_] addstaticroute 1 2 2 0
set tcp0 [create_cbr_connection $node_(0) $node_(3) 1.0 0.005 1500]
# -----------------------------------
for {set i 0} {$i < $val(nn)} { incr i } {
$ns_ initial_node_pos $node_($i) 4
}
# -----------------------------------
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 110.0 "$node_($i) reset";
}
$ns_ at 110.01 "puts \"NS Exiting...\"; $ns_ halt" ;
######################################################
############# Prosedur Finish ########################
######################################################
proc finish {} {
global ns_ f nf val
$ns_ flush-trace
close $f
close $nf
exec nam fanet-out.nam &
puts "Starting Simulation..."
}
$ns_ run
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
Re #25.
Code:
$ ns235-dir-antenna-64 akbar_san-D.tcl
num_nodes is set 4
INITIALIZE THE LIST xListHead
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
SORTING LISTS ...DONE!
MAC_802_11: accessing MAC cache_ array out of range (src 5, dst 0, size 4)!
NS Exiting...
... the stop time is about one second.
The files fanet-out.nam 24.1MB, fanet-out.tr 13.8MB are created.
$ nam fanet-out
`Step´ set to 50mS : The animation looks OK.
Time : Please specify which time / timing you are asking about.
Time :
Code:
$ ls -l
-rw-rw-r-- 1 knudfl knudfl 14442243 Nov 21 13:53 fanet-out.tr
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
Re #29.
Quote:
[$node_(1) set netif_(0)] set Pt_ 0.1
I guess it's explained in the simulation examples:
Dir-antenna-test.tcl, nna-test-1.tcl, old-long.tcl, TeNS.tcl
→
# This is the method of setting the channel at which a particular network interface of a node
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.