Пример #1
0
def set_rts_nodes(disable_rts=False, ifc="mesh0"):
    rts_th = "10" if not disable_rts else "off"
    command = "iwconfig {} rts {}".format(ifc, rts_th)
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.exec_cmd(s, command)
Пример #2
0
def set_rts_nodes(disable_rts=False, ifc="mesh0"):
    rts_th = "10" if not disable_rts else "off"
    command = "iwconfig {} rts {}".format(ifc, rts_th)
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.exec_cmd(s, command)
Пример #3
0
    def read_ath(self):
        sock = cmd.connect(self.host)
        ath = cmd.exec_cmd(sock, cmd.ath_cmd)
        sock.close()

        out = {}
        out['tx_management'] = int(
            re.findall("(\d+) tx management frames", ath)[0])
        out['tx_failed'] = int(
            re.findall("(\d+) tx failed due to too many retries", ath)[0])
        out['tx_short_retries'] = int(
            re.findall("(\d+) short on-chip tx retries", ath)[0])
        out['tx_long_retries'] = int(
            re.findall("(\d+) long on-chip tx retries", ath)[0])
        out['tx_noack'] = int(
            re.findall("(\d+) tx frames with no ack marked", ath)[0])
        out['tx_rts'] = int(
            re.findall("(\d+) tx frames with rts enabled", ath)[0])
        out['tx_short'] = int(
            re.findall("(\d+) tx frames with short preamble", ath)[0])
        out['rx_bad_crc'] = int(
            re.findall("(\d+) rx failed due to bad CRC", ath)[0])
        out['rx_too_short'] = int(
            re.findall("(\d+) rx failed due to frame too short", ath)[0])
        out['rx_phy_err'] = int(re.findall("(\d+) PHY errors", ath)[0])
        out['rx'] = sum(map(lambda x: int(x), re.findall(" rx +(\d+)", ath)))
        out['tx'] = sum(map(lambda x: int(x), re.findall(" tx +(\d+)", ath)))

        return out
Пример #4
0
 def clear_stats(self):
     sock = cmd.connect(self.host)
     stats = cmd.read_cmd(sock, cmd.clear_path)
     sock.close()
     self.stats = []
     self.total_cpu = None
     self.total_idle = None
     self.error = False
Пример #5
0
 def clear_stats(self):
     sock = cmd.connect(self.host)
     stats = cmd.read_cmd(sock, cmd.clear_path)
     sock.close()
     self.stats = []
     self.total_cpu = None
     self.total_idle = None
     self.error = False
Пример #6
0
def set_hop_penalty(penalty="10"):
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        if node.endnode:
            cmd.write_cmd(s, cmd.hop_path, penalty)
        else:
            cmd.write_cmd(s, cmd.hop_path, "0")
Пример #7
0
def set_coding_nodes(coding=True, toggle_tq=False):
    c = "1" if coding else "0"
    try:
        for node in nodes:
            host = "{}:{}".format(node.forward_ip, node.port)
            if toggle_tq:
                s = cmd.connect(host)
                cmd.write_cmd(s, cmd.tq_path, c)
                s = cmd.connect(host)
                cmd.write_cmd(s, cmd.catw_path, "1")
            else:
                s = cmd.connect(host)
                cmd.write_cmd(s, cmd.catw_path, c)
    except Exception:
        return False
    else:
        return True
Пример #8
0
def set_hop_penalty(penalty="10"):
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        if node.endnode:
            cmd.write_cmd(s, cmd.hop_path, penalty)
        else:
            cmd.write_cmd(s, cmd.hop_path, "0")
Пример #9
0
def set_coding_nodes(coding=True, toggle_tq=False):
    c = "1" if coding else "0"
    try:
        for node in nodes:
            host = "{}:{}".format(node.forward_ip, node.port)
            if toggle_tq:
                s = cmd.connect(host)
                cmd.write_cmd(s, cmd.tq_path, c)
                s = cmd.connect(host)
                cmd.write_cmd(s, cmd.catw_path, "1")
            else:
                s = cmd.connect(host)
                cmd.write_cmd(s, cmd.catw_path, c)
    except Exception:
        return False
    else:
        return True
Пример #10
0
def set_rate_nodes(rate="2", ifc="mesh0"):
    if not rate == "auto":
        rate = rate + "M fixed"

    command = "iwconfig {} rate {}".format(ifc, rate)
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.exec_cmd(s, command)
Пример #11
0
def set_rate_nodes(rate="2", ifc="mesh0"):
    if not rate == "auto":
        rate = rate + "M fixed"

    command = "iwconfig {} rate {}".format(ifc, rate)
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.exec_cmd(s, command)
Пример #12
0
    def read_origs(self):
        sock = cmd.connect(self.host)
        inp = cmd.read_cmd(sock, cmd.orig_path)
        sock.close()
        origs = re.findall("([0-9a-fA-F:]{17}) +\d+\.\d+s +\(( *\d+)\) ([0-9a-fA-F:]{17})", inp)
        out = {}
        for nexthop in origs:
            out[nexthop[0]] = (nexthop[2], nexthop[1])

        #self.check_origs(out)

        return out
Пример #13
0
    def read_origs(self):
        sock = cmd.connect(self.host)
        inp = cmd.read_cmd(sock, cmd.orig_path)
        sock.close()
        origs = re.findall(
            "([0-9a-fA-F:]{17}) +\d+\.\d+s +\(( *\d+)\) ([0-9a-fA-F:]{17})",
            inp)
        out = {}
        for nexthop in origs:
            out[nexthop[0]] = (nexthop[2], nexthop[1])

        #self.check_origs(out)

        return out
Пример #14
0
    def read_cpu(self):
        last_cpu = self.total_cpu
        last_idle = self.total_idle

        sock = cmd.connect(self.host)
        cpu = cmd.read_cmd(sock, cmd.cpu_path)
        sock.close()
        line = cpu.split("\n")[0]
        self.total_cpu = sum(map(lambda x: float(x), line.split()[1:]))
        self.total_idle = float(line.split()[4])
        if not last_cpu:
            return None
        else:
            total = self.total_cpu - last_cpu
            idle = self.total_idle - last_idle
            return int(100 * (total - idle) / total)
Пример #15
0
    def read_cpu(self):
        last_cpu = self.total_cpu
        last_idle = self.total_idle

        sock = cmd.connect(self.host)
        cpu = cmd.read_cmd(sock, cmd.cpu_path)
        sock.close()
        line = cpu.split("\n")[0]
        self.total_cpu = sum(map(lambda x: float(x), line.split()[1:]))
        self.total_idle = float(line.split()[4])
        if not last_cpu:
            return None
        else:
            total = self.total_cpu - last_cpu
            idle = self.total_idle - last_idle
            return int(100*(total - idle)/total)
Пример #16
0
    def read_ath(self):
        sock = cmd.connect(self.host)
        ath = cmd.exec_cmd(sock, cmd.ath_cmd)
        sock.close()

        out = {}
        out['tx_management'] = int(re.findall("(\d+) tx management frames", ath)[0])
        out['tx_failed'] = int(re.findall("(\d+) tx failed due to too many retries", ath)[0])
        out['tx_short_retries'] = int(re.findall("(\d+) short on-chip tx retries", ath)[0])
        out['tx_long_retries'] = int(re.findall("(\d+) long on-chip tx retries", ath)[0])
        out['tx_noack'] = int(re.findall("(\d+) tx frames with no ack marked", ath)[0])
        out['tx_rts'] = int(re.findall("(\d+) tx frames with rts enabled", ath)[0])
        out['tx_short'] = int(re.findall("(\d+) tx frames with short preamble", ath)[0])
        out['rx_bad_crc'] = int(re.findall("(\d+) rx failed due to bad CRC", ath)[0])
        out['rx_too_short'] = int(re.findall("(\d+) rx failed due to frame too short", ath)[0])
        out['rx_phy_err'] = int(re.findall("(\d+) PHY errors", ath)[0])
        out['rx'] = sum(map(lambda x: int(x), re.findall(" rx +(\d+)", ath)))
        out['tx'] = sum(map(lambda x: int(x), re.findall(" tx +(\d+)", ath)))

        return out
Пример #17
0
def set_tx_nodes(tx):
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.exec_cmd(s, "iwconfig mesh0 txpower {}".format(tx))
Пример #18
0
 def read_meas(self):
     sock = cmd.connect(self.host)
     stats = cmd.read_cmd(sock, cmd.stats_path)
     sock.close()
     return stats
Пример #19
0
def set_tx_nodes(tx):
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.exec_cmd(s, "iwconfig mesh0 txpower {}".format(tx))
Пример #20
0
def set_hold_nodes(hold="30"):
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.write_cmd(s, cmd.hold_path, int(hold))
Пример #21
0
def set_coding(node, coding=True):
    print("Network Coding: {}".format(coding))
    c = "1" if coding else "0"
    s = cmd.connect(node)
    cmd.write_cmd(s, cmd.catw_path, c)
Пример #22
0
 def read_meas(self):
     sock = cmd.connect(self.host)
     stats = cmd.read_cmd(sock, cmd.stats_path)
     sock.close()
     return stats
Пример #23
0
def set_coding(node, coding=True):
    print("Network Coding: {}".format(coding))
    c = "1" if coding else "0"
    s = cmd.connect(node)
    cmd.write_cmd(s, cmd.catw_path, c)
Пример #24
0
def set_tq(node, tq=True):
    print("Random tq: {}".format(tq))
    t = "1" if tq else "0"
    s = cmd.connect(node)
    cmd.write_cmd(s, cmd.tq_path, t)
Пример #25
0
def set_tq(node, tq=True):
    print("Random tq: {}".format(tq))
    t = "1" if tq else "0"
    s = cmd.connect(node)
    cmd.write_cmd(s, cmd.tq_path, t)
Пример #26
0
def set_hold_nodes(hold="30"):
    for node in nodes:
        host = "{}:{}".format(node.forward_ip, node.port)
        s = cmd.connect(host)
        cmd.write_cmd(s, cmd.hold_path, int(hold))