network simulation using ns2 software

92 views Asked by At

When executing the following code: I faced this error:

ns2 AOMDV simulation error

Network is not my field. thus I need your help seriously.

num_nodes is set 0
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
MAC_802_11: accessing MAC cache_ array out of range (src 29, dst 36, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 36, dst 29, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 43, dst 36, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 36, dst 43, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 34, dst 29, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 29, dst 34, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 34, dst 29, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 29, dst 36, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 79, dst 36, size 0)!
MAC_802_11: accessing MAC cache_ array out of range (src 40, dst 36, size 0)!
[suppressing additional MAC cache_ warnings]
NS EXITING...

 # define options 
 set val(chan) Channel/WirelessChannel                                      ;# channel type
 set val(prop) Propagation/TwoRayGround           ;# radio propagation             model 
 set val(netif) Phy/WirelessPhy          ;# !!!EDITED !!!  ;# 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/OmniAntenna                                ;# antenna model 
 set val(ifqlen) 50                                                   ;# max packet in ifq
 set val(nn)    50                                              ;# number of mobile nodes 

set val(rp)     AOMDV           ;# MDAOMDV   ;# Routing protocol 
set val(x) 800                                                    ;# X dimension of topography 
set val(y) 800                                                    ;# Y dimension of topography
set val(stop) 500                                                   ;# time of simulation end  
set val(energymodel) EnergyModel                                               ; 
set val(n_ch) chan_1
set val(initialenergy)  90   ;# edited/added ##########  ;# Initial energy in Joules
#----------------------------------------- 
# ---------------------------------------- 
#remove-all-packet-headers 
#add- packet header IP LL Mac AODV AOMDV ATR DSDV DSR OLSR UDP TCP CBR FTP   ;# needed headers 
Mac /802_11 set CWMin_31 
Mac /802_11 set CWMax_1023 
Mac /802_set Slot Time _0.000020                                                  ;# 20us 
Mac /802_11 set SIFS_0.000010                                                        ;# 10us 
Mac /802_11 set preamble Length_144                                                 ;# 144 bit 
Mac /802_11 set short preamble Length _                                          ;# 72 bit 
Mac /802_ set preamble data rate_1.0e6                                              ;# 1Mbps
Mac /802_11 set PLCP  Header Length_ 48                                              ;# 48 bits 
Mac /802_11 set PLCP Data Rate_1.0e6                                               ;# 1Mbps 
Mac /802_11 set Short PLCP Data Rate_2.0e6                                             ;# 2Mbps 
Mac /802_11 set RTS Threshold_3000                                                 ;# bytes 
Mac /802_11 set Short Retry Limit_7                                          ;# retransmissions 
Mac /802_11 set Long Retry Limit _4                                      ;# retransmissions 
Mac /802_11 set new chipset_ false                  ;# use new chipset , allowing a more recent packet to be correctly received in place of the first sensed packet

Mac /802_11 set Data Rate _2Mb                                ;# 802.11 data transmission rate 
Mac/802_11 set basic Rate_1Mb                                ;# 802.11 basic transmission 
Mac /802_11 set aarf_ false

 
# creating simulation: 
set ns [new Simulator]
# use colors to differentiate the traffics 
$ns color 1 green 
# creating nam and trace file: 
set tracefd [open mdaomdv.tr w]     ;# edited 
set namtrace [open mdaomdv.nam w] 
$ns trace-all $tracefd       ;# edited
$ns namtrace-all-wireless $namtrace $val(x) $val(y)     ;# edited

 
#set up topography object           
set topo    [new Topography]    ;# edited       
$topo load_flatgrid $val(x) $val(y) ;# edited

set god_    [create-god val(nn)]
 
#configure the nodes        #### section is edited #################
## all lines in this section are edited, +added: -initialEnergy $val(initialenergy) #####
$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 ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON \
-n_chType  $val(n_ch) \
-energyModel $val(energymodel) \
#-rx power 0.3 \
#-tx power 0.6 \
-initialEnergy $val(initialenergy)


## creating node object  ### edited section ################
for {set i 0} {$i < $val(nn) } {incr i} {
        set node_($i) [$ns node]    
#       $node_($i) random-motion 0
        }

for {set i 0} {$i < 20} {incr i} {      ;# edited
$node_($i) color blue
$ns at 0.0 "$node_($i) color blue"
} 
for {set i 20} {$i < 30} {incr i} { 
set node_($) [$ns node]             
} 
for {set i 20} {$i < 30} {incr i} { 
$node_($i) color cyan
$ns at 1.0 "$node_($i) color cyan"
} 
for {set i 30} {$i < 50} {incr i} { 
set node_($i) [$ns node] 
}
for {set i 20} {$i < 50} {incr i} {
$node_($i) color red
$ns at 2.0 "$node_($i) color red"
}

source cbr-50-20-4-512ns
 
# provide initial location of mobile nodes 
for {set i 0} {$i < $val(nn) } { incr i } { 
set xx [expr rand()*800] 
set yy [expr rand()* 800] 
$node_($i) set X_ $xx 
$node_($i) set Y_ $yy 
}
 
# Define node initial position in nam    ;# this section is edited #####
for {set i 0} {$i < $val(nn)} {incr i} { 
# defines the node size for nam  
$ns initial_node_pos $node_($i) 30  
}

proc stop {} { 
global ns tracefd nam trace 
$ns flush-trace 
close $tracefd 
close $nam trace
}

# Tell all the nodes when the simulation ends ###############
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns at $val(stop).000000001 "$node_($i) reset";
}
$ns at $val(stop).00000001 "puts \"NS EXITING...\" ; $ns halt"

$ns run

exec nam mdaomdv.nam &

I tried to analyze the output .tr .nam and unable to analyze it. I expect graphical output by image.

1

There are 1 answers

3
Knud Larsen On

MAC_802_11: accessing MAC cache_ array out of range

Line 58 set god_ [create-god val(nn)]
... Edit to

set god_    [create-god [expr $val(nn) + 50]]  

Ref. the "Tim Crone answer" here Wireless simulation issue

Ref. a Google search = accessing MAC cache_ array out of range

Edited file, 111_aomdv-2.tcl https://drive.google.com/drive/folders/14vdJfoIqqKj34clkdxuN0IclHc0o0Oml?usp=share_link


Graphical, xgraph : "ns2 ... VIII. Creating Output Files for Xgraph" http://www.isi.edu/nsnam/ns/tutorial/nsscript4.html
xgraph_ns2-files-tcl_04.19.tar.gz https://drive.google.com/file/d/1YuW8gmp7GpuibBiZJqj22Gf4ZDIX1gCO/view?usp=sharing

Graphical, gnuplot : gnuplot-ex.tar.gz https://drive.google.com/file/d/1NNxWJWWWsK0UsxMURsMfu_6nfDwWwwOn/view?usp=sharing

Graphical, ns2 APP-Tool https://github.com/WiNG-NITK/APP-Tool
Ubuntu 16.04 can use APP-Tool, i.e. it's a Python2 application The awk files APP-Tool/Final/[file].awk are using the new trace format

set ns [new Simulator]
$ns use-newtrace
$ns set WirelessNewTrace_ ON

The "newtrace modified" 111_aomdv-2.tcl is named newtrace-111_aomdv-2.tcl, creating a trace file 1new-mdaomdv.tr. https://drive.google.com/drive/folders/14vdJfoIqqKj34clkdxuN0IclHc0o0Oml?usp=share_link
Using newtrace : Many more of the available awk scripts can be used with the "1new-mdaomdv.tr"