Ejemplo n.º 1
0
    def start_pings(self, traffic_file):
        try:
            f = open(traffic_file, "r")
        except:
            print "Open %s failed" % traffic_file
            sys.exit(1)

        addr =  [0x20, 0x01, 0x04, 0x70, 0x1f, 0x04, 0x05, 0x6d, 
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];

        lines = f.readlines()
        for l in lines:
            s = l.split()
            addr[15] = int(s[1])
        
            t = TestDriverMsg()
            t.set_cmd(TEST_PING)
            t.set_dt(int(s[2]))
            t.set_n(int(s[3]))
            t.set_addr(addr)
            print int(s[0]), t
            self.sendMsg(int(s[0]), t)
            time.sleep(1)

        self.setTarget(len(lines))
Ejemplo n.º 2
0
 def stop_node(self, n):
     t = TestDriverMsg()
     t.set_cmd(TEST_STOP)
     self.sendMsg(n, t)
Ejemplo n.º 3
0
        print "Usage: %s [clear | ping] <traffic file>" % sys.argv[0]
        sys.exit(1)
    
    d = Driver()


    if sys.argv[1] == "ping":
        d.start_pings(sys.argv[2])

        if len(sys.argv) == 4 and sys.argv[3] == "dontwait":
            d.finish()
        else:
            d.waitOnFinish()

    elif sys.argv[1] == "clear":
        t = TestDriverMsg()
        t.set_cmd(TEST_CLEAR)
        for i in range(1,225):
            d.sendMsg(i, t)
        d.finish()

    elif sys.argv[1] == "stop":
        d.stop_node(int(sys.argv[2]))
        d.finish()

    elif sys.argv[1] == "start":
        t = TestDriverMsg()
        t.set_cmd(TEST_START)
        d.sendMsg(int(sys.argv[2]), t)
        d.finish()