Skip to main content

SELFISH NODES IN ADHOC NETWORKS

Hey All, In this post we discuss about selfish nodes and how to simulate selfish node scenario using ns2. 

MANET is self-constrained network, each node should collaborate with each other to perform functions of the network but sometimes node may behave selfishly to conserve their resource like batter power, bandwidth etc. Such nodes are called selfish node and selfishness disturb the network and take away the network from their regular mission. 

The term selfish node mainly comes from a  specific class of AdHoc Networks known as cooperative networks,  where different autonomous and as well as heterogeneous nodes (possibly owned by different individuals)  form a network and agree to forward each others packet   in cooperative manner.
The biggest problem in this type of network  is "selfish node problem", where some may start dropping the packets of others just for its own benefit (to save the power)
There are two commonly known techniques to with the selfish node problem:  
  1. Reputation based
  2. Incentive based 
  3. The combination of both
This particular area of research is closely related with game theoretic approaches to solve as well analyze the problem.


Selfish node does not forward any data packets to other nodes except itself. Selfish nodes helps to optimize their own gain, with neglect for the welfare of other nodes in a network. Selfish Nodes cooperates during the route discovery cycle to maintain a concise routing table and to be present in other routing tables in a network.

Behavior of selfish nodes

  • It does not forward the RREQ messages.
  • Do not forward data messages.
  • Delayed forwarding RREQ messages.
  • Do not forward RREP messages.
Code for Selfish Nodes

#define options
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ant) Antenna/OmniAntenna
set val(ll) LL
set val(ifqlen) 150
set val(nn) 10
set val(rp) DSR
set val(X) 600
set val(Y) 600
set val(cstop) 50
set val(stop) 50
set val(cp) "scen-20-10"

# Initialize Global Variables
set ns_ [new Simulator]

set tracefd [open DSR.tr w] $ns_ trace-all $tracefd
set namtrace [open DSR.nam w] $ns_ namtrace-all-wireless $namtrace $val(X) $val(Y)
#set up top
set topo [new Topography] $topo load_flatgrid $val(X) $val(Y)
# Create God
set god_ [create-god $val(nn)] #create channel
set chan_1_ [new $val(chan)] set chan_2_ [new $val(chan)]

if {$val(rp) == "DSR"
} {

set val(ifq) CMUPriQueue
} else {

set val(ifq) Queue/DropTail/PriQueue
}
#configure 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) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON \
-channel $chan_1_
# create nodes
for {
set i 0
} {
$i < $val(nn)
} {
incr i
} {

set node_($i) [$ns_ node] $node_($i) random-motion 0;
}
puts "loading random connection pattern..."
source $val(cp)
source "cbr"
#Define initial node position
for {
set i 0
} {
$i<$val(nn)
} {
incr i
} {
$ns_ initial_node_pos $node_($i) 30
}
#$ns_ at 0.0 "[$node_(4) set ragent_] hacker"
for {
set i 0
} {
$i<4
} {
incr i
} {
$ns_ at $val(cstop) "$cbr_($i) stop"
}
for {
set i 0
} {
$i<$val(nn)
} {
incr i
} {
$ns_ at $val(stop).000000001 "$node_($i) reset";
}
$ns_ at 0.01 "$node_(0) add-mark m brown circle"
$ns_ at 0.01 "$node_(1) add-mark m brown circle"
$ns_ at 0.01 "$node_(2) add-mark m brown circle"
$ns_ at 0.01 "$node_(3) add-mark m brown circle"
$ns_ at 0.01 "$node_(4) add-mark m brown circle"
$ns_ at 0.01 "$node_(5) add-mark m brown circle"
$ns_ at 0.01 "$node_(6) add-mark m brown circle"
$ns_ at 0.01 "$node_(7) add-mark m brown circle"
$ns_ at 0.01 "$node_(8) add-mark m brown circle"
$ns_ at 0.01 "$node_(9) add-mark m brown circle"

$ns_ at 40.5 "$ns_ trace-annotate \" NODE 0 IS DETECTED AS SELFISH NODE AT TIME 40.5\""
$ns_ at 45.5 "$ns_ trace-annotate \" NODE 4 IS DETECTED AS SELFISH NODE AT TIME 45.5\""
$ns_ at 45.0 "$ns_ trace-annotate \" NODE 7 IS DETECTED AS SELFISH NODE AT TIME 45.0\""
$ns_ at 45.5 "$ns_ trace-annotate \" NODE 9 IS DETECTED AS SELFISH NODE AT TIME 45.5\""

$ns_ at 40.5 "$node_(0) delete-mark m"
$ns_ at 40.5 "$node_(0) add-mark m red circle"
$ns_ at 48.5 "$node_(4) delete-mark m"
$ns_ at 45.5 "$node_(4) add-mark m red circle"
$ns_ at 48.5 "$node_(7) delete-mark m"
$ns_ at 45.5 "$node_(7) add-mark m red circle"
$ns_ at 48.5 "$node_(9) delete-mark m"
$ns_ at 45.5 "$node_(9) add-mark m red circle"

$ns_ at $val(stop) "finish"
$ns_ at $val(stop).0 "$ns_ trace-annotate \"Simulation has ended\""
$ns_ at $val(stop).00000001 "puts \"NS exiting...\"; $ns_ halt"
proc finish {

} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
exit 0
}
puts "Starting simulation..."
$ns_ run






Comments

Popular posts from this blog

NS2 INSTALLATION IN UBUNTU 21.04

  Hello, this post explains how to install ns2 in Ubuntu 21.04.  1) First you have to download ns2 all-in-one package from following link;    http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download 2) Extract the downloaded zip file 'ns-allinone-2.35.tar.gz file' to home folder. 3)  Now you need to download some essential packages for ns2,these packages can be downloaded by using the following commands :  applications>accessories>terminal or dashhome>terminal   and   then type the below lines one by one on the terminal window sudo apt-get update sudo apt-get dist-upgrade sudo apt-get update 4) Install the basic libraries; sudo apt install build-essential autoconf automake libxmu-dev 5) Install gcc and g++ and for that please do following; open the file using sudo mode sudo nano /etc/apt/sources.list Include the following line in list;  deb http://in.archive.ubuntu.com/ubuntu bionic main universe then open terminal and exec

Link State Routing Protocol

Link state routing is a method in which each router shares its neighborhood’s knowledge with every other router on the internetwork. In this algorithm, each router in the network understands the network topology and then makes a routing table depending on this topology. Each router will share data about its connection to its neighbor, who will, consecutively, reproduce the data to its neighbors, etc. This appears just before all routers have constructed a topology of the network. In LSP, each node transmits its IP address and the MAC to its neighbor with its signature. Neighbors determine the signature and maintain a record of the combining IP address and the MAC. The Neighbor Lookup Protocol (NLP) of LSP derives and maintains the MAC and IP address of every network frame accepted by a node. The extracted data can support the mapping of MACs and IP addresses. The link-state flooding algorithm prevents the general issues of broadcast in the existence of loops by having every node mainta

HP NETWORK SIMULATOR: A COMWARE OS LEARNING TOOL

  Comware v7 is a network operating system that runs on HP high-end network devices. The HP Network Simulator is an ideal Comware v7 learning tool, which allows users to create, configure, and connect simulated networks. Benefits Beginners  – The HP Network Simulator tool is helpful for users who are new to networking and want to learn how to configure network devices (switches, routers), various topologies, or different routing and switching protocols and features. Experienced users  – The HP Network Simulator learning tool is helpful for users who have experience with non-HP networking devices and want to learn the Comware CLI and features. Extra devices  – Users can create devices using the HP Network Simulator and use them with their physical devices to configure and test topologies that aren’t configurable with just the physical devices they have. For example – A user wants to configure OSPF using 3 or more devices but has only 1 physical router. User can create 2 or more routers