Reputation mechanism protocol documentation - NS-2 protocol

Introduction

The DGrR (Distributed GRoup Reputation) project is a reputation extension of NS-2. Though the actual version as been tested on the OLSR protocol, simple modifications on the OTCL file (OTCL example file) are required to use our solution on another routing protocol, such as AODV.
Please refer to our full documentation about the recommendation evaluation.

Tools required:

This code is a NS-2 plugin. NS2 have to be installed first, with the OLSR package as this version of the project is made for OLSR (otherwise, you only need to update the OTCL file describes in OTCL example file).
NS-2 is available at http://www.isi.edu/nsnam/ns/

Installation

In order to install this application layer protocol, the package has to be installed in the NS-2 protocols folder : #/ns-2/ns-2.31.
Decompress the whole files in a the #/ns-2/ns-2.31/DGrR/ subdirectory

Then, modifiations have to be performed on basic ns2 files in order to integrate this package (an automatic patch is not yet available):

Full explanation are available at http://www.isi.edu/nsnam/ns/tutorial/nsnew.html#third

Running the program

NS2 recompilation

Before launching ns with an adapted OTCL file, the simulator must be recompiled :
 cd $nsfolder
 make
where $nsfolder should look like #/ns-2/ns-2.31

OTCL example file

 # ======================================================================
# Define options
# ======================================================================
set opt(chan)           Channel/WirelessChannel  ;# channel type
set opt(prop)           Propagation/TwoRayGround ;# radio-propagation model
set opt(netif)          Phy/WirelessPhy          ;# network interface type
set opt(mac)            Mac/802_11               ;# MAC type
set opt(ifq)            Queue/DropTail/PriQueue  ;# interface queue type
set opt(ll)             LL                       ;# link layer type
set opt(ant)            Antenna/OmniAntenna      ;# antenna model
set opt(ifqlen)         50                       ;# max packet in ifq
set opt(nn)             4                        ;# number of mobilenodes
set opt(adhocRouting)   AODV                     ;# routing protocol
set opt(cp)             ""; #"~/bin/ns-2/ns-2.31/tcl/mobility/scene/cbr-3-test"  ; # connection pattern file
set opt(sc)             "~/bin/ns-2/ns-2.31/tcl/mobility/scene/scen-3-test" ; # node movement file.

set opt(x)              400                      ;# x coordinate of topology
set opt(y)              600                      ;# y coordinate of topology
set opt(seed)           0.0                      ;# seed for random number gen.
set opt(stop)           8000 	         	 ;# time to stop simulation

# ============================================================================

#
# check for random seed
#
if {$opt(seed) > 0} {
    puts "Seeding Random number generator with $opt(seed)\n"
    ns-random $opt(seed)
}

#
# create simulator instance
#
set ns_ [new Simulator]

#$ns_ set-address-format expanded

#
# control OLSR behaviour from this script -
# commented lines are not needed because
# those are default values
#
Agent/OLSR set use_mac_    true
Agent/OLSR set debug_      false
Agent/OLSR set willingness 3
Agent/OLSR set hello_ival_ 2
Agent/OLSR set tc_ival_    5

#
# control reputation mechanism
#

# synchronisation interval
set DGrR(reptimer_ival_) 50
set DGrR(groupSize) 4

# % of malicious nodes at most !
set DGrR(tau_) 10
set DGrR(NRmax_) 10

#
bindings
#
Agent/DGrR set reptimer_ival_  $DGrR(reptimer_ival_)
Agent/DGrR set tau_  $DGrR(tau_)
Agent/DGrR set NRmax_  $DGrR(NRmax_)

#
# open traces
#
set tracefd  [open olsr_example.tr w]
set namtrace [open olsr_example.nam w]

set DGrRtrace [open olsr_example.rep w]

$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)

#
# create topography object
#
set topo [new Topography]

#
# define topology
#
$topo load_flatgrid $opt(x) $opt(y)

#
# create God
#
create-god $opt(nn)

set chan_1_ [new $opt(chan)]

#
# configure mobile nodes
#
$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -topoInstance $topo \
                 -wiredRouting OFF \
                 -agentTrace ON \
                 -routerTrace ON \
                 -macTrace OFF \
	  	 -channel $chan_1_ 
		#-channelType $opt(chan) \

create nodes & start
for {set i 0} {$i < $opt(nn)} {incr i} {
    set node_($i) [$ns_ node]
    $ns_ at 0.1 "$node_($i) start"

}

#
define  group node (attach-agent)
#
for {set i 0} {$i < $DGrR(groupSize)} {incr i} {
    set olsrRAgent($i) [new Agent/DGrR]
    $node_($i) random-motion 0 ;# disable random motion
    $ns_ attach-agent $node_($i)  $olsrRAgent($i)
}

#
# init group nodes
#

#
# Note : these operations are done only because the group mechanism
# is not implemented in NS-2
# Thus, we emulate two cases : 
# - node inside the group : "initGroupEntry"
# - node outside the group and who whish enter the group (here : Universe \ group) : "initEntry"
#
for {set i 0} {$i < $DGrR(groupSize)} {incr i} {

    # send first messages (tables creations)
    # wait for network stability
    $ns_ at 100.0 "$olsrRAgent($i) start"
    $ns_ at 100.0 "$olsrRAgent($i) initbroadcast"
    for {set j 0} {$j < $DGrR(groupSize)} {incr j} {
	set id [$node_($j) node-addr]
	 $ns_ at 1.0 "$olsrRAgent($i) initGroupEntry $id"

    }

    for {set j $DGrR(groupSize)} {$j < $opt(nn) } {incr j} {
	set id [$node_($j) node-addr]
	 $ns_ at 1.0 "$olsrRAgent($i) initentry $id"

    }

}

for {set i 0} {$i < $DGrR(groupSize)} {incr i} {
  $ns_ at $opt(stop).0001  "$olsrRAgent($i) finaldisplay"
}

#
# source connection-pattern and node-movement scripts
#
if { $opt(cp) == "" } {
    puts "*** NOTE: no connection pattern specified."
    set opt(cp) "none"
} else {
    puts "Loading connection pattern..."
    source $opt(cp)
}
if { $opt(sc) == "" } {
    puts "*** NOTE: no scenario file specified."
    set opt(sc) "none"
} else {
    puts "Loading scenario file..."
    source $opt(sc)
    puts "Load complete..."
}

#
# define initial node position in nam
#
for {set i 0} {$i < $opt(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 20
}

#
# tell all nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {

    $ns_ at $opt(stop).0 "$node_($i) reset";
}

$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "stop"

proc stop {} {
    global ns_ tracefd namtrace
    $ns_ flush-trace
    close $tracefd
    close $namtrace
 #	exec nam out.nam &
        exit 0
}

#
# begin simulation
#
puts "Starting Simulation..."

$ns_ run

full examples and explanation are available at TODO

Copyright and License

TODO




Generated on Fri May 11 10:58:00 2007 for STGDH - NS2 by  doxygen 1.4.6