[ns] Snoop with 802.11 in wired-cum-wireless

Matina Georpopoulou matina at netmode.ntua.gr
Tue May 18 03:31:37 PDT 2004


Hello to all
 Has anyone managed to implement Snoop with 802.11 in wired-cum-wireless.
My script gives "segmentation fault"    with 802.11 and snoop . It works 
fine with 802.11 without snoop and snoop works fine with 802.3.
I figured the bug is inside the .cc file but I am a bit lost ...
any sugestions ?
I attach my tcl please take the truble to take a look
I would apreciate any comment
can anyone help?
--Matina--
-------------- next part --------------
# A few colors...
set palette [list red green blue yellow orange brown pink grey black \
        snow ghost GhostWhite white WhiteSmoke gainsboro floral \
        FloralWhite gold OldLace linen antique AntiqueWhite papaya \
        PapayaWhip blanched BlanchedAlmond bisque peach PeachPuff \
        navajo NavajoWhite moccasin cornsilk ivory lemon LemonChiffon \
        seashell honeydew mint MintCream azure alice AliceBlue lavender \
        lavender LavenderBlush misty MistyRose white black dark \
        blue2 blue3 blue4 DodgerBlue1 \
        DodgerBlue2 DodgerBlue3 DodgerBlue4 SteelBlue1 SteelBlue2 \
        SteelBlue3 SteelBlue4 DeepSkyBlue1 \
        DeepSkyBlue2 DeepSkyBlue3 DeepSkyBlue4 SkyBlue1 SkyBlue2 SkyBlue3 \
        SkyBlue4 LightSkyBlue1]
#########################################################################################################################
# TCP configuration Parameters 
#**********Things to play with********
#########################################################################################################################
#########################################################################################################################
Agent/TCP set window_               	50              ;# max bound on window size                         #
# Agent/TCP set windowInit_              1              ;# initial/reset value of cwnd                          #
# Agent/TCP set windowOption_            1              ;# cong avoid algorithm (1: standard)                       #
# Agent/TCP set windowConstant_          4              ;# used only when windowOption != 1                     #
# Agent/TCP set windowThresh_            0.002           ;# used in computing averaged window                        #
# Agent/TCP set overhead_                0              ;# !=0 adds random time between sends                       #
#Agent/TCP set ecn_                   	1               ;# TCP should react to ecn bit                          #
Agent/TCP set packetSize_           	1500            ;# packet size used by sender (bytes)                       #
# Agent/TCP set bugFix_                 true            ;# see explanation                                  #
# Agent/TCP set slow_start_restart_     true            ;# see explanation                                  #
# Agent/TCP set tcpTick_                 0.1             ;# timer granulatiry in sec (.1 is NONSTANDARD)                 #
# Agent/TCP set maxrto_                 64              ;# bound on RTO (seconds)                               #
# Agent/TCP set dupacks_                 0              ;# duplicate ACK counter                                #
# Agent/TCP set ack_                    0               ;# highest ACK received                             #
# Agent/TCP set cwnd_                   0               ;# congestion window (packets)                          #
# Agent/TCP set awnd_                   0               ;# averaged cwnd (experimental)                         #
# Agent/TCP set ssthresh_                0              ;# slow-stat threshold (packets)                            #
# Agent/TCP set rtt_                    0               ;# rtt sample                                       #
# Agent/TCP set srtt_                   0               ;# smoothed (averaged) rtt                              #
# Agent/TCP set rttvar_                 0               ;# mean deviation of rtt samples                            #
# Agent/TCP set backoff_                 0              ;# current RTO backoff factor                           #
# Agent/TCP set maxseq_                 0               ;# max (packet) seq number sent                         #
#########################################################################################################################



# ======================================================================
# Define options for wireless
# ======================================================================

set option(chan)            Channel/WirelessChannel     ;#channel type
set option(prop)            Propagation/TwoRayGround    ;#radio-propagation modl
set option(netintf)         Phy/WirelessPhy             ;#network interface
set option(mac)             Mac/802_11                  ;#Mac type
set option(intfq)           Queue/DropTail     ;#interface Queue type
set option(ll)                  LL/LLSnoop                     ;#link layer type
set option(ant)             Antenna/OmniAntenna         ;#antenna model
set option(qlen)                10                      ;#max packet in Queue
set option(adhocRouting)       DSDV                     ;#routing protocol DSDV/
set option(x)                   500                 ;#
set option(y)                   500                 ;#
set option(nodenum)             2                   ;#number of mobilenodes
#set option(cp)                 "cbr-3-test"        ;#connection pattern file
set option(cp)                  ""                  ;#cp file not used
set option(sc)                  ""                  ;#scenario file not used
set option(seed)                0.0                 ;#starting value for random-number-generator
set option(stop)                300.1               ;#simulation time

# =================================================================
## Default settings
#==================================================================

##############################################
####***********Bandwidth******************####
##############################################

Mac/802_11 set bandwidth_ 10e6

################################################
####***********PACKET LOSS******************####
################################################

set pk_loss_rate    0.01

##############################################
####***********FILE SIZE******************####
##############################################

set file_size       100000

########################################################
####***********SCENARIO AND FLAVOR******************####
########################################################
#values : newreno,reno,sack,fack,vegas
set scenario snoop	
set flavor reno

##########################################
####****Bandwitdth & delay (LINKS)****####
##########################################
set bw_ter  20Mb
set dl_ter  10ms




#Number of nodes and connections
set num_wired_nodes     1
set num_bs_nodes        1
set connections [expr $option(nodenum)]

#==================================================================
## check for boundary parameters and random seed
#==================================================================

if { $option(x) == 0 || $option(y) == 0 } {
    puts "No X-Y boundary values given for wireless topology\n"
}
if {$option(seed) > 0} {
    puts "Seeding Random number generator with $option(seed)\n"
    ns-random $option(seed)
}

#==================================================================
# create simulator instance
#==================================================================
set ns   [new Simulator]
#source file
source script_trace.tcl

#==================================================================
##set up for hierarchical routing
#==================================================================

$ns node-config -addressType hierarchical

AddrParams set domain_num_  2                  ;#number of domains 1-wired 1-wireless
lappend second_level        1 1                ;#number of clusters 2-wired 1-wireles
AddrParams set cluster_num_     $second_level
;#number of nodes in each cluster of each domain 1 - wired kai 2- wireless
lappend last_level          [expr $num_wired_nodes] [expr $option(nodenum)+ $num_bs_nodes]    
AddrParams set nodes_num_   $last_level


#==================================================================
#trace & nam files
#==================================================================

create_trace_files $connections         ;#go to script_trace for explanation  
$ns use-newtrace                        ;# To trace gia auto brisketai kefalaio 16
$ns trace-all       $hn_tr_all          
$ns namtrace-all $hn_nam
$ns namtrace-all-wireless $hn_nam $option(x) $option(y)

#==================================================================
# Create topography object
#==================================================================

set topo [new Topography]


#==================================================================
# define topology
#==================================================================

$topo load_flatgrid $option(x) $option(y)


#==================================================================
# create God --->>General Operations Director 
#==================================================================

create-god [expr $option(nodenum)+ $num_bs_nodes]

#==================================================================
##create wired nodes
#==================================================================
set temp {0.0.0}                 ;# hierarchical addresses for wired domain

for {set i 0} {$i < $num_wired_nodes} {incr i} {
    set W($i) [$ns node [lindex $temp $i]] 
    puts "Wired Node: $W($i) Addr: [$W($i) node-addr]"

}
#==================================================================
# configure for base-station node
#==================================================================

$ns node-config -adhocRouting       $option(adhocRouting) \
                    -llType         $option(ll) \
                    -macType        $option(mac) \
                    -ifqType        $option(intfq) \
                    -ifqLen         $option(qlen) \
                    -antType        $option(ant) \
                    -propType       $option(prop) \
                    -phyType        $option(netintf) \
                    -topoInstance   $topo \
                    -channel        [new $option(chan)]\
                    -wiredRouting   ON \
                    -agentTrace     OFF \
                    -routertrace    OFF \
                    -macTrace       ON

                 

#==================================================================
##create base-station node
#==================================================================
set temp {1.0.0}                            ;# hier address to be used for wireless domain

set BS(0) [$ns node [lindex $temp 0]]
$BS(0) random-motion 0                      ;# disable random motion
puts "base station addr: [$BS(0) node-addr]"

#==================================================================
#provide some co-ord (fixed) to base station node
#==================================================================

$BS(0) set X_ 1.0
$BS(0) set Y_ 2.0
$BS(0) set Z_ 0.0

#==================================================================
# create mobilenodes in the same domain as BS(0)  
# note the position and movement of mobilenodes is not defined
# in $option(sc)because we chose not to use it
#==================================================================

#========================================
#configure for mobilenodes
#========================================

$ns node-config -wiredRouting   OFF \
                -ifqType        $option(intfq)

#========================================
#create mobilenodes
#========================================

 for {set j 0} {$j < $option(nodenum)} {incr j} {
    set node_($j) [$ns node 1.0.[expr $j +1]]
    $node_($j) base-station [AddrParams addr2id \ [$BS(0) node-addr]]
    puts "Wireless Node: $node_($j) Addr: [$node_($j) node-addr]"
 }
 
$ns initial_node_pos $node_(0) 20

#####################################################################
#ERROR MODELS
#####################################################################
#====================================
# Loss configuration
#====================================


set loss [new ErrorModel]
$loss set rate_ $pk_loss_rate
$loss unit pkt
$loss ranvar [new RandomVariable/Uniform]
$loss drop-target [new Agent/Null]

#==================================================================
# setup TCP connections
#==================================================================

##################################################
#LINKS AND AGENTS
##################################################

#==================================================================
#create links between wired and BS nodes
#==================================================================

$ns duplex-link $W(0) $BS(0) $bw_ter $dl_ter DropTail
$ns duplex-link-op $W(0) $BS(0) orient left-down


#
#variables to trace on connections
#########################################

set trace_vars [list cwnd_ dupacks_ rtt_ srtt_ rttvar_  maxseq_ ack_ ssthresh_ ndatapack_ ndatabytes_ curseq_ nackpack_ nrexmit_ nrexmitpack_ nrexmitbytes_ backoff_ seqno_]
#trace_vars options:    
#cwnd_          congestion window
#dupacks_       ;# Number of duplicate acks seen since any new data was acknowledged
#rtt_           ;# Round Trip Time
#srtt_          ;# smoothed Round Trip Time
#rttvar_        ;# Round Trip Time mean deviation estimate
#maxseq_        ;# max (packet) seq number sent
#ack_           ;# Highest acknowledgment seen from receiver
#ssthresh_      ;# slow start threshold
#ndatapack_     ;# number of data packets sent 
#ndatabytes_    ;# number of data bytes sent
#curseq_        ;# highest seqno "produced by app"
#nackpack_      ;# number of ack packets received
#nrexmit_       ;# number of retransmit timeouts when there was data outstanding 
#nrexmitpack_   ;# number of retransmited packets 
#nrexmitbytes_  ;# number of retransmited bytes
#backoff_       ;# current multiplier, 1 if not backed off
#seqno_         ;# sequence number


# Agents  #
#=========#
for {set i 0} {$i < $connections} {incr i} {

        if {$flavor == "newreno"} {
            set ag_tcp_snd($i) [new Agent/TCP/Newreno]
            set ag_tcp_rcv($i) [new Agent/TCPSink/DelAck]
        } elseif {$flavor == "reno"} {
            set ag_tcp_snd($i) [new Agent/TCP/Reno]
            set ag_tcp_rcv($i) [new Agent/TCPSink/DelAck]
        } elseif {$flavor == "sack"} {
            set ag_tcp_snd($i) [new Agent/TCP/Sack1]
            set ag_tcp_rcv($i) [new Agent/TCPSink/Sack1/DelAck]
        } elseif {$flavor == "fack"} {
            set ag_tcp_snd($i) [new Agent/TCP/Fack]
            set ag_tcp_rcv($i) [new Agent/TCPSink]
        } elseif {$flavor == "vegas"} {
            set ag_tcp_snd($i) [new Agent/TCP/Vegas]
            set ag_tcp_rcv($i) [new Agent/TCPSink]
        }
 

        $W(0) attach $ag_tcp_snd($i)
        $node_($i) attach $ag_tcp_rcv($i)
        
        $ns connect $ag_tcp_snd($i) $ag_tcp_rcv($i)
        $ag_tcp_rcv($i) listen
        $ag_tcp_snd($i) set fid_ $i
        $ns color $i [lindex $palette $i]

        ;#start sending the file 
#        $ns at [expr 10.0 + 2*$i] "$ag_tcp_snd($i) send $file_size"
        ;# Attach trace on agents for every variable in trace_vars
        $ag_tcp_snd($i) attach-trace $hn_tr_tcp_snd($i)
        for {set j 0} {$j < [llength $trace_vars]} {incr j} {
                $ag_tcp_snd($i) trace [lindex $trace_vars $j]
        }
}



#=======================================================================
# source connection-pattern and node-movement scripts  ********not used
#=======================================================================
if { $option(cp) == "" } {
    puts "*** NOTE: no connection pattern specified."
        set option(cp) "none"
} else {
    puts "Loading connection pattern..."
    source $option(cp)
}
if { $option(sc) == "" } {
    puts "*** NOTE: no scenario file specified."
        set option(sc) "none"
} else {
    puts "Loading scenario file..."
    source $option(sc)
    puts "Load complete..."
}
################################################################################
#==============================================================================
# END the simulation
#==============================================================================
proc finish {} {
    global ns
    global connections
    global trace_vars
    
    $ns flush-trace
    close_trace_files $connections
    process $connections $trace_vars
    exit 0
}
###############################################################################
# Initial Events
for {set i 0} {$i < $connections} {incr i} {
	set conn_file_size [expr ($i+1)*$file_size/100]
	puts "Connection $i transfers $file_size bytes..."
	$ns at [expr 2.0 + 2*$i] "$ag_tcp_snd($i) send $file_size"
}

$ns at $option(stop) "finish"


puts "Starting Simulation..."
$ns run


More information about the Ns-users mailing list