Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
I am working on my project. It is about detection of selfish nodes depending on the energy of the node. Here I have 20 nodes of the same energy, then I added 5 more but with different energies. The program shows that there is an error (as listed at the end of the code).
My code
```
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 100000 ;# max packet in ifq
set val(nn) 20 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(seed) 0.0
set val(cp) "cbr-20"
set val(sc) "setdest-20"
set val(stop) 200.0 ;# time of simulation end
set ns_ [new Simulator]
set tracefile [open aodvnode50.tr w]
#set windowVsTime2 [open win.tr w]
$ns_ trace-all $tracefile
$ns_ use-newtrace
#$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
#Open the NAM trace file
set namfile [open manet.nam w]
$ns_ namtrace-all $namfile
$ns_ namtrace-all-wireless $namfile $val(x) $val(y)
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]
#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#
# configure the nodes
$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 $chan_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-energyModel "EnergyModel" \
-initialEnergy 100.0 \
-txPower 2.0522 \
-rxPower 0.0591 \
-idlePower 0.00006 \
-sleepPower 0.000003 \
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
}
$ns_ node-config -initialEnergy 500
set node_(20) [$ns_ node]
$ns_ node-config -initialEnergy 20
set node_(21) [$ns_ node]
$ns_ node-config -initialEnergy 30
set node_(22) [$ns_ node]
$ns_ node-config -initialEnergy 100
set node_(23) [$ns_ node]
$ns_ node-config -initialEnergy 100
set node_(24) [$ns_ node]
# 21 connecting to 24 at time 20.48548468411224
#
set udp_(8) [new Agent/UDP]
$ns_ attach-agent $node_(21) $udp_(8)
set null_(8) [new Agent/Null]
$ns_ attach-agent $node_(24) $null_(8)
set cbr_(8) [new Application/Traffic/CBR]
$cbr_(8) set packetSize_ 512
$cbr_(8) set interval_ 1.0
$cbr_(8) set random_ 1
$cbr_(8) set maxpkts_ 10000
$cbr_(8) attach-agent $udp_(8)
$ns_ connect $udp_(8) $null_(8)
$ns_ at 20.48548468411224 "$cbr_(8) start"
#
# 22 connecting to 9 at time 76.258212521792487
#
set udp_(9) [new Agent/UDP]
$ns_ attach-agent $node_(22) $udp_(9)
set null_(9) [new Agent/Null]
$ns_ attach-agent $node_(9) $null_(9)
set cbr_(9) [new Application/Traffic/CBR]
$cbr_(9) set packetSize_ 512
$cbr_(9) set interval_ 1.0
$cbr_(9) set random_ 1
$cbr_(9) set maxpkts_ 10000
$cbr_(9) attach-agent $udp_(9)
$ns_ connect $udp_(9) $null_(9)
$ns_ at 76.258212521792487 "$cbr_(9) start"
puts "Loading connection pattern..."
source $val(cp)
puts "Loading scenario file..."
source $val(sc)
proc finish {} {
global ns_ tracefile namfile
$ns_ flush-trace
close $tracefile
close $namfile
exec nam manet.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ initial_node_pos $node_($i) 20
}
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop).000000001 "$node_($i) reset";
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop).000000001 "puts "NS EXITING..."; $ns_ halt"
puts "Start Simulation..."
$ns_ run
```
The error
```
num_nodes is set 20
INITIALIZE THE LIST xListHead
Loading connection pattern...
Loading scenario file...
Start Simulation...
SORTING LISTS ...DONE!
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 24, dst 21, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
[suppressing additional MAC cache_ warnings]
NS EXITING...
I am working on my project. It is about detection of selfish nodes depending on the energy of the node. Here I have 20 nodes of the same energy, then I added 5 more but with different energies. The program shows that there is an error (as listed at the end of the code).
My code
Code:
# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 100000 ;# max packet in ifq
set val(nn) 20 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(seed) 0.0
set val(cp) "cbr-20"
set val(sc) "setdest-20"
set val(stop) 200.0 ;# time of simulation end
set ns_ [new Simulator]
set tracefile [open aodvnode50.tr w]
#set windowVsTime2 [open win.tr w]
$ns_ trace-all $tracefile
$ns_ use-newtrace
#$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
#Open the NAM trace file
set namfile [open manet.nam w]
$ns_ namtrace-all $namfile
$ns_ namtrace-all-wireless $namfile $val(x) $val(y)
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]
#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#
# configure the nodes
$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 $chan_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-energyModel "EnergyModel" \
-initialEnergy 100.0 \
-txPower 2.0522 \
-rxPower 0.0591 \
-idlePower 0.00006 \
-sleepPower 0.000003 \
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
}
$ns_ node-config -initialEnergy 500
set node_(20) [$ns_ node]
$ns_ node-config -initialEnergy 20
set node_(21) [$ns_ node]
$ns_ node-config -initialEnergy 30
set node_(22) [$ns_ node]
$ns_ node-config -initialEnergy 100
set node_(23) [$ns_ node]
$ns_ node-config -initialEnergy 100
set node_(24) [$ns_ node]
# 21 connecting to 24 at time 20.48548468411224
#
set udp_(8) [new Agent/UDP]
$ns_ attach-agent $node_(21) $udp_(8)
set null_(8) [new Agent/Null]
$ns_ attach-agent $node_(24) $null_(8)
set cbr_(8) [new Application/Traffic/CBR]
$cbr_(8) set packetSize_ 512
$cbr_(8) set interval_ 1.0
$cbr_(8) set random_ 1
$cbr_(8) set maxpkts_ 10000
$cbr_(8) attach-agent $udp_(8)
$ns_ connect $udp_(8) $null_(8)
$ns_ at 20.48548468411224 "$cbr_(8) start"
#
# 22 connecting to 9 at time 76.258212521792487
#
set udp_(9) [new Agent/UDP]
$ns_ attach-agent $node_(22) $udp_(9)
set null_(9) [new Agent/Null]
$ns_ attach-agent $node_(9) $null_(9)
set cbr_(9) [new Application/Traffic/CBR]
$cbr_(9) set packetSize_ 512
$cbr_(9) set interval_ 1.0
$cbr_(9) set random_ 1
$cbr_(9) set maxpkts_ 10000
$cbr_(9) attach-agent $udp_(9)
$ns_ connect $udp_(9) $null_(9)
$ns_ at 76.258212521792487 "$cbr_(9) start"
puts "Loading connection pattern..."
source $val(cp)
puts "Loading scenario file..."
source $val(sc)
proc finish {} {
global ns_ tracefile namfile
$ns_ flush-trace
close $tracefile
close $namfile
exec nam manet.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ initial_node_pos $node_($i) 20
}
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop).000000001 "$node_($i) reset";
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop).000000001 "puts "NS EXITING..."; $ns_ halt"
puts "Start Simulation..."
$ns_ run
```
The error
```
num_nodes is set 20
INITIALIZE THE LIST xListHead
Loading connection pattern...
Loading scenario file...
Start Simulation...
SORTING LISTS ...DONE!
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 24, dst 21, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
MAC_802_11: accessing MAC cache_ array out of range (src 21, dst 24, size 20)!
[suppressing additional MAC cache_ warnings]
NS EXITING...
You have been asked before to use CODE tags when posting, and have ignored that too. You have been asked for details about your system previously, and posted that you were using NS2.35 on Ubuntu 18.04, and were informed that the scenario in question wouldn't work...and don't tell us what you're using NOW, if it's different. You say this is 'your' code...if you wrote it, it should be easy for you to debug. If you didn't, you aren't telling us what you've done/changed in this code that you downloaded. We can't guess, and if you're not going to follow up on any of your threads, why post?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.