示例#1
0
文件: slave.py 项目: jledet/catbench
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
文件: stats.py 项目: jledet/catbench
    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
文件: stats.py 项目: jledet/catbench
 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
文件: stats.py 项目: jledet/catbench
 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
文件: slave.py 项目: jledet/catbench
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
文件: slave.py 项目: jledet/catbench
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
文件: slave.py 项目: jledet/catbench
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
文件: stats.py 项目: jledet/catbench
    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
文件: stats.py 项目: jledet/catbench
    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
文件: stats.py 项目: jledet/catbench
    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
文件: stats.py 项目: jledet/catbench
    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
文件: stats.py 项目: jledet/catbench
    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
文件: stats.py 项目: jledet/catbench
 def read_meas(self):
     sock = cmd.connect(self.host)
     stats = cmd.read_cmd(sock, cmd.stats_path)
     sock.close()
     return stats
示例#19
0
文件: slave.py 项目: jledet/catbench
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
文件: catcp.py 项目: jledet/catbench
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
文件: stats.py 项目: jledet/catbench
 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
文件: catcp.py 项目: jledet/catbench
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
文件: slave.py 项目: jledet/catbench
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))