示例#1
0
    def __init__(self,
                 iface,
                 log_directory,
                 cw_init,
                 beta,
                 k,
                 cw_min=0,
                 cw_max=1023,
                 enable_react=True):
        super(QueueTuner, self).__init__(iface, '')

        self.log_directory = log_directory
        self.qos_logfile = open(f'{log_directory}/qos_react.csv', 'w')
        self.be_logfile = open(f'{log_directory}/be_react.csv', 'w')

        self.cr_observer = CollisionRateObserver(iface)

        self.cw_min = cw_min
        self.cw_max = cw_max

        self.k = k
        self.beta = beta
        self.cw_prev_be = cw_init
        self.cw_prev_qos = cw_init
        self.smooth_be = None
        self.smooth_qos = None

        self.enable_react = enable_react
示例#2
0
    def __init__(self, iface, log_file, cw_init):
        super(TunerCollisionRate, self).__init__(iface, log_file)

        self.cr_observer = CollisionRateObserver(iface)
        self.ao = AirtimeObserver(iface)

        self.set_cw(cw_init)
        self.cw_prev = cw_init
class QueueTuner(TunerBase):

    def __init__(self, iface, log_directory, cw_init, beta, k, cw_min=0, cw_max=1023, enable_react=True):
        super(QueueTuner, self).__init__(iface, '')

        self.log_directory = log_directory
        self.qos_logfile = open(f'{log_directory}/qos_react.csv', 'w')
        self.be_logfile = open(f'{log_directory}/be_react.csv', 'w')

        self.cr_observer = CollisionRateObserver(iface)

        self.cw_min = cw_min
        self.cw_max = cw_max

        self.k = k
        self.beta = beta
        self.cw_prev_be = cw_init
        self.cw_prev_qos = cw_init
        self.smooth_be = None
        self.smooth_qos = None

        self.enable_react= enable_react

    def update_cw_queues(self, be_alloc, be_airtime, qos_alloc, qos_airtime):
        if self.enable_react:
            if self.smooth_be is None:
                self.smooth_be = be_airtime
            else:
                self.smooth_be = self.beta*be_airtime + (1.0 - self.beta) * self.smooth_be

            if self.smooth_qos is None:
                self.smooth_qos = qos_airtime
            else:
                self.smooth_qos = self.beta*qos_airtime + (1.0 - self.beta) * self.smooth_qos

            cw_be = int((self.smooth_be - be_alloc) * self.k) + self.cw_prev_be
            print(f'self.cw_min: {self.cw_min}, cw_be: {cw_be}')
            cw_be = self.cw_min if cw_be < self.cw_min else cw_be
            cw_be = self.cw_max if cw_be > self.cw_max else cw_be

            cw_qos = int((self.smooth_qos - qos_alloc) * self.k) + self.cw_prev_qos
            cw_qos = self.cw_min if cw_qos < self.cw_min else cw_qos
            cw_qos = self.cw_max if cw_qos > self.cw_max else cw_qos

            self.set_cw(cw_be, qumID=1, aifs=3)
            self.set_cw(cw_qos, qumID=2, aifs=2)

            self.log(be_alloc, be_airtime, self.cw_prev_be, cw_be, self.cr_observer.collision_rate(), 2, log_file=self.be_logfile)
            self.log(qos_alloc, qos_airtime, self.cw_prev_qos, cw_qos, self.cr_observer.collision_rate(), 2, log_file=self.qos_logfile)
            self.cw_prev_be = cw_be
            self.cw_prev_qos = cw_qos
        else:
            self.log(be_alloc, be_airtime, -1, -1, self.cr_observer.collision_rate(), 2, log_file=self.be_logfile)
            self.log(qos_alloc, qos_airtime, -1, -1, self.cr_observer.collision_rate(), 2, log_file=self.qos_logfile)
    def __init__(self, iface, log_file):
        # TODO: implement iface --> phy translation
        assert(iface == 'wls33')
        phy = 'phy0'

        self.cr_observer = CollisionRateObserver(iface)

        self.txq_params_fname = '/sys/kernel/debug/ieee80211/'
        self.txq_params_fname += phy
        self.txq_params_fname += '/ath9k/txq_params'

        self.log_file = log_file
示例#5
0
    def __init__(self, iface, log_file, cw_init, beta, k, qos):
        super(TunerSALT, self).__init__(iface, log_file)

        self.cr_observer = CollisionRateObserver(iface)

        self.k = k
        self.beta = beta
        self.cw_prev = cw_init
        self.smooth = None
        self.qos = qos

        self.set_cw(cw_init)
示例#6
0
    def __init__(self, iface, log_file, cw_init):
        super(TunerRENEW, self).__init__(iface, log_file)

        self.cmd = [
            'cat',
            '/sys/kernel/debug/ieee80211/phy0/statistics/dot11RTSSuccessCount'
        ]

        self.cr_observer = CollisionRateObserver(iface)

        self.observer = ChannelObserver()
        self.n = int(subprocess.check_output(self.cmd))
        self.n_old = None
        self.cw_prev = cw_init
示例#7
0
class TunerCollisionRate(TunerBase):
    def __init__(self, iface, log_file, cw_init):
        super(TunerCollisionRate, self).__init__(iface, log_file)

        self.cr_observer = CollisionRateObserver(iface)
        self.ao = AirtimeObserver(iface)

        self.set_cw(cw_init)
        self.cw_prev = cw_init

    def update_cw(self):
        coll_rate = self.cr_observer.collision_rate()
        airtime = self.ao.airtime()

        if coll_rate < .1:
            cw = self.cw_prev / 2
        elif coll_rate > .2:
            cw = self.cw_prev * 2
        else:
            cw = self.cw_prev

        cw = 2 if cw < 2 else cw
        cw = 1023 if cw > 1023 else cw
        cw = int(cw)
        self.set_cw(cw)

        self.log(-1, airtime, self.cw_prev, cw, coll_rate)
        self.cw_prev = cw
示例#8
0
class TunerSALT(TunerBase):
    def __init__(self, iface, log_file, cw_init, beta, k, qos):
        super(TunerSALT, self).__init__(iface, log_file)

        self.cr_observer = CollisionRateObserver(iface)

        self.k = k
        self.beta = beta
        self.cw_prev = cw_init
        self.smooth = None
        self.qos = qos

        self.set_cw(cw_init)

    def update_cw(self, alloc, airtime):
        if self.smooth is None:
            self.smooth = airtime
        else:
            self.smooth = self.beta * airtime + (1.0 - self.beta) * self.smooth

        cw = int((self.smooth - alloc) * self.k) + self.cw_prev
        cw = 0 if cw < 0 else cw
        cw = 1023 if cw > 1023 else cw

        aifs = 2 if self.qos else 3
        self.set_cw(cw, aifs=aifs)

        self.log(alloc, airtime, self.cw_prev, cw,
                 self.cr_observer.collision_rate(), aifs)
        self.cw_prev = cw
示例#9
0
class TunerRENEW(TunerBase):
    def __init__(self, iface, log_file, cw_init):
        super(TunerRENEW, self).__init__(iface, log_file)

        self.cmd = [
            'cat',
            '/sys/kernel/debug/ieee80211/phy0/statistics/dot11RTSSuccessCount'
        ]

        self.cr_observer = CollisionRateObserver(iface)

        self.observer = ChannelObserver()
        self.n = int(subprocess.check_output(self.cmd))
        self.n_old = None
        self.cw_prev = cw_init

    def update_cw(self,
                  alloc,
                  airtime,
                  VO_q_len=-1,
                  VI_q_len=-1,
                  BE_q_len=-1,
                  BK_q_len=-1):
        self.observer.update()
        busy = self.observer.surveysays('busy')

        self.n_old = self.n
        self.n = int(subprocess.check_output(self.cmd))
        n = self.n - self.n_old

        n_alloc = n * alloc if n * alloc != 0 else 1
        cw = int((2 / 9e-3) * (airtime * ((1 - alloc) / (n_alloc)) * busy))
        cw = 15 if cw < 15 else cw
        cw = 1023 if cw > 1023 else cw
        self.set_cw(cw)

        self.log(alloc, airtime, self.cw_prev, cw,
                 self.cr_observer.collision_rate(), 2, VO_q_len, VI_q_len,
                 BE_q_len, BK_q_len)
        self.cw_prev = cw
class TunerBase(object):

    def __init__(self, iface, log_file):
        # TODO: implement iface --> phy translation
        assert(iface == 'wls33')
        phy = 'phy0'

        self.cr_observer = CollisionRateObserver(iface)

        self.txq_params_fname = '/sys/kernel/debug/ieee80211/'
        self.txq_params_fname += phy
        self.txq_params_fname += '/ath9k/txq_params'

        self.log_file = log_file

    def set_cw(self, cw, qumID=1, aifs=2, burst=0):
        # qumId = qumID
        # aifs = aifs
        cwmin = int(cw)
        cwmax = int(cw)
        # burst = burst

        txq_params_msg = '{} {} {} {} {}'.format(qumID, aifs, cwmin, cwmax, burst)
        f_cw = open(self.txq_params_fname, 'w')
        f_cw.write(txq_params_msg)
        f_cw.close()

    def log(self, alloc, airtime, cw_prev, cw, cr, aifs, log_file=None):
        if log_file is None:
            log_file = self.log()

        log_file.write('{:.5f},{:.5f},{:.5f},{},{},{:.5f},{}\n'.format(
                time.time(), alloc, airtime, cw_prev, cw, cr, aifs))
        log_file.flush()

    def update_cw(self, alloc, airtime):
        self.log(alloc, airtime, -1, -1, self.cr_observer.collision_rate(), -1)