LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-09-2021, 06:23 AM   #1
JAFAR-KEFAH
LQ Newbie
 
Registered: May 2021
Posts: 7

Rep: Reputation: Disabled
Nodes with different energies


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...


```
 
Old 06-09-2021, 08:00 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,654

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by JAFAR-KEFAH View Post
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...
This is now your third thread related to NS...and you never bothered to follow up in your other two:
https://www.linuxquestions.org/quest...le-4175695890/
https://www.linuxquestions.org/quest...wk-4175695821/

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?
 
1 members found this post helpful.
  


Reply

Tags
energy model



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
AODV with Black hole nodes for 20 nodes is Not Executing please help to solve this ??? mateen_Chatterki Linux - Wireless Networking 2 04-27-2021 08:33 AM
How to set different energy levels to different nodes in ns2 pon Linux - Newbie 3 05-03-2019 07:45 AM
Setting up Kickstart server RHEL 6.5 for compute nodes, GPU nodes and PHI nodes sho1sho1 Red Hat 3 06-23-2015 04:20 PM
how to set different energy level to different nodes in ns2 Aska123 Linux - Software 0 02-17-2014 02:44 PM
convert your energies Trio3b General 4 05-04-2005 11:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:31 AM.

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