Ejemplo n.º 1
0
Archivo: tcp2.py Proyecto: FSlyne/nsim
class tcpterm(duplex2):
    def __init__(self, *args, **kwargs):
        super(tcpterm, self).__init__(*args, **kwargs)
        self.listener = TCPListener(self.B.get, self.B.put, '2.2.2.2')
        self.conn = TCPSocket(self.listener)
        self.conn.bind('2.2.2.2', 80)
        self.worker()

    @threaded
    def worker(self):
        while True:
            data = self.conn.recv(10000, timeout=1)
        self.conn.close()
Ejemplo n.º 2
0
class tcpterm(datalink):
    def __init__(self, *args, **kwargs):
        super(tcpterm, self).__init__(*args, **kwargs)
        self.listener = TCPListener(self.B.get, self.B.put, '2.2.2.2')
        self.conn = TCPSocket(self.listener)
        self.conn.bind('2.2.2.2', 80)
        self.worker()

    @threaded
    def worker(self):
        while True:
            item = str(self.conn.recv(10000, timeout=1))
            #         print item
            timlock, now = self.lock()
            count, sendnow, payload = item.split(':')
            r.hset("pkt:%07d" % int(count), "recvtime", now)
            self.unlock(timlock)
        self.conn.close()
Ejemplo n.º 3
0
class tcpgen(datalink):
    def __init__(self, *args, **kwargs):
        super(tcpgen, self).__init__(*args, **kwargs)
        self.listener = TCPListener(self.A.get, self.A.put, '1.1.1.1')
        self.conn = TCPSocket(self.listener)
        self.conn.connect('2.2.2.2', 80)
        self.worker1()

    @threaded
    def worker1(self):
        payload = "A" * 200
        for count in range(1, 5000):
            now = stime = self.waittick()
            #         timlock,now=self.lock()
            load = '%d:%s:%s' % (count, now, payload)
            loadbits = len(load) * 8
            self.updatestats('trafbits', loadbits, 'bits')
            r.hset("pkt:%07d" % count, "sendtime",
                   "%s:%d" % (now, len(payload)))
            self.conn.send(load)


#         self.unlock(timlock)
        self.waitfor(1000)
        print "closing"
        self.conn.close()
Ejemplo n.º 4
0
Archivo: tcp2.py Proyecto: FSlyne/nsim
class tcpgen(duplex2):
    def __init__(self, *args, **kwargs):
        super(tcpgen, self).__init__(*args, **kwargs)
        self.listener = TCPListener(self.A.get, self.A.put, '1.1.1.1')
        self.conn = TCPSocket(self.listener)
        self.conn.connect('2.2.2.2', 80)
        self.worker1()

    @threaded
    def worker1(self):
        for i in range(1, 5000):
            stime = self.waittick()
            self.conn.send("A" * 250)
        self.waitfor(9.999)
        print "closing"
        self.conn.close()
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(tcpgen, self).__init__(*args, **kwargs)
     self.listener = TCPListener(self.A.get, self.A.put, '1.1.1.1')
     self.conn = TCPSocket(self.listener)
     self.conn.connect('2.2.2.2', 80)
     self.worker1()
Ejemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     super(tcpterm, self).__init__(*args, **kwargs)
     self.listener = TCPListener(self.B.get, self.B.put, '2.2.2.2')
     self.conn = TCPSocket(self.listener)
     self.conn.bind('2.2.2.2', 80)
     self.worker()