Commit 65f17704 authored by gauthier's avatar gauthier

clean


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7381 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 45093a6a
This diff is collapsed.
# cat /etc/radvd.conf
interface eth0
{
AdvSendAdvert on;
AdvIntervalOpt on;
AdvHomeAgentFlag on;
MinRtrAdvInterval 0.1;
MaxRtrAdvInterval 0.3;
AdvReachableTime 30000;
AdvRetransTimer 500;
prefix 2001:1::1/64
{
AdvOnLink on;
AdvValidLifetime 20;
AdvPreferredLifetime 15;
AdvAutonomous on;
AdvRouterAddr on;
};
prefix fec0:1000::1/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
AdvValidLifetime 5;
AdvPreferredLifetime 1;
};
};
# cat /etc/radvd.conf
interface eth0
{
AdvSendAdvert on;
AdvIntervalOpt on;
AdvHomeAgentFlag on;
MinRtrAdvInterval 0.1;
MaxRtrAdvInterval 0.3;
AdvReachableTime 30000;
AdvRetransTimer 500;
prefix 2001:1::1/64
{
AdvValidLifetime 20;
AdvPreferredLifetime 15;
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
prefix fec0:2000::1/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
AdvValidLifetime 10;
AdvPreferredLifetime 1;
};
};
<?xml version="1.0" encoding="UTF-8"?>
<!--DOCTYPE vnuml SYSTEM "/usr/local/share/xml/vnuml/vnuml.dtd"-->
<!DOCTYPE vnuml SYSTEM "/packages/vnuml_1.8.3/share/xml/vnuml/vnuml.dtd">
<!--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/packages/vnuml_1.8.3/share/xml/vnuml/vnuml.dtd">
This file describe the Wireless Mesh Network topology for Chorist Project
Author:
Huu-Nghia.Nguyen@eurecom.fr
Christian.Bonnet@eurecom.fr
-->
<vnuml>
<global>
<version>1.8</version>
<simulation_name>chorist_inter</simulation_name>
<automac/>
<vm_mgmt type="none" />
<vm_defaults exec_mode="mconsole">
<filesystem type="cow">/home/Local_Data/nguyenhn/airnet/root_fs.fc6</filesystem>
<kernel>/home/Local_Data/nguyenhn/airnet/linux</kernel>
<!--
<filesystem type="cow">/home/all/root_fs.fc6</filesystem>
<kernel>/home/all/linux</kernel>
-->
<console id="0">xterm</console>
<console id="1">pts</console>
<console id="2">pts</console>
<console id="3">pts</console>
<console id="4">pts</console>
<console id="5">pts</console>
</vm_defaults>
</global>
<net name="C1" mode="uml_switch" hub="no" />
<net name="C2" mode="uml_switch" hub="no" />
<net name="MR1.0" mode="uml_switch" hub="yes" />
<net name="MR2.0" mode="uml_switch" hub="yes" />
<net name="MN1.0" mode="uml_switch" hub="yes" />
<net name="MN2.0" mode="uml_switch" hub="yes" />
<!-- Correspondent Node -->
<vm name="RELAY">
<if id="0" net="C1">
<ipv6>2001:100::3/64</ipv6>
</if>
<if id="1" net="C2">
<ipv6>2001:200::3/64</ipv6>
</if>
</vm>
<!-- Cluster Heads -->
<vm name="CH1">
<if id="0" net="C1">
<ipv6>2001:100::1/64</ipv6>
</if>
<route type="ipv6" gw="2001:100::3">2001:200::/64</route> <!-- forward to RELAY to Cluster2-->
<route type="ipv6" gw="2001:100::2">2001:1::1/128</route> <!-- forward to MR1 to MR1.IF0 -->
<forwarding type="ip"/>
</vm>
<vm name="CH2">
<if id="0" net="C2">
<ipv6>2001:200::1/64</ipv6>
</if>
<route type="ipv6" gw="2001:200::3">2001:100::/64</route> <!-- forward to RELAY to Cluster1-->
<route type="ipv6" gw="2001:200::2">2001:1::2/128</route> <!-- forward to MR1 to MR2.IF0 -->
<forwarding type="ip"/>
</vm>
<!-- Mobile Routers-->
<vm name="MR1">
<if id="1" net="C1">
<ipv6>2001:100::2/64</ipv6>
</if>
<if id="0" net="MR1.0">
<ipv6>2001:1::1/64</ipv6>
</if>
<route type="ipv6" gw="2001:100::1">default</route> <!-- default gateway is CH1.IF0 -->
<forwarding type="ip"/>
</vm>
<vm name="MR2">
<if id="1" net="C2">
<ipv6>2001:200::2/64</ipv6>
</if>
<if id="0" net="MR2.0">
<ipv6>2001:1::2/64</ipv6>
</if>
<route type="ipv6" gw="2001:200::1">default</route> <!-- default gateway is CH2.IF0 -->
<forwarding type="ip"/>
</vm>
<!-- Mobile Nodes -->
<vm name="MN1">
<if id="0" net="MN1.0">
</if>
</vm>
<vm name="MN2">
<if id="0" net="MN2.0">
</if>
</vm>
</vnuml>
This diff is collapsed.
#http://wiki.tcl.tk/1968
#from Jeffrey Hobbs
puts -nonewline "vnman (0) % "
if {!$tcl_interactive} {
set long_command ""
set verbose_history 0
if {![catch {rename unknown tcl_unknown}]} {
proc unknown {cmdname args} {
if {[regexp "^!..*" $cmdname]} {
banghist [string range $cmdname 1 end]
} else {
tcl_unknown $cmdname $args
}
}
}
proc banghist {val} {
global verbose_history
if {![string compare $val "!"]} {set val ""}
if {$verbose_history} {puts "[history event $val]"}
history redo $val
}
if {![info exists tcl_prompt1]} {
set tcl_prompt1 {puts -nonewline "vnman ([history nextid]) % "}
}
proc read_stdin {} {
global eventLoop tcl_prompt1 long_command
set l [gets stdin]
if {[eof stdin]} {
set eventLoop "done" ;# terminate the vwait eventloop
} else {
if {[string compare $l {}]} {
append long_command "\n$l"
set l $long_command
if {[info complete $l]} {
if {[catch {uplevel \#0 history add [list $l] exec} err]} {
puts stderr $err
} elseif {[string compare $err {}]} {
puts $err
}
set long_command ""
catch $tcl_prompt1
} else {
puts -nonewline "> "
}
} elseif {![string compare $long_command {}]} {
catch $tcl_prompt1
} else {
puts -nonewline "> "
}
flush stdout
}
}
# set up our keyboard read event handler:
# Vector stdin data to the socket
fileevent stdin readable read_stdin
catch $tcl_prompt1
flush stdout
# wait for and handle or stdin events...
#vwait eventLoop
}
#
# Management Script for Virtual Networking User-Mode-Linux
# Author: Huu-Nghia Nguyen
# Email: Huu-Nghia.Nguyen@eurecom.fr
# Eurecom Institute
#
Class VirtualMachine
proc flatten list {return [string map {\{ "" \} ""} $list]}
VirtualMachine instproc init {vm_opt_list} {
$self instvar opt sname
array set sname {}
array set opt $vm_opt_list
set dir [split $opt(uml_dir) "/"]
set len [llength $dir]
set opt(vmid) [lindex $dir [expr $len-2]]
set opt(scenario) [lindex $dir [expr $len-4]]
puts "VM ($opt(scenario).$opt(vmid)) running in $opt(uml_dir) is created"
}
VirtualMachine instproc mconsole args {
$self instvar opt
set dir $opt(uml_dir)$opt(umid)
set cmdline "cd $dir && uml_mconsole mconsole [flatten $args]"
puts "execute the command: $cmdline"
set result [exec sh -c "cd $dir && uml_mconsole mconsole [flatten $args]" 2>/dev/null]
return $result
}
VirtualMachine instproc getinfo {param idx} {
$self instvar opt
return [lindex [split $opt($param) ","] $idx]
}
########################################################################
#
# PARSE THE ENVIRONMENT
#
########################################################################
set vm_cmds [exec ps -ef | grep linux | sed s/.*linux//g | sort | uniq ]
## Split into vm_cmd_lines
set vm_cmd_lines [split $vm_cmds "\n"]
array unset vms
set stdout "/mnt/hostfs/stdout"
set stderr "/mnt/hostfs/stdout"
set filestdout ""
## Iterate over the vm_cmd_lines
foreach cmd $vm_cmd_lines {
#puts "---------\nAnalyse the command line:"
#puts $cmd
set params [split $cmd " "]
array unset opt
foreach param $params {
set fields [split $param "="]
set optname [lindex $fields 0]
set optval [lindex $fields 1]
if {$optval != ""} {
set opt($optname) $optval
}
}
if {[array size opt] > 0} {
set vm [new VirtualMachine [array get opt]]
set vms([$vm set opt(vmid)]) $vm
}
}
########################################################################
#
# COMMAND IMPLEMENTATION
#
########################################################################
set helpstr "Command list:\n\
\tconfig <vm> <device\[=options\]>: querry/add a new device to <vm>\n\
\tjob <vm> <command>: execute a command in <vm> using sh -c\n\
\tresult <vm>: return result of last job\n\
\tterm <vm> <conid>: open the console <conid> of <vm>\n\
\tmconsole <vm> <args>: run uml_mconsole for <vm>\n\
\tsetdest <x> <y> <speed>: \n\t\tset destination (<x>, <y>) for the MN with the speed of <speed> m/s\n"
proc help {} {
global helpstr
puts $helpstr
}
proc config {vmid args} {
global vms
set vm $vms($vmid)
return [$vm mconsole config $args]
}
proc job {vmid args} {
global vms filestdout
global stdout stderr
set vm $vms($vmid)
catch { exec rm opt(uml_dir)]/hostfs/$stdout }
return [$vm mconsole exec "'" $args ">$stdout 2>$stderr '"]
regsub {(.*)/(.*)} $stdout {\2} filename
set filestdout [$vm set opt(uml_dir)]/hostfs/$filename
exec cat $filestdout
}
proc lastresult {} {
exec cat $filestdout
}
proc result {vmid} {
global vms
global stdout stderr
set vm $vms($vmid)
regsub {(.*)/(.*)} $stdout {\2} filename
set filestdout [$vm set opt(uml_dir)]/hostfs/$filename
exec cat $filestdout
}
proc term {vmid conid} {
global vms
set vm $vms($vmid)
#Create screen name
set result [$vm mconsole config $conid]
regsub {(.*):(.*)} $result {\2} device
regsub {(.*)/(\d+)} $device {\2} devid
set screenname "$conid$devid$vmid"
#Try to look up in the env if the screen exist?
set filename /tmp/vnman-screen-[pid].cfg
catch { exec screen -ls > $filename } {}
set output [split [exec cat $filename] "\n"]
if {[lsearch -regex $output ".*$screenname.*"] < 0} {exec screen -d -m -S $screenname $device}
catch { exec rm -f $filename}
#Show the terminal
exec konsole -e screen -d -r $screenname &
}
proc mconsole {vmid args} {
global vms
set vm $vms($vmid)
return [$vm mconsole $args]
}
########################################################################
#
# COMMAND LINE INTERFACE
#
########################################################################
puts "VM lists: [array names vms]"
help
source vninteractive.tcl
source wirelesstopo.tcl
stop
#! /bin/nse
# An example script for the usage of ns-2 in emulation mode:
# Uses:
# 1. Network/Daemon agents (by Huu-Nghia.Nguyen@eurecom.fr) to access to a uml_switch 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 /tmp/chorist_inter.tr
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) DumbAgent ;# routing protocol
set val(nn) 4 ;# number of mobile nodes
#set val(stime) 200.0 ;# simulation time
set val(stime) 360000.0 ;# simulation time = 100 hours
set ns [new Simulator]
$ns use-scheduler RealTime
set tracefd [open $scriptname w]
$ns trace-all $tracefd
#set namtrace [open $scriptname.nam 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)]
set chan_2 [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 ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON \
-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
}
#Topo table:
set RELAY $vms(RELAY)
set CH1 $vms(CH1)
set CH2 $vms(CH2)
set MR1 $vms(MR1)
set MR2 $vms(MR2)
set MN1 $vms(MN1)
set MN2 $vms(MN2)
set map(1) [list $MR1 eth0 $chan_2 100 100 0 "green"]
set map(2) [list $MR2 eth0 $chan_2 500 100 0 "green"]
set map(3) [list $MN1 eth0 $chan_2 150 100 0 "red"]
set map(4) [list $MN2 eth0 $chan_2 450 100 0 "red"]
Agent/Tap set maxpkt_ 1500
for {set i 1} {$i <= $val(nn)} {incr i} {
$ns node-config -channel [lindex $map($i) 2]
puts "setup_node $i [lindex $map($i) 3] [lindex $map($i) 4] [lindex $map($i) 5] [lindex $map($i) 6]"
setup_node $i [lindex $map($i) 3] [lindex $map($i) 4] [lindex $map($i) 5] [lindex $map($i) 6]
$ns at 0 "$node_($i) start";
$ns at $val(stime) "$node_($i) reset";
#set raw($i) [new Network/Raw]
set raw($i) [new Network/Daemon]
set node [lindex $map($i) 0]
set iff [lindex $map($i) 1]
puts [$node getinfo $iff 1]
#$raw($i) open [$node getinfo $iff 1] readwrite
$raw($i) open [$node getinfo $iff 3] readwrite
#Tap Agent for each node
puts [$node getinfo $iff 2]
#set tagent($i) [new Agent/Tap/Raw [$node getinfo $iff 2]]
# if {$node == $MR2 && $iff == "eth0"} {
# set tagent($i) [new Agent/Tap/Raw fe:fd:0:0:3:0]
# } else {
set tagent($i) [new Agent/Tap/Raw [$node getinfo $iff 1]]
# }
$tagent($i) network $raw($i)
$ns attach-agent $node_($i) $tagent($i)
}
$ns at $val(stime) "stop"
$ns at $val(stime) "puts \"NS EXITING ...\" ; $ns halt"
proc setdest_1 { x y speed} {
global node_
$node_(3) setdest $x $y $speed
}
proc setdest_2 { x y speed} {
global node_
$node_(4) setdest $x $y $speed
}
proc stop {} {
global ns tracefd raw
$ns flush-trace
close $tracefd
for {set i 1} {$i <= $val(nn)} {incr i} {
$raw($i) close
}
}
source utils.tcl
puts "okey"
$ns run
# cat /etc/radvd.conf
interface eth0
{
AdvSendAdvert on;
AdvIntervalOpt on;
AdvHomeAgentFlag on;
MinRtrAdvInterval 0.1;
MaxRtrAdvInterval 0.3;
AdvReachableTime 1;
AdvRetransTimer 1;
prefix 2001:1::1/64
{
AdvOnLink on;
AdvValidLifetime 20;
AdvPreferredLifetime 15;
AdvAutonomous on;
AdvRouterAddr on;
};
prefix fec0:1000::1/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
AdvValidLifetime 5;
AdvPreferredLifetime 1;
};
};
# cat /etc/radvd.conf
interface eth0
{
AdvSendAdvert on;
AdvIntervalOpt on;
AdvHomeAgentFlag on;
MinRtrAdvInterval 0.1;
MaxRtrAdvInterval 0.3;
AdvReachableTime 1;
AdvRetransTimer 1;
prefix 2001:1::1/64
{
AdvValidLifetime 20;
AdvPreferredLifetime 15;
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
};
prefix fec0:2000::1/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr on;
AdvValidLifetime 10;
AdvPreferredLifetime 1;
};
};
<?xml version="1.0" encoding="UTF-8"?>
<!--DOCTYPE vnuml SYSTEM "/usr/local/share/xml/vnuml/vnuml.dtd"-->
<!DOCTYPE vnuml SYSTEM "/packages/vnuml_1.8.3/share/xml/vnuml/vnuml.dtd">
<!--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/packages/vnuml_1.8.3/share/xml/vnuml/vnuml.dtd">
This file describe the Wireless Mesh Network topology for Chorist Project
Author:
Huu-Nghia.Nguyen@eurecom.fr
Christian.Bonnet@eurecom.fr
-->
<vnuml>
<global>
<version>1.8</version>
<simulation_name>chorist</simulation_name>
<automac/>
<vm_mgmt type="none" />
<vm_defaults exec_mode="mconsole">
<filesystem type="cow">/home/Local_Data/nguyenhn/airnet/root_fs.fc6</filesystem>
<kernel>/home/Local_Data/nguyenhn/airnet/linux</kernel>
<!--
<filesystem type="cow">/home/all/root_fs.fc6</filesystem>
<kernel>/home/all/linux</kernel>
-->
<console id="0">xterm</console>
<console id="1">pts</console>
<console id="2">pts</console>
<console id="3">pts</console>
<console id="4">pts</console>
<console id="5">pts</console>
</vm_defaults>
</global>
<net name="Inter" mode="uml_switch" hub="yes" />
<net name="CH.0" mode="uml_switch" hub="yes"/>
<net name="MR1.1" mode="uml_switch" hub="yes" />
<net name="MR2.1" mode="uml_switch" hub="yes" />
<net name="MR1.0" mode="uml_switch" hub="yes" />
<net name="MR2.0" mode="uml_switch" hub="yes" />
<net name="MN1.0" mode="uml_switch" hub="yes" />
<net name="MN2.0" mode="uml_switch" hub="yes" />
<!-- Correspondent Node -->
<vm name="CN">
<if id="0" net="Inter">
<ipv6>2000::1/64</ipv6>
</if>
<route type="ipv6" gw="2000::2">2001::/16</route>
</vm>
<!-- Cluster Heads -->
<vm name="CH">
<if id="1" net="Inter">
<ipv6>2000::2/64</ipv6>
</if>
<if id="0" net="CH.0">
<ipv6>2001:100::1/64</ipv6>
</if>
<route type="ipv6" gw="2001:100::2">2001:1::1/128</route> <!-- forward to MR1 -->
<route type="ipv6" gw="2001:100::3">2001:1::2/128</route> <!-- forward to MR2 -->
<route type="ipv6" gw="2000::2">2000::/16</route> <!-- forward through CH.1-->
<forwarding type="ip"/>
</vm>
<!-- Mobile Routers-->
<vm name="MR1">
<if id="1" net="MR1.1">
<ipv6>2001:100::2/64</ipv6>
</if>
<if id="0" net="MR1.0">
<ipv6>2001:1::1/64</ipv6>
</if>
<route type="ipv6" gw="2001:100::1">default</route> <!-- default gateway is CH.IF0 -->
<forwarding type="ip"/>
</vm>
<vm name="MR2">