[ns] how to calculate bit error rate and packet error rate

2012-05-25 Thread Muhammad Musaddiq

Guyz can anyone tell me how to calculate bit error rate, and packet error rate 
in ns-2. does any body have tcl script for both bit error rate and packet error 
rate??..it would be great favour..Thnxxx 
 
Regardz
Muhammad Musaddiq
+92-332-4197661


[ns] Static routing tcl script

2012-05-08 Thread Muhammad Musaddiq

Guyz !!!
 does abybody have static routing infrastrcuture scenario correct 
script?... i want to understand the logic of static routing...kindly 
plz send me tcl script of STATIC ROUTING it will be great help.thnxxx 
alottt.

Regardz
Muhammad Musaddiq
+92-332-4197661


[ns] Fw: how to handle floating point exception error

2012-05-06 Thread Muhammad Musaddiq




Regardz
Muhammad Musaddiq
+92-332-4197661

- Forwarded Message -
From: Muhammad Musaddiq 
To: "ns-users@isi.edu"  
Sent: Monday, May 7, 2012 11:16 AM
Subject: how to handle floating point exception error


 Respected guyz !
 i am getting floating point exception error in the given below code,kindly do 
reply that how can i remove this error. thannnxxx alot -plz reply me early.

 
# -*- Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
Agent/TCP set tcpTick_ 0.1
# The default for tcpTick_ is being changed to reflect a changing reality.
Agent/TCP set rfc2988_ false
# The default for rfc2988_ is being changed to true.
# This test suite is for validating the snoop protocol
remove-all-packet-headers ; # removes all except common
add-packet-header Flags IP TCP Snoop Arp LL Mac ; # hdrs reqd for validation
# FOR UPDATING GLOBAL DEFAULTS:
Agent/TCP set precisionReduce_ false ; # default changed on 2006/1/24.
Agent/TCP set rtxcur_init_ 6.0 ; # Default changed on 2006/01/21
Agent/TCP set updated_rttvar_ false ; # Variable added on 2006/1/21
Agent/TCP set minrto_ 1
# default changed on 10/14/2004.
Agent/TCP set singledup_ 0
# The default is being changed to 1
Agent/TCP set useHeaders_ false
# The default is being changed to useHeaders_ true.
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_3
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(seed) 0
set val(ifqlen) 100 ;# max packet in ifq
set val(nn) 2 ;# how many nodes are simulated
set val(rp) AODV 
set val(x) 800 ;# X dimension of the topography
set val(y) 800 ;# Y dimension of the topography
set val(stop) 50 ;# simulation time
 
 
 
set basenode(bs) 2
set ns_ [new Simulator]
set tracefd [open snoop.tr w]
set namtrace [open snoop.nam w]
set cwnd [open tcpcwnd.tr w]
set file1 [open throughput1.tr w]
set f1 [open goodput1.tr w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god [expr $val(nn)+$basenode(bs)]
 
$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 \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF 
for {set i 0} {$i < $basenode(bs) } { incr i } {
set base($i) [$ns_ node] 
$base($i) random-motion 0 
}
$base(0) set X_ 200.0
$base(0) set Y_ 550.0
$base(0) set Z_ 0.0
 
$base(1) set X_ 450.0
$base(1) set Y_ 550.0
$base(1) set Z_ 0.0
set lan [$ns_ make-lan [list $base(1)] 11Mb 2ms LL $val(ifq) $val(mac)]
$lan addNode [list $base(0)] 11Mb 2ms LL/LLSnoop $val(ifq) $val(mac)
 
for {set j 0} {$j < $val(nn) } { incr j } {
set wireless($j) [$ns_ node] 
}
 
$ns_ node-config -macType Mac/802_11 
$ns_ node-config -wiredRouting OFF
$ns_ node-config -agentTrace ON 
$ns_ node-config -routerTrace ON
$ns_ node-config -movementTrace ON
$wireless(0) set X_ 150.0
$wireless(0) set Y_ 525.0
$wireless(0) set Z_ 0.0
 
$wireless(1) set X_ 550.0
$wireless(1) set Y_ 525.0
$wireless(1) set Z_ 0.0
 
 
 
 
$wireless(0) base-station [AddrParams addr2id [$base(0) node-addr]]
$wireless(1) base-station [AddrParams addr2id [$base(1) node-addr]]
 
 
 
proc finish {} {
global ns_ tracefd namtrace cwnd file1 f1
$ns_ flush-trace
close $tracefd
close $namtrace
close $cwnd
close $file1
close $f1
exec xgraph tcpcwnd.tr -x "Time (RTT)" -y "Window" -t "CWND0" -geometry 800*400 
&
exec xgraph throughput1.tr -t "throughput1" -geometry 800*400 &
exec xgraph goodput1.tr -t "goodput1" -geometry 800*400 &
exec nam snoop.nam &
puts "finishing.."
exit 0
}
 
# simple test
#
# Network topology:
#
# AB
# _|_(lan) 
# |
# CD
#
# A sends data to destination D
#
# B is snoop agent. 
# set up TCP flow from A to D
set tcp [new Agent/TCP]
#$tcp set windowInit_ 1
#max congestion window size
#$tcp set maxcwnd_ 32
set sink [new Agent/TCPSink]
$ns_ attach-agent $wireless(0) $tcp
$ns_ attach-agent $wireless(1) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
#$ftp set packetSize_ 1024
#$ftp set interval_ 0.001
#$ftp set rate_ 8Mb
#$ftp set window_ 40
$ftp attach-agent $tcp
 
 
 
set rtt1 3
set rto1 64 
proc congestionwindow {} {
global ns_ cwnd tcp current_cwnd current_wndw roundtriptime retimeout ssthresh 
rtt1 rto1
# set the time after which the procedure should be called again
set time 0.1
# get the current time
set now [$ns_ now]
set current_cwnd [$tcp set cwnd_]
set current_wndw [$tcp set window_]
set roundtriptime [$tcp set rtt_]
set retimeout [$tcp set maxrto_]
set ssthresh [expr $current_cwnd/2]
if {$current_cwnd < $ssthresh} {
if {$roundtriptime < $rtt1} {
set current_cwnd [expr $current_cwnd +1]
} else {
set rtt1 $ro

[ns] how to remove floating point exception error

2012-05-06 Thread Muhammad Musaddiq

Respected Guys !
i am running snoop protocol in wireless scenario. i am getting floating point 
exception error. can anybody help me how can i remove this error. thanks alot 
kindly do reply quickly as this is the part of my project.

 
Regardz
Muhammad Musaddiq
+92-332-4197661


[ns] getting error in snoop

2012-04-25 Thread Muhammad Musaddiq



Regardz

Muhammad Musaddiq

+92-332-4197661

--- On Wed, 4/25/12, Muhammad Musaddiq  wrote:

From: Muhammad Musaddiq 
Subject: getting error in snoop
To: ns-users@isi.edu
Date: Wednesday, April 25, 2012, 10:40 PM

Guys this is the function which i make for snoop protocol, i am getting error 
which is below the code

set last_seqno 0.0
set rtt1 3
proc snoop {} {
global ns snoop1 current_seqno last_seqno rtt1 roundtriptime last_ack abc 
$snoop1 instvar snoopIn_ snoopOut_ snoopDrop_ queue_ head_
set time 0.1
set now [$ns now]
set current_seqno [$tcp1 set t_seqno_]
set last_ack [$tcp1 set ack_]
set roundtriptime [$tcp1 set rtt_]


if {$current_seqno > $last_seqno} {
if {[expr ($last_seqno +1)] == $current_seqno} {
set snoopIn_ $current_seqno
set snoopOut_ $current_seqno
if {$roundtriptime > $rtt1} {
set snoopOut_ $current_seqno
} else {
set snoopOut_ $current_seqno
set rtt1 $roundtriptime
}
} elseif {$current_seqno > $last_ack} {
set snoopOut_
 $current_seqno
} else {
set snoopDrop_ $current_seqno
}
if {[expr ($current_seqno - $last_seqno)] > 1} {
set snoopIn_ $current_seqno
set snoopOut_ $current_seqno
} else {
}
set last_seqno $current_seqno
} else {
set snoopOut_ $last_seqno
set abc [$tcp1 set nrexmitpack_]
puts "number of retransmission = [$tcp1 set nrexmitpack_]"
}

$ns at [expr $now + $time] "snoop"
}

Error is :


INITIALIZE THE LIST xListHead
warning: no class variable LanRouter::debug_

    see tcl-object.tcl in tclcl
 for info about this warning.

ns: snoop: can't read "snoop1": no such variable
    while executing
"$snoop1 instvar snoopIn_ snoopOut_ snoopDrop_ queue_ head_"
    (procedure "snoop" line 3)
    invoked from within
"snoop"

kindly reply me as soon as possible 
Regardz

Muhammad Musaddiq

+92-332-4197661


[ns] how to implement Snoop protocol

2012-04-25 Thread Muhammad Musaddiq



Regardz
Muhammad Musaddiq
+92-332-4197661

--- On Wed, 4/25/12, Muhammad Musaddiq  wrote:


From: Muhammad Musaddiq 
Subject: how to implement Snoop protocol
To: ns-users@isi.edu
Date: Wednesday, April 25, 2012, 2:43 AM







Respected guyz,
 
i want to implement snoop protocol in wireless scenario, can any one help me by 
sending snoop protocol tcl script. it would be great help. i am waiting for 
quick reply
 

Regardz
Muhammad Musaddiq
+92-332-4197661


[ns] issue regarding simulation of wireless scenario

2012-04-07 Thread Muhammad Musaddiq



Dear users,

 i am using NS 2.34 version,i have run some wired networks scenarios, they run 
properly,now i want to run wireless scenarios, the following script i have got 
from NS tutorial (website), after running this code ,i am getting some output 
description,but there is no NAM output when i run this code, the output 
description is pasted at the end of code. kindly plz anyone help me out about 
why there is no output nam??, i shall be very thankful..i am waiting for reply 
guyz
 
# ==
# Define options
# ==

set val(chan)   Channel/WirelessChannel
set val(prop)   Propagation/TwoRayGround
set val(netif)  Phy/WirelessPhy
set val(mac)    Mac/802_11
set val(ifq)    Queue/DropTail/PriQueue
set val(ll) LL
set val(ant)    Antenna/OmniAntenna
set val(x)  670   ;# X dimension of the topography
set val(y)  670   ;# Y dimension of the topography
set val(ifqlen) 50    ;# max packet in ifq
set val(seed)   0.0
set val(adhocRouting)   DSR
set val(nn) 3 ;# how many nodes are simulated
set val(cp) "../mobility/scene/cbr-3-test" 
set val(sc) "../mobility/scene/scen-3-test" 
set val(stop)   400.0   ;# simulation time

# =
# Main Program
# ==

#
# Initialize Global Variables
#

# create simulator instance

set ns_        [new Simulator]

# setup topography object

set topo    [new Topography]

# create trace object for ns and nam

set tracefd    [open wireless1-out.trw]
set namtrace    [open wireless1-out.nam w]

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

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

#
# Create God
#
set god_ [create-god $val(nn)]

#
# define how node should be created
#

#global node setting

$ns_ node-config -adhocRouting $val(adhocRouting) \
 -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 OFF \
 -macTrace OFF 

#
#  Create the specified number of nodes [$val(nn)] and "attach" them
#  to the channel. 

for {set i 0} {$i < $val(nn) } {incr i} {
    set node_($i) [$ns_ node]    
    $node_($i) random-motion 0        ;# disable random motion
}


# 
# Define node movement model
#
puts "Loading connection pattern..."
source $val(cp)

# 
# Define traffic model
#
puts "Loading scenario file..."
source $val(sc)

# Define node initial position in nam

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

    # 20 defines the node size in nam, must adjust it according to your scenario
    # The function must be called after mobility model is defined
    
    $ns_ initial_node_pos $node_($i) 20
}


#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at $val(stop).0 "$node_($i) reset";
}

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

puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(adhocRouting)"
puts $tracefd "M 0.0 sc $val(sc) cp $val(cp) seed $val(seed)"
puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)"

puts "Starting Simulation..."
$ns_ run

This is output description

num_nodes is set 2 
warning: Please use -channel as shown in
tcl/ex/wireless-mitf.tcl 
INITIALIZE THE LIST xListHead 
Starting Simulation... 
channel.cc:sendUp - Calc highestAntennaZ_ and
distCST_ 
highestAntennaZ_ = 1.5,  distCST_ = 550.0 
SORTING LISTS ...DONE! 
NS EXITING... 

Regardz
Muhammad Musaddiq


[ns] Fw: help

2012-04-07 Thread Muhammad Musaddiq



 
Regardz
Muhammad Musaddiq
Fa08-Bce-038
COMSATS Institute Of Information And Technology
0332-4197661

- Forwarded Message -
From: Muhammad Musaddiq 
To: "ns-users@isi.edu"  
Sent: Saturday, April 7, 2012 5:02 PM
Subject: help
 

Respected Users,
I am running the following code,i am getting error,the error which i am getting 
is at the end, can anyone help me out pleasekindly plz reply me as quickly 
as possible

# == 
# Define options 
# == 

set val(chan)   Channel/WirelessChannel 
set val(prop)   Propagation/TwoRayGround 
set val(netif)  Phy/WirelessPhy 
set val(mac)    Mac/802_11 
set val(ifq)    Queue/DropTail/PriQueue 
set
 val(ll) LL 
set val(ant)    Antenna/OmniAntenna 
set val(x)  670   ;# X dimension of the topography 
set val(y)  670   ;# Y dimension of the topography 
set val(ifqlen) 50    ;# max packet in ifq 
set val(seed)   0.0 
set val(adhocRouting)   DSR 
set val(nn) 3 ;# how many nodes are simulated 
set
 val(cp) "../mobility/scene/cbr-3-test" 
set val(sc) "../mobility/scene/scen-3-test" 
set val(stop)   400.0   ;# simulation time 

# = 
# Main Program 
# == 

# 
# Initialize Global Variables 
# 

# create simulator instance 

set ns_        [new Simulator] 

# setup topography object 

set topo    [new Topography] 

# create trace object for ns and nam 

set tracefd    [open wireless1-out.tr w] 
set namtrace    [open
 wireless1-out.nam w] 

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

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

# 
# Create God 
# 
set god_ [create-god $val(nn)] 

# 
# define how node should be created 
# 

#global node setting 

$ns_ node-config -adhocRouting $val(adhocRouting) \ 
 -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 OFF \ 
 -macTrace OFF 

# 
#  Create the specified number of nodes [$val(nn)] and "attach" them 
# 
 to the channel. 

for {set i 0} {$i < $val(nn) } {incr i} { 
    set node_($i) [$ns_ node]     
    $node_($i) random-motion 0        ;# disable random motion 
} 


# 
# Define node movement model 
# 
puts "Loading connection pattern..." 
source $val(cp) 

# 
# Define traffic model 
# 
puts "Loading scenario file..." 
source $val(sc) 

# Define node initial position in nam 

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

    # 20 defines the node size in nam, must adjust it according to your 
scenario 
    # The function must be called after mobility model is defined 
    
    $ns_ initial_node_pos $node_($i) 20 
} 


# 
# Tell nodes when the simulation ends 
# 
for {set i 0} {$i < $val(nn) } {incr i} { 
    $ns_ at $val(stop).0 "$node_($i) reset"; 
} 

$ns_ at  $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt" 
 
puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(adhocRouting)" 
puts $tracefd "M 0.0 sc $val(sc) cp $val(cp) seed $val(seed)" 
puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)" 

puts "Starting Simulation..." 
$ns_ run 


This is the error 


num_nodes is set 3 
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl 
INITIALIZE THE LIST xListHead 
Loading connection pattern... 
couldn't read file "../mobility/scene/cbr-3-test": no such file or directory 
    while executing 
"source.orig ../mobility/scene/cbr-3-test" 
    ("uplevel" body line 1) 
    invoked from within 
"uplevel source.orig [list $fileName]" 
    invoked from within 
"if [$instance_ is_http_url $fileName] { 
set buffer [$instance_ read_url $fileName] 
uplevel eval $buffer 
} else { 
uplevel source.orig [list $fileName] 
..." 
    (procedure "source" line 8) 
    invoked from within 
"source $val(cp)" 
    (file "simple-wireless1.tcl" line 121) 


 
Regardz
Muhammad Musaddiq