[Olsr-users] ns2 and olsrd

Henning Rogge (spam-protected)
Wed May 6 13:07:12 CEST 2009


Am Wednesday 06 May 2009 12:50:05 schrieb Ignacio Alvarez e Iñaki Fuentes 
telematica:
> Hi! We connect the VM to NS2 emulation as an ethernet interface. We have
> read it from a paper of magdeburg university. I agree with you because i
> think that the routing will be done inside the VM, but something strange
> happens, because if i put a node too far it listens the other nodes
> request, but these nodes dont listen him. I think that here is the problem
> because this should not happen.We did an attempt changing the virtual
> machines kernel but it also fail.
>
>  I will paste the ns2 code for you. We use a bridge connecting all the VM
> because our final target is to connect a external interface as a nokia810.
> We use iptables on the bridge to avoid the duplicated traffic but the
> problem is not at iptables i am certain.
>
> Could be the problem in using DumbAgent protocol?
> i am very sorry for my bad english but i have tried to explain it
> clearly...if you dont understand something, just ask me and i will try to
> explain it better.
The problem might be that you use only one TAP interface and bridge it to the 
VMs. I used one TAP for each VM during my diploma thesis experiments (see file 
below.


#! /bin/nse

# An example script for the usage of ns-2 in emulation mode:
# Uses:
# 1. Network/Raw agents to access to a network device at level II
# 2. Tap/Raw agents to map between real MAC addresses and NS-2 IP addresses
# 3. In-memory compression of the trace file to reduce disk write operations 
during simulation
#	(currently done via gzip)


# Common variables
# 

set scriptname		routingdemo
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/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(x)              800			   ;# x range in meters
set val(y)              600			   ;# y range in meters
#set val(rp)		AODV			   ;# routing protocol
set val(rp)		DumbAgent		   ;# routing protocol
set val(nn)		4			   ;# number of mobile nodes
#set val(stime)		60.0			   ;# simulation time
set val(stime)		360000.0		   ;# simulation time = 100 hours

set ns		[new Simulator]
$ns use-scheduler RealTime

set tracefd  [open "|gzip > $scriptname.tr.gz" w]
$ns trace-all $tracefd
#set tr0 [new BaseTrace/ShmGZ test.tr.gz 16 400 104857600]

set namtrace [open "|gzip > $scriptname.nam.gz" w]
#set namtrace [open "|nam -r 0.1 -" w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

#Procedure needed when running nam in real-time
proc NamTime {} {
	#Send time to nam periodically
	global ns namtrace
	set now [$ns now]
	set next [expr $now + 0.05]
	puts $namtrace "T -t $now"
	flush $namtrace
	$ns at $next "NamTime"
}

#$ns at 1.0 "NamTime"

proc UniformErr {} {
    set err [new ErrorModel]
    $err unit packet
    $err set rate_ 0.01
    $err ranvar [new RandomVariable/Uniform]
    $err drop-target [new Agent/Null]
    return $err
}

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

# Create GOD
create-god $val(nn)

# Create channel
set chan_1_ [new $val(chan)]

# Configure node parameters
$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 OFF \
	-routerTrace OFF \
	-macTrace ON \
	-movementTrace OFF \
	-channel $chan_1_ \
	-IncomingErrProc UniformErr

#Procedure to configure an ns-2 node initially
proc setup_node {id x y z color} {
	
	global ns node_
	set node_($id) [$ns node]
	$node_($id) set X_ $x
	$node_($id) set Y_ $y
	$node_($id) set Z_ $z
	$node_($id) color $color
	$ns at 0 "$node_($id) setdest $x $y 0"
	$ns at 0 "$node_($id) color $color"
	$node_($id) random-motion 0
}
				
setup_node 1 100 300 0 "black"
setup_node 2 300 300 0 "green"
setup_node 3 500 300 0 "blue"
setup_node 4 700 300 0 "cyan"
					
for {set i 1} {$i <= $val(nn)} {incr i} {
	$ns at 0 "$node_($i) start";
    	$ns at $val(stime) "$node_($i) reset";
}

#Network objects to access the TAP devices at the link layer
set raw1 [new Network/Raw]
set raw2 [new Network/Raw]
set raw3 [new Network/Raw]
set raw4 [new Network/Raw]

$raw1 open tap0 readwrite 
$raw2 open tap1 readwrite 
$raw3 open tap2 readwrite 
$raw4 open tap3 readwrite 

#Tap Agent for each node
Agent/Tap set maxpkt_ 3100
set a1 [new Agent/Tap/Raw "FE:FD:C0:A8:2F:01"]
set a2 [new Agent/Tap/Raw "FE:FD:C0:A8:2F:02"]
set a3 [new Agent/Tap/Raw "FE:FD:C0:A8:2F:03"]
set a4 [new Agent/Tap/Raw "FE:FD:C0:A8:2F:04"]

puts "install nets into taps..."
#Assign network objects to TAP agents
$a1 network $raw1
$a2 network $raw2
$a3 network $raw3
$a4 network $raw4

#Assign TAP agents to ns-2 nodes
$ns attach-agent $node_(1) $a1
$ns attach-agent $node_(2) $a2
$ns attach-agent $node_(3) $a3
$ns attach-agent $node_(4) $a4
        
$ns at $val(stime) "stop"
$ns at $val(stime) "puts \"NS EXITING ...\" ; $ns halt"

proc stop {} {
	global ns tracefd raw1 raw2 raw3 raw4
	$ns flush-trace
	close $tracefd
	$raw1 close
	$raw2 close
	$raw3 close
	$raw4 close
}
	    
puts "okey"
	
$ns run


*************************************************
Diplom Informatiker Henning Rogge
Forschungsgesellschaft für
Angewandte Naturwissenschaften e. V. (FGAN) 
Neuenahrer Str. 20, 53343 Wachtberg, Germany
Tel.: 0049 (0)228 9435-961
Fax: 0049 (0)228 9435-685
E-Mail: (spam-protected)
Web: www.fgan.de
************************************************
Sitz der Gesellschaft: Bonn
Registergericht: Amtsgericht Bonn VR 2530
Vorstand: Prof. Dr. rer. nat. Maurus Tacke (komm. Vors.), Prof. Dr.-Ing. 
Joachim Ender (Stellv.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.olsr.org/pipermail/olsr-users/attachments/20090506/07eb4e10/attachment.sig>


More information about the Olsr-users mailing list