Пример #1
0
 def TXRSH(self, fsm):
     """TXRSH state; overloaded to send RSH prior to DATA."""
     assert DCF.isdot11data(self, self.datatosend), \
             "[RBAR]: Cannot determine 'datatosend' in TXUCAST!"
     assert not (self.datatosend.addr1==self.broadcast), \
             "[RBAR]: Cannot send broadcast 'datatosend' in TXUCAST!"
     # update rate annotation
     data = self.get_dot11data(self.datatosend)
     dst, src = data.addr1, data.addr2
     rate = self.ra.get_rate(dst)
     data.setanno('phy-rate', rate)
     if not self.usecsma:
         # send RSH before sending DATA
         rsh = self.dot11rsh(addr1=dst, addr2=src)
         self.send_rsh(rsh, self.datatosend)
         # recalculate NAV from new rate information
         nav = self.rshnav(self.datatosend)
         rsh.ID = nav
         pkt = crcupdate(rsh)
         # send and hold for duration
         rate, length = pkt[RAI].rate, pkt[RAI].length
         self.log("RSH", pkt, nav=nav, rate=rate, length=length)
         duration = self.duration(pkt)
         self.log_send(pkt, nav=nav)
         yield self.TXD.send(fsm, [pkt])
         yield hold, fsm, duration
         # pause for SIFS before continuing
         yield hold, fsm, self.sifs
     # go to DCF.TXUCAST state
     OLDSTATE = lambda *args, **kwargs: DCF.TXUCAST(self, *args, **kwargs)
     yield fsm.goto(OLDSTATE)
Пример #2
0
 def isdot11data(self, p):
     """Overloaded to check for DATA or RSH."""
     isdata = DCF.isdot11data(self, p)
     isrsh = self.isdot11rsh(p)
     return (isdata or isrsh)