I want to simulate a wired-cum wireless scenario adding FEC, ARQ
functionality to the wireless environment. Please help me in any of these
topics :

   1. I added uniform error model to my mobile nodes configuration, I can
   not get any dropped packets. I am using *cat
mixed.tr<http://pastebin.com/f1cf95ae0>| grep d
   * to search for dropped packets in the trace file. I can not  get any
   dropped packets
   2. I tried to attach flow monitor to tcp flow because I want to measure
   the dropped packets, but it seems that attach-fmon wants a link which is not
   available in the wireless based flows, how can I use that flow monitor for
   wireless flows??? The flow monitor section is commented to make the script
   working. The attach-fmon is not working :(
   3. I want to add sequential decoding algorithm [FEC algorithm] to the
   link layer, I want also to implement ARQ in the Link layer [MAC 802.11]. I
   am not sure what is possible to do and what is not ? Any idea how can I
   start ? and where to find resources ?

*Please reply, Your reply will help me a lot.*
My current code.

### This simulation is an example of combination of wired and wireless
### topologies.
#-------------------------------------------------------------------------------
#defining a new hashtable to store values
global opt
set adhocRouting   DSDV
set stop           350
set num_wired_nodes      1
set num_bs_nodes         1
set num_wireless_nodes             2
set x    300
set y    300
#-------------------------------------------------------------------------------

proc plotWindow { tcpSource file } {
global ns_
set time 0.1
set now [$ns_ now]
set cwnd [$tcpSource set cwnd_]
set wnd [$tcpSource set window_]
puts $file "$now $cwnd"
$ns_ at [expr $now+$time] "plotWindow $tcpSource $file"
}

proc wireless_node_config { ns topo em } {
  $ns node-config -adhocRouting DSDV \
                 -llType LL \
                 -macType Mac/802_11 \
                 -ifqType Queue/DropTail/PriQueue \
                 -ifqLen 50 \
                 -antType Antenna/OmniAntenna \
                 -propInstance [new Propagation/TwoRayGround] \
                 -phyType Phy/WirelessPhy \
                 -channel [new Channel/WirelessChannel] \
                 -topoInstance $topo \
                 -wiredRouting ON \
                 -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
                 -outgoingErrProc $em \
                 -incomingErrProc $em

}

proc nam {ns namFile trFile namOutFile} {
    $ns flush-trace
    close $namFile
    close $trFile
    puts "running nam..."
#    exec nam $namOutFile &
    puts "I am in nam"
}
proc finish { } {
    exit 0
}
#-------------------------------------------------------------------------------
# The global simulator instance
set ns_   [new Simulator]
#-------------------------------------------------------------------------------
#Hierarchical routing is needed to in mixed environments
#each of wireless and wired environment must be in seperated domains
#so at least we want 2 domains

# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2
lappend cluster_num 1 2
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 2
AddrParams set nodes_num_ $eilastlevel
#-------------------------------------------------------------------------------
#set the Topology
set topo   [new Topography]
$topo load_flatgrid x y

# god needs to know the number of all wireless interfaces
create-god [expr $num_wireless_nodes+$num_wired_nodes]
#-------------------------------------------------------------------------------
#trace output file
set trFile  [open mixed.tr w]
$ns_ trace-all $trFile

# nam output files
set namFile [open mixed.nam w]
$ns_ namtrace-all $namFile
$ns_ namtrace-all-wireless $namFile x y

#xgraph output files
set x0 [open xgraph0.tr w]

#flow monitor trace
set flowFile [open flowfile w]
#extra files
set cwndFile [open cwndFile.wtc w]
#-------------------------------------------------------------------------------
#Define different colors for data flows (for NAM)
$ns_ color 1 Blue
$ns_ color 2 Red
$ns_ color 3 Green
#-------------------------------------------------------------------------------
#creating the error model
set m1_ubstate 27.0
set m1_bstate 12.0
set m2_ubstate 0.4
set m2_bstate 0.4
set durlist "$m1_ubstate $m1_bstate $m2_ubstate $m2_bstate"
#set em [new ErrorModel/ComplexTwoStateMarkov $durlist time]
set em [new ErrorModel]
$em unit bit
$em ranvar [new RandomVariable/Uniform]
$em set rate_ 0.1
$em drop-target [new Agent/Null]
#$em drop-target [new Agent/Null]

#the option below is for wired links, there is no links in wireless
environment

#$ns_ link-lossmodel $loss_module $BS(0) $node_(0)
#-------------------------------------------------------------------------------
#Creating the nodes

    # The wired nodes
set addresses {0.0.0 1.0.0 1.1.0 1.1.1}
set W(0) [$ns_ node [lindex $addresses 0]]
    #The wireless nodes
wireless_node_config $ns_ $topo $em
#-------------------------------------------------------------------------------
set BS(0) [$ns_ node [lindex $addresses 1]]


$ns_ node-config -wiredRouting OFF
        #base stations nodes
$BS(0) random-motion 0

        #mobile nodes
  for {set j 0} {$j < [expr $num_wired_nodes + $num_bs_nodes]} {incr j} {
    set node_($j) [ $ns_ node [lindex $addresses [expr $j+2]] ]
    #attach nodes to base station
    $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]
  }

# End Creating the Nodes
#-------------------------------------------------------------------------------
# Positioning the nodes
  $BS(0) set X_ 50.0
  $BS(0) set Y_ 50.0
  $BS(0) set Z_ 0.0
  $node_(0) set X_ 0.0
  $node_(0) set Y_ 0.0
  $node_(0) set Z_ 0.0
  $node_(1) set X_ 100.0
  $node_(1) set Y_ 0.0
  $node_(1) set Z_ 0.0
#-------------------------------------------------------------------------------
#create links between wired and BS nodes
$ns_ duplex-link $W(0) $BS(0) 2Mb 2ms DropTail down
$ns_ duplex-link-op $W(0) $BS(0) orient down
$ns_ queue-limit $W(0) $BS(0) 2020Mb
#$ns_ duplex-link-op $W(0) $BS(0) queuePos 0.5
#-------------------------------------------------------------------------------

#Sizing the mobile nodes this will make them appear in NAM
for {set i 0} {$i < $num_wireless_nodes} {incr i} {
      $ns_ initial_node_pos $node_($i) 10
   }
#-------------------------------------------------------------------------------
# setup TCP connections
  set tcp1 [new Agent/TCP/Newreno]
  $tcp1 set class_ 2
  $tcp1 set fid_ 1
  set sink1 [new Agent/TCPSink/DelAck]
  $ns_ attach-agent $W(0) $tcp1
  $ns_ attach-agent $node_(0) $sink1
  $ns_ connect $tcp1 $sink1
  set ftp1 [new Application/FTP]
  $ftp1 attach-agent $tcp1
#-------------------------------------------------------------------------------
# The flow monitor
#set fmon [$ns_ makeflowmon Fid]
#set wllink [$ns_ link $node_(0) $BS(0)]
#$ns_ attach-fmon $wllink $fmon
#$fmon attach $flowFile
#-------------------------------------------------------------------------------
#time line scenario.
$ns_ at 1.5 "$ftp1 start"
$ns_ at [expr $stop-10] "$ftp1 stop"

#reset nodes after finishing
for {set i 0} {$i < $num_wireless_nodes } {incr i} {
      $ns_ at $stop.000000 "$node_($i) reset";
  }
$ns_ at $stop.000000 "$BS(0) reset";

puts "Starting Simulation..."
$ns_ at 0.1 "plotWindow $tcp1 $cwndFile"
$ns_ at $stop.1 "nam $ns_ $namFile $trFile mixed.nam"
$ns_ at $stop.2 "finish"
#-------------------------------------------------------------------------------
$ns_ run


-- 
Ramy Eid

Reply via email to