Hidden Terminal Problem

 

In this report, I just show the script to demonstrate the hidden terminal problem and how to use RTS/CTS to alleviate this effect. More information about hidden terminal can be found on the Internet.

 

(file name: hidden.tcl)

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(rp) DumbAgent

 

set ns [new Simulator]

 

Mac/802_11 set RTSThreshold_    3000

 

Antenna/OmniAntenna set X_ 0

Antenna/OmniAntenna set Y_ 0

Antenna/OmniAntenna set Z_ 1.5

Antenna/OmniAntenna set Gt_ 1.0

Antenna/OmniAntenna set Gr_ 1.0

 

Phy/WirelessPhy set CPThresh_ 10.0

#Phy/WirelessPhy set CSThresh_ 1.559e-11

Phy/WirelessPhy set CSThresh_ 5.659e-11

Phy/WirelessPhy set RXThresh_ 3.652e-10

Phy/WirelessPhy set bandwidth_ 2e6

Phy/WirelessPhy set Pt_ 0.28183815

Phy/WirelessPhy set freq_ 914e+6

Phy/WirelessPhy set L_ 1.0 

 

set f [open test.tr w]

$ns trace-all $f

$ns eventtrace-all

set nf [open test.nam w]

$ns namtrace-all-wireless $nf 500 500

 

# set up topography object

set topo       [new Topography]

$topo load_flatgrid 500 500

 

# Create God

create-god 3

 

# create channel

set chan [new $val(chan)]

 

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

                -channel $chan \

                -topoInstance $topo \

                -agentTrace ON \

                -routerTrace OFF \

                -macTrace ON \

                -movementTrace OFF

 

for {set i 0} {$i < 3} {incr i} {

        set node_($i) [$ns node]

        $node_($i) random-motion 0

}

 

$node_(0) set X_ 30.0

$node_(0) set Y_ 30.0

$node_(0) set Z_ 0.0

 

$node_(1) set X_ 200.0

$node_(1) set Y_ 30.0

$node_(1) set Z_ 0.0

 

$node_(2) set X_ 450.0

$node_(2) set Y_ 30.0

$node_(2) set Z_ 0.0

 

set udp [new Agent/mUDP]

#set the sender trace file name to sd

$udp set_filename sd1

$ns attach-agent $node_(0) $udp

set null [new Agent/mUdpSink]

#set the receiver filename to rd

$null set_filename rd1

$ns attach-agent $node_(1) $null

$ns connect $udp $null

 

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set type_ CBR

$cbr set packet_size_ 1000

$cbr set rate_ 1Mb

$cbr set random_ false

$ns at 0.0 "$cbr start"

$ns at 15.0 "$cbr stop"

 

set udp2 [new Agent/mUDP]

$udp2 set_filename sd2

$ns attach-agent $node_(2) $udp2

set null2 [new Agent/mUdpSink]

$null2 set_filename rd2

$ns attach-agent $node_(1) $null2

$ns connect $udp2 $null2

 

set cbr2 [new Application/Traffic/CBR]

$cbr2 attach-agent $udp2

$cbr2 set type_ CBR

$cbr2 set packet_size_ 1000

$cbr2 set rate_ 1Mb

$cbr2 set random_ false

$ns at 1.0 "$cbr2 start"

$ns at 15.0 "$cbr2 stop"

 

for {set i 0} {$i < 3} {incr i} {

        $ns initial_node_pos $node_($i) 30

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

}

 

$ns at 20.0 "finish"

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

 

#INSERT ANNOTATIONS HERE

proc finish {} {

        global ns f nf val

        $ns flush-trace

        close $f

        close $nf

}

 

puts "Starting Simulation..."

$ns run

 

 

l          Without RTS/CTS

$ns hidden.tcl

 

After simulation, there are four files, i.e. sd1, rd1, sd2, rd2, generated. “sd” is sender trace file and “rd” is the receiver trace file. From “sd1”, node0 sends out 1876 packets. From “rd1”, node1 receives 200 packets. From “sd2”, node 2 sends out 1751 packets. From “rd2”, node1 receives 88 packets.

 

l          With RTS/CTS

Before running the simulation, change “Mac/802_11 set RTSThreshold_    3000” to “Mac/802_11 set RTSThreshold_    0” to enable RTS/CTS.

$ns hidden.tcl

 

From “sd1”, node0 sends out 1876 packets. From “rd1”, node1 receives 855 packets. From “sd2”, node 2 sends out 1751 packets. From “rd2”, node1 receives 751 packets. The simulation results show that the RTS/CTS can alleviate the hidden terminal problem.

 

Reference

http://www.cse.iitd.ernet.in/~csu02122/gatechns-sol.pdf

 

 

Last modified date: 2006/05/11

 

Author: Chih-Heng Ke (柯志亨)

Email: smallko@ee.ncku.edu.tw