コード例 #1
0
    def loop(self):
        """ Periodic job. """

        # otherwise apply the SDN@Play algorithm
        for block in self.blocks():

            for addr, entry in self.mcast_services.items():

                # fetch txp
                if addr not in block.tx_policies:
                    block.tx_policies[addr] = TxPolicy(addr, block)

                txp = block.tx_policies[addr]

                if self.mcast_policy == TX_MCAST_DMS_H:
                    txp.mcast = TX_MCAST_DMS
                    continue

                if self.mcast_policy == TX_MCAST_LEGACY_H:
                    txp.mcast = TX_MCAST_LEGACY
                    continue

                phase = self.get_next_group_phase(addr)

                self.log.info("Mcast phase %s for group %s", TX_MCAST[phase],
                              addr)

                # If the service is disabled, DMS must be the multicast mode
                if entry["status"] is False:
                    txp.mcast = TX_MCAST_DMS
                    continue

                if phase == TX_MCAST_DMS:

                    txp.mcast = TX_MCAST_DMS

                else:

                    # compute MCS
                    temp_mcs = self.calculate_group_mcs(entry["receivers"])

                    if block.band == BT_HT20:
                        mcs = max(temp_mcs, min(block.ht_supports))
                    else:
                        mcs = max(temp_mcs, min(block.supports))

                    entry['mcs'] = mcs
                    txp.mcast = TX_MCAST_LEGACY

                    if block.band == BT_HT20:
                        txp.ht_mcs = [mcs]
                    else:
                        txp.mcs = [mcs]

                    # assign MCS
                    self.log.info("Block %s setting mcast %s to %s MCS %d",
                                  block, addr, TX_MCAST[TX_MCAST_DMS], mcs)
コード例 #2
0
    def __assign_downlink(self, dl_block):
        """Set the downlink block."""

        # assign default tx policy to the downlink resource block
        txp = TxPolicy(self.addr, dl_block)

        # standard MCS (channel above 14 are the 11a modulations)
        if dl_block.channel > 14:
            txp.set_mcs([6.0, 9.0, 12.0, 18.0, 24.0, 36.0, 48.0, 54.0])
        else:
            txp.set_mcs([
                1.0, 2.0, 5.5, 11.0, 6.0, 9.0, 12.0, 18.0, 24.0, 36.0, 48.0,
                54.0
            ])

        # assign the HT MCS
        if self.ht_caps:
            txp.set_ht_mcs(
                [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
        else:
            txp.set_ht_mcs([])

        # assign the max AMSDU len
        if self.ht_caps and self.ht_caps_info['Maximum_AMSDU_Length']:
            txp.set_max_amsdu_len(TX_AMSDU_LEN_8K)
        elif self.ht_caps and not self.ht_caps_info['Maximum_AMSDU_Length']:
            txp.set_max_amsdu_len(TX_AMSDU_LEN_8K)
        else:
            txp.set_max_amsdu_len(0)

        # set tx policy
        dl_block.tx_policies[self.addr] = txp

        # send the message to set the tx policy
        dl_block.wtp.connection.send_set_tx_policy(txp)

        # send add_lvap message
        xid = \
            dl_block.wtp.connection.send_add_lvap_request(self, dl_block, True)

        self.pending.append(xid)

        # save block
        self._downlink = dl_block
コード例 #3
0
    def _handle_tx_policy_status_response(self, status):
        """Handle an incoming TX_POLICY_STATUS_RESPONSE message."""

        block = self.device.blocks[status.iface_id]
        addr = EtherAddress(status.sta)

        if addr not in block.tx_policies:
            block.tx_policies[addr] = TxPolicy(addr, block)

        txp = block.tx_policies[addr]

        txp.set_mcs([float(x) / 2 for x in status.mcs])
        txp.set_ht_mcs([int(x) for x in status.mcs_ht])
        txp.set_rts_cts(status.rts_cts)
        txp.set_max_amsdu_len(status.max_amsdu_len)
        txp.set_mcast(status.tx_mcast)
        txp.set_no_ack(status.flags.no_ack)

        self.log.info("TX policy status: %s", txp)