Thursday, October 7, 2010

Simulating wireless link errors

To attach the error model, add following codes to a TCL simulation script


..........
proc UniformErr {} {
                set err [new ErrorModel]
                $err unit packet
                $err set rate_ 0.05
                return $err
        }
        # $err rate_ 0.5  "invalid command ErrModel::Command does not support"
        # the other valid method is " set err [new ErrorModel/Uniform 0.05 pkt] "
        # the parameter rate ( 0 or 0.9) is a threshold that all packets all going through and 90% packets are
        # going to be drop

     proc TwoStateMarkovErr {} {

                set tmp0 [new ErrorModel/Uniform 0 pkt]
                set tmp1 [new ErrorModel/Uniform .7 pkt]

                 # Array of states (error models)
                set m_states [list $tmp0 $tmp1]
                 # Durations for each of the states, tmp, tmp1 and tmp2, respectively
                set m_periods [list 0.1 .075 ]
        # Transition state model matrix
        set m_transmx { {0.9   0.1 }
                        {0.7   0.3 } }
        set m_trunit byte
        # Use time-based transition
        set m_sttype time
        set m_nstates 2
        set m_nstart [lindex $m_states 0]

        set em [new ErrorModel/MultiState $m_states $m_periods $m_transmx \
                $m_trunit $m_sttype $m_nstates $m_nstart]
        return $em
    }

      $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  $chan1 \
                         -topoInstance $topo \
                         -agentTrace ON \
                         -routerTrace OFF\
                         -macTrace ON \
                         -movementTrace OFF \
                         -IncomingErrProc TwoStateMarkovErr
                         #\
                         #-OutcomingErrProc TwoStateMarkovErr

#The other way to configure error
#        $ns_ node-config --IncomingErrProc $opt(err)

1 comment:

Vinit Mahiwal said...

It gives error. Error model doesn't work with wireless network.