Exemple #1
0
    def ctsnav(self, rts):
        """Overloaded to add RSH to NAV and apply rate adaptation..

        :param rts: RTS packet.
        :return: Integer; representing NAV value.

        This method uses `DCF.ctsnav()`, `calcrate()`, and `duration()` to
        calculate the new value of the CTS NAV.
        """
        ctsnav = DCF.ctsnav(self, rts)
        errmsg = "[RBAR]: Invalid RTS! No RAI found in ctsnav()!"
        assert rts.haslayer(RAI), errmsg
        errmsg = "[RBAR]: Cannot find 'phy-sinr' annotation in ctsnav()!"
        assert rts.hasanno('phy-sinr'), errmsg
        # calculate new rate from SINR
        sinr = rts.getanno('phy-sinr')
        newrate = self.calcrate(sinr)
        # extract info from RTS+RAI
        rai = rts[RAI]
        oldrate, length = rai.rate, rai.length
        # recompute NAV using length and new rate
        dold = self.duration(length, oldrate)
        dnew = self.duration(length, newrate)
        nav = ctsnav - int(dold*1e6) + int(dnew*1e6)
        return nav