- server side:
- clone this repo:
git clone https://github.mv.usa.alcatel.com/corentih/tgen
- make go-capnproto2
available in your
$GOPATH
:go get github.com/zombiezen/go-capnproto2/
- run
make go
. Atgen
binary should be built. Look at the help with./tgen -h
- clone this repo:
- python client:
- create a virtual environment and activate it
- run
make py
. Atar.gz
package should be built underclient/dist/tgenpy<version>.tar.gz
. - install the package with
pip install client/dist/tgenpy<version>.tar.gz
.
import tgenpy
# connect to the server
controller = tgenpy.Controller('localhost', '1234')
# create a new stream with 1000 ethernet frames:
stream = tgenpy.Stream()
ethernet = tgenpy.protocols.Ethernet2())
stream.layers.append(ethernet)
stream.count = 1000
# save the stream
controller.save_stream(stream)
# fetch the ports, find the loopback interface, and send and capture traffic:
port = controller.get_port('lo'):
port.start_capture(packet_count=1000)
port.start_send([stream.id])
done, error = port.wait_capture(timeout=5000)
if not done:
print "capture did not finish after 5 seconds"
port.stop_capture()
port.wait_capture(timeout=2000)
if error:
print 'something when wrong: %s' % error