Hi all,

We installed ns-allinone-2.30 and NSE over it. Now we want to work NSE
as an emulator in Linux machine with two ethernet cards attached.
Instead of tun interfaces, it uses real ethernet cards eth0 and eth1
to communicate with the other two hosts. Hosts are going to
communicate each others of which packets/bandwidth etc affected by the
emulator. We could not work what we found inside the example tcl
scripts. Because they are generally for sensory network, just the
nodes have random motion, topology as topography that have max/min x y
dimensions etc... So we changed some of the example tcl files, but we
had some errors and they already did not work correctly as we hoped up
to the error situation occurs. Would you suggest anything to this
simple code to assist two hosts to communicate through the emulator ?
( We want packet losses, bandwidth limitations or whatever else over
packets...)

There are two errors we have; (general errors posted in this forum
with less sufficient answers)
1) RealTimeScheduler warning slop exceeded limit...
2) no target slot -1...

#! /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)             2                          ;# number of mobile nodes
#set val(stime)         60.0                       ;# simulation time
set val(stime)          360000.0                   ;# simulation time = 100 
hours

 #   Mac/802_11 set dataRate_ 11Mb                  ;# 802.11 data

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 result.tr.txt 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 0 1

# Create GOD
create-god $val(nn)

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

# Configure node parameters
# -adhocRouting $val(rp) \

$ns node-config -llType $val(ll) \
        -macType $val(mac) \
        -ifqType $val(ifq) \
        -ifqLen $val(ifqlen) \
        -phyType $val(netif) \
        -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"

#Network objects to access the TAP devices at the link layer

global ns node_
        set node_(1) [$ns node]
global ns node_
        set node_(2) [$ns node]

$ns color 0 blue
$ns color 1 red
                                        
#for {set i 1} {$i <= $val(nn)} {incr i} {
#       $ns at 0 "$node_($i) start";
 #      #$ns at $val(stime) "$node_($i) reset";
#}

$ns duplex-link $node_(1) $node_(2) 0.5Mb 100ms DropTail

  puts "cell topology"


set raw1 [new Network/Raw]
set raw2 [new Network/Raw]

#set raw3 [new Network/Raw]
#set raw4 [new Network/Raw]

$raw1 open eth0 readwrite
$raw2 open eth1 readwrite

#$raw3 open eth0 readwrite
#$raw4 open eth0 readwrite

#Tap Agent for each node
Agent/Tap set maxpkt_ 3100
set a1 [new Agent/Tap/Raw "FE:FD:C8:5A:4E:D4"]
#MAC address of server
set a2 [new Agent/Tap/Raw "FD:DE:AA:AA:6E:04"]
#MAC address of client

#set a3 [new Agent/Tap/Raw "FE:FD:C0:A9:2E:02"]
#set a4 [new Agent/Tap/Raw "FE:FD:C0:A9:2E:07"]

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

We also try to change mtp.tcl in ns2.30/tcl/ex/wireless-scripts
directory, but we could not just emulate correctly, could not apply
bandwidth limitation, packet losses or else to our network.

Thanks in advance...

Emin

Reply via email to