LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   wireless implementation in ns2 (https://www.linuxquestions.org/questions/linux-newbie-8/wireless-implementation-in-ns2-860845/)

bluetooth 02-05-2011 03:00 AM

wireless implementation in ns2
 
not able to solve an error when i try to do a wireless scenario in ns2.


num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead

knudfl 02-05-2011 05:33 AM

Welcome to LQ.

May be start here http://www.linuxquestions.org/linux/...Ask_a_Question
http://linuxsilo.net/docs/smart-questions_en.html

Much more information is required :
Always tell, which Linux OS ( Ubuntu <version> <name> ),
you are using for the application in question, please.
And the application, <version> : ns-allinone-2.34 ?
The command, that is used. And the location. ( $ pwd will tell.)
Also : If you wrote the file.tcl yourself or used a modified one.

Example : cd ns-allinone-2.34/ns-2.34/tcl/ex
ns wireless-mitf.tcl : No errors.
Or : ns wireless.tcl : Also OK.

..

bluetooth 02-07-2011 10:38 PM

Thanx knudfl. I rectified the error. It was just a mistake in the code i had written. But certainly i'll keep in mind your tip.

eyana 02-22-2012 03:07 AM

sctp in wireless scenario
 
Hi!

I got the same error.

I'm using ns2.33 and I modified the simple-wireless.tcl.

My code is below:

Trace set show_sctphdr_ 1

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

# Define options

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

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(nn) 2 ;# number of mobilenodes

set val(rp) DSDV ;# routing protocol



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

# Main Program

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

#

# Initialize Global Variables

#

set ns [new Simulator]


set tr [open simple.tr w]

$ns trace-all $tr

set nf [open simple.nam w]
$ns namtrace-all $nf



# set up topography object

set topo [new Topography]



$topo load_flatgrid 500 500



#

# Create God

#

create-god $val(nn)



#

# Create the specified number of mobilenodes [$val(nn)] and "attach" them

# to the channel.

# Here two nodes are created : node(0) and node(1)



# configure node



$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) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace OFF \

-movementTrace OFF



for {set i 0} {$i < $val(nn) } {incr i} {

set node_($i) [$ns node]

$node_($i) random-motion 0 ;# disable random motion

}



#

# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes

#

$node_(0) set X_ 5.0

$node_(0) set Y_ 2.0

$node_(0) set Z_ 0.0



$node_(1) set X_ 390.0

$node_(1) set Y_ 385.0

$node_(1) set Z_ 0.0



#

# Now produce some simple node movements

# Node_(1) starts to move towards node_(0)

#

$ns at 50.0 "$node_(1) setdest 25.0 20.0 15.0"

$ns at 10.0 "$node_(0) setdest 20.0 18.0 1.0"



# Node_(1) then starts to move away from node_(0)

$ns at 100.0 "$node_(1) setdest 490.0 480.0 15.0"



# Setup traffic flow between nodes

# SCTP connections between node_(0) and node_(1)



set sctp0 [new Agent/SCTP]
$ns attach-agent $node_(0) $sctp0
$sctp0 set fid_ 1
set cbr0 [new Application/Traffic/CBR]

# set traffic class to 1

$cbr0 set class_ 1
$cbr0 attach-agent $sctp0

# Create a Null sink to receive Data

set sinknode1 [new Agent/LossMonitor]
$ns attach-agent $node_(1) $sinknode1
set sctp1 [new Agent/SCTP]
$ns attach-agent $node_(1) $sctp1
$sctp1 set fid_ 2
set cbr1 [new Application/Traffic/CBR]
$cbr1 set class_ 2
$cbr1 attach-agent $sctp1
set sinknode0 [new Agent/LossMonitor]
$ns attach-agent $node_(0) $sinknode0
$ns connect $sctp0 $sctp1


#

# Tell nodes when the simulation ends

#

for {set i 0} {$i < $val(nn) } {incr i} {

$ns at 150.0 "$node_($i) reset";

}

$ns at 15.0 "stop"

$ns at 15.01 "puts \"NS EXITING...\" ; $ns halt"

proc stop {} {

global ns tracefd

$ns flush-trace

close $tracefd

}



Please help me.

Thank you very much.

knudfl 02-22-2012 04:10 AM

Post #4, @eyana : Please edit post #4 to use CODE tags :
Write [/code] at code text end, and [code] at text start.
Or use the # button in the Advanced Editor : Edit > Go Advanced.
http://www.linuxquestions.org/questi....php?do=bbcode


Quote:

I got the same error.
Same as what ? ? No errors were indicated in post #1.

.

eyana 02-22-2012 10:11 PM

I'm sorry. I made correction for post #4.

When I run this code I got the same output as #1 and the simple.tr file was blank. Also nam didn't appear.

Code:

Trace set show_sctphdr_ 1

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

# Define options

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

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(nn) 2 ;# number of mobilenodes

set val(rp) DSDV ;# routing protocol



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

# Main Program

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

#

# Initialize Global Variables

#

set ns [new Simulator]


set tr [open simple.tr w]

$ns trace-all $tr

set nf [open simple.nam w]
$ns namtrace-all $nf



# set up topography object

set topo [new Topography]

$topo load_flatgrid 500 500

# Create God
create-god $val(nn)

# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel.
# Here two nodes are created : node(0) and node(1)

# configure node
$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) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace OFF \

-movementTrace OFF

for {set i 0} {$i < $val(nn) } {incr i} {

set node_($i) [$ns node]

$node_($i) random-motion 0 ;# disable random motion

}



#

# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes

#

$node_(0) set X_ 5.0

$node_(0) set Y_ 2.0

$node_(0) set Z_ 0.0



$node_(1) set X_ 390.0

$node_(1) set Y_ 385.0

$node_(1) set Z_ 0.0

#

# Now produce some simple node movements

# Node_(1) starts to move towards node_(0)

#

$ns at 50.0 "$node_(1) setdest 25.0 20.0 15.0"

$ns at 10.0 "$node_(0) setdest 20.0 18.0 1.0"


# Node_(1) then starts to move away from node_(0)

$ns at 100.0 "$node_(1) setdest 490.0 480.0 15.0"


# Setup traffic flow between nodes

# SCTP connections between node_(0) and node_(1)

set sctp0 [new Agent/SCTP]
$ns attach-agent $node_(0) $sctp0
$sctp0 set fid_ 1
set cbr0 [new Application/Traffic/CBR]

# set traffic class to 1

$cbr0 set class_ 1
$cbr0 attach-agent $sctp0

# Create a Null sink to receive Data

set sinknode1 [new Agent/LossMonitor]
$ns attach-agent $node_(1) $sinknode1
set sctp1 [new Agent/SCTP]
$ns attach-agent $node_(1) $sctp1
$sctp1 set fid_ 2
set cbr1 [new Application/Traffic/CBR]
$cbr1 set class_ 2
$cbr1 attach-agent $sctp1
set sinknode0 [new Agent/LossMonitor]
$ns attach-agent $node_(0) $sinknode0
$ns connect $sctp0 $sctp1

#

# Tell nodes when the simulation ends

#

for {set i 0} {$i < $val(nn) } {incr i} {

$ns at 150.0 "$node_($i) reset";

}

$ns at 15.0 "stop"

$ns at 15.01 "puts \"NS EXITING...\" ; $ns halt"

proc stop {} {

global ns tracefd

$ns flush-trace

close $tracefd

}

Please help me.

knudfl 02-23-2012 02:10 AM

Post # 4 : Please hit the Edit button : Code tags are required.

A tcl file that 1) generates a trace file ? , 2) starts nam,
can look like this ( Template.tcl )
Code:

# start with these lines :

set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf

proc finish {} {
        global ns nf
        $ns flush-trace
        close $nf
        exec nam out.nam &
        exit 0
}

#######################



#######################

# end with :

$ns at 5.0 "finish"
$ns run

.


All times are GMT -5. The time now is 10:45 PM.