LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 11-09-2018, 10:23 AM   #16
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641

Please click the 'Edit' button in post #11.

And edit the code text to use code tags, like post #13.

I.e. type "[/code]" at code end .... and "[code]" at code start.
 
Old 11-09-2018, 06:19 PM   #17
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Rep #16


Done sir
 
Old 11-10-2018, 01:48 AM   #18
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #11.

A couple of edits to nna-test.tcl : New file name = nna-test-1.tcl (Attached.)

See lines 102, 448, 450.
-
Attached Files
File Type: txt nna-test-1.tcl.txt (8.2 KB, 30 views)
 
Old 11-12-2018, 03:19 AM   #19
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Rep #18

i try your file

and the result is :

num_nodes is set 4
INITIALIZE THE LIST xListHead
Env variable NS_ANTENNA_FILE has to be set, see documentation (?)
 
Old 11-12-2018, 05:15 AM   #20
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #19.

The simulation command is ...
Code:
export NS_ANTENNA_FILE=./antenna1.txt && ns nna-test-1.tcl
... where `antenna1.txt´ is a file in the same directory as nna-test-1.tcl .
 
Old 11-12-2018, 07:51 AM   #21
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Re #19

finally i can run this file and got the file .nam and file .tr but,the nodes can't show in network simulation.

could you help me please how to create the nodes sir?

BTW im using 4 nodes for this simulation


thanks before
 
Old 11-12-2018, 10:23 AM   #22
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.
Code:
[AWK-first.10.18]$ awk -f PDR.awk simple.tr 
cbr s:21803 r:0, r/s Ratio:0.0000, f:0
Note : Not easy to find a script, awk or perl, to match the trace file (simple.tr).
... May be some cbr or/and udp traffic would do for this issue ?
3000 ex https://drive.google.com/drive/folde...Ws?usp=sharing

awk-and-perl/a/ https://drive.google.com/drive/folde...7T?usp=sharing
-
Attached Files
File Type: txt NAM_nna-test-1.tcl.txt (8.4 KB, 28 views)

Last edited by knudfl; 11-12-2018 at 10:38 AM.
 
Old 11-12-2018, 10:31 AM   #23
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Re #22

Thx i'll try but where I should put the codes define nodes for NAM?
 
Old 11-15-2018, 04:01 PM   #24
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Directional-Antenna : Two new examples ... with traffic / communication.

Code:
$ ns235-dir-antenna-64 Dir__aodv10ms.tcl 
num_nodes is set 4
num_nodes is set 4
INITIALIZE THE LIST xListHead
Starting Simulation…
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
SORTING LISTS ...DONE! 

$ perl Statistics__perl_script.pl Di-1.tr 
sent packets= 1428
received packets= 1427
packets dropped=1
routing agents=1429/nrouting overhead= 100.070028
Packet delivery ratio 0.999300
Average path length 2.001402

$ awk -f PDR.awk Di-1.tr
cbr s:1428 r:1427, r/s Ratio:0.9993, f:1429

$ perl End-to-End-Delay##.pl Di-1.tr
... OK, 1431 lines output.
_________________________________________________


$ ns235-dir-antenna-64 diAnt__aodv-Soumia.tcl
num_nodes is set 10
. . .

$ perl Statistics__perl_script.pl di-Soumia-simple.tr 
sent packets= 14660
received packets= 14660
packets dropped=0
routing agents=23/nrouting overhead= 0.156889
Packet delivery ratio 1.000000
Average path length 1.001569

$ awk -f PDR.awk di-Soumia-simple.tr 
cbr s:14660 r:14660, r/s Ratio:1.0000, f:23

$ perl End-to-End-Delay##.pl di-Soumia-simple.tr
... 14,664 lines output !

-
... The examples were modified from current aodv ex, "ex-AODV_01.18/" :
https://drive.google.com/file/d/1uOv...ew?usp=sharing

Package with the new examples included : Directional-Antenna_ex-2.tar.gz
https://drive.google.com/file/d/15rx...ew?usp=sharing

-

Last edited by knudfl; 11-15-2018 at 04:15 PM.
 
Old 11-21-2018, 01:52 AM   #25
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
how to add time for this code ?

Code:
#==============================================================================
#                   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
 
Old 11-21-2018, 07:01 AM   #26
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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
-

Last edited by knudfl; 11-21-2018 at 07:05 AM.
 
Old 11-21-2018, 07:23 AM   #27
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Rep #26

Time for calculate in ns2
For example set the time to 200s untill finish
 
Old 11-21-2018, 08:29 AM   #28
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Stop time is maximum time.

Setting the time to 200sec doesn't extend the simulation time, if the setup lasts e.g. 2 ... 20 seconds.

Solution : Find a 200sec simulation, and edit to Directional Antenna
https://drive.google.com/drive/folde...Ws?usp=sharing

-
 
Old 11-21-2018, 10:20 AM   #29
akbar_san
LQ Newbie
 
Registered: Oct 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Rep#28

I will try sir thanks..

Could you explain this code?

Code:
[$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
 
Old 11-21-2018, 12:53 PM   #30
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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
 
  


Reply

Tags
directional-antenna, ns2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Directional Antenna patch for ns2.35 amal79 Linux - Software 19 05-08-2020 04:19 AM
how to change omni antenna to directional antenna in NS2 programming 13thsparton Linux - Software 1 10-08-2015 03:36 AM
OLSR with directional antenna in NS2 ws19561986 Linux - Newbie 0 04-17-2014 09:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration