wmac
wmac

Reputation: 1063

NS2, packets larger than 100 byte are dropped on 802.15.4

I have a simple 802.15.4 simulation program (2 nodes, CBR traffic).

If the size of CBR packets are less than 100, the packets are delivered without problem but as soon as you increase the packet size all packets are dropped.

I guess it is because the fragmentation does not happen by default (the maximum size on 802.15.4 is 127 octets). Is that true? How should I fix my simulation program (as I think the fragmentation happens in real world)?

set val(chan)          Channel/WirelessChannel      ;# channel type
set val(prop)          Propagation/TwoRayGround     ;# radio-propagation model
set val(netif)         Phy/WirelessPhy/802_15_4     ;# network interface type
set val(mac)           Mac/802_15_4                 ;# 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)        100                             ;# max packet in ifq
set val(nn)            2                            ;# number of mobilenodes
set val(rp)            AODV                            ;# protocol tye
set val(x)             40                            ;# X dimension of topography
set val(y)             40                            ;# Y dimension of topography
set val(stop)          500                            ;# simulation period
set val(energymodel)   EnergyModel                    ;# Energy Model
set val(initialenergy) 100                            ;# value

set ns                [new Simulator]
set tracefd           [open aodv1.tr w]
set namtrace          [open aodv1.nam w]

$ns use-newtrace
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(40m)
Phy/WirelessPhy set RXThresh_ $dist(40m)


# set up topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

# configure the nodes
$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 [new $val(chan)] \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace OFF \
             -macTrace  OFF \
             -movementTrace OFF \
             -energyModel $val(energymodel) \
             -initialEnergy $val(initialenergy) \
             -rxPower 35.28e-3 \
             -txPower 31.32e-3 \
         -idlePower 712e-6 \
         -sleepPower 144e-9

             #-IncomingErrProc MultistateErrorProc \
             #-OutgoingErrProc MultistateErrorProc

for {set i 0} {$i < $val(nn) } { incr i } {
        set mnode_($i) [$ns node]
}



for {set i 1} {$i < $val(nn) } { incr i } {
    $mnode_($i) set X_ [ expr {$val(x) * rand()} ]
    $mnode_($i) set Y_ [ expr {$val(y) * rand()} ]
    $mnode_($i) set Z_ 0
}

# Position of Sink
$mnode_(0) set X_ [ expr {$val(x)/2} ]
$mnode_(0) set Y_ [ expr {$val(y)/2} ]
$mnode_(0) set Z_ 0.0
$mnode_(0) label "Sink"


for {set i 0} {$i < $val(nn)} { incr i } {
    $ns initial_node_pos $mnode_($i) 10
}


#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $mnode_(1) $udp

set sink [new Agent/Null]
$ns attach-agent $mnode_(0) $sink

$ns connect $udp $sink
$udp set fid_ 2

#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 100
$cbr set rate_ 0.1Mb
$cbr set interval_ 2
#$cbr set random_ false

$ns at 5.0 "$cbr start"
$ns at [expr $val(stop) - 5] "$cbr stop"

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "$mnode_($i) reset;"
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at [expr $val(stop) + 0.01] "puts \"end simulation\"; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
}

$ns run

Upvotes: 2

Views: 2479

Answers (1)

Naveen.S
Naveen.S

Reputation: 750

Check the below tcl..

set val(chan)          Channel/WirelessChannel      ;# channel type
set val(prop)          Propagation/TwoRayGround     ;# radio-propagation model
set val(netif)         Phy/WirelessPhy/802_15_4     ;# network interface type
set val(mac)           Mac/802_15_4                 ;# 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)        100                             ;# max packet in ifq
set val(nn)            2                            ;# number of mobilenodes
set val(rp)            AODV                            ;# protocol tye
set val(x)             40                            ;# X dimension of topography
set val(y)             40                            ;# Y dimension of topography
set val(stop)          500                            ;# simulation period
set val(energymodel)   EnergyModel                    ;# Energy Model
set val(initialenergy) 100                            ;# value

set ns                [new Simulator]
set tracefd           [open aodv1.tr w]
set namtrace          [open aodv1.nam w]

$ns use-newtrace
$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 $val(nn)

# configure the nodes
$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 [new $val(chan)] \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace ON \
             -macTrace  ON \
             -movementTrace OFF \
             -energyModel $val(energymodel) \
             -initialEnergy $val(initialenergy) \
             -rxPower 35.28e-3 \
             -txPower 31.32e-3 \
         -idlePower 712e-6 \
         -sleepPower 144e-9

             #-IncomingErrProc MultistateErrorProc \
             #-OutgoingErrProc MultistateErrorProc

for {set i 0} {$i < $val(nn) } { incr i } {
        set mnode_($i) [$ns node]
}



for {set i 1} {$i < $val(nn) } { incr i } {
    $mnode_($i) set X_ [ expr {$val(x) * rand()} ]
    $mnode_($i) set Y_ [ expr {$val(y) * rand()} ]
    $mnode_($i) set Z_ 0
}

# Position of Sink
$mnode_(0) set X_ [ expr {$val(x)/2} ]
$mnode_(0) set Y_ [ expr {$val(y)/2} ]
$mnode_(0) set Z_ 0.0
$mnode_(0) label "Sink"


for {set i 0} {$i < $val(nn)} { incr i } {
    $ns initial_node_pos $mnode_($i) 10
}


#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $mnode_(1) $udp

set sink [new Agent/Null]
$ns attach-agent $mnode_(0) $sink

$ns connect $udp $sink

#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packet_size_ 10000
$cbr set rate_ .1Mb
$cbr set interval_ .2
#$cbr set random_ false

$ns at 5.0 "$cbr start"


# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at 20 "stop"

proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
exec nam aodv1.nam
}

$ns run

Upvotes: 2

Related Questions