Haven't tested it, but the below should work I guess.
# add two streams
stream_id = ost_pb.StreamIdList()
stream_id.port_id.CopyFrom(tx_port.port_id[0])
stream_id.stream_id.add().id = 1 # stream 1
stream_id.stream_id.add().id = 2 # stream 2
log.info('adding tx_stream %d' % stream_id.stream_id[0].id)
drone.addStream(stream_id)
# configure the stream#1
stream_cfg = ost_pb.StreamConfigList()
stream_cfg.port_id.CopyFrom(tx_port.port_id[0])
s = stream_cfg.stream.add()
s.stream_id.id = stream_id.stream_id[0].id
s.core.is_enabled = True
s.control.num_packets = 5
# setup stream protocols as mac:eth2:ip4:udp:payload
p = s.protocol.add()
p.protocol_id.id = ost_pb.Protocol.kMacFieldNumber
p.Extensions[mac].dst_mac = 0x001122334455
p.Extensions[mac].src_mac = 0x00aabbccddee
p = s.protocol.add()
p.protocol_id.id = ost_pb.Protocol.kEth2FieldNumber
p = s.protocol.add()
p.protocol_id.id = ost_pb.Protocol.kIp4FieldNumber
# reduce typing by creating a shorter reference to p.Extensions[ip4]
ip = p.Extensions[ip4]
ip.src_ip = 0x01020304
ip.dst_ip = 0x05060708
ip.dst_ip_mode = Ip4.e_im_inc_host
s.protocol.add().
protocol_id.id = ost_pb.Protocol.kUdpFieldNumber
s.protocol.add().
protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
# configure the stream#2
stream_cfg = ost_pb.StreamConfigList()
stream_cfg.port_id.CopyFrom(tx_port.port_id[0])
s = stream_cfg.stream.add()
s.stream_id.id = stream_id.stream_id[1].id
s.core.is_enabled = True
s.control.num_packets = 5
# setup stream protocols as mac:eth2:ip4:udp:payload
p = s.protocol.add()
p.protocol_id.id = ost_pb.Protocol.kMacFieldNumber
p.Extensions[mac].dst_mac = 0x001122334455
p.Extensions[mac].src_mac = 0x00aabbccddee
p = s.protocol.add()
p.protocol_id.id = ost_pb.Protocol.kEth2FieldNumber
p = s.protocol.add()
p.protocol_id.id = ost_pb.Protocol.kIp4FieldNumber
# reduce typing by creating a shorter reference to p.Extensions[ip4]
ip = p.Extensions[ip4]
ip.src_ip = 0x01020304
ip.dst_ip = 0x05060708
ip.dst_ip_mode = Ip4.e_im_inc_host
s.protocol.add().
protocol_id.id = ost_pb.Protocol.kUdpFieldNumber
s.protocol.add().
protocol_id.id = ost_pb.Protocol.kPayloadFieldNumber
log.info('configuring tx_stream %d' % stream_id.stream_id[0].id)
drone.modifyStream(stream_cfg)
Alternatively, you might find
https://github.com/little-dude/simple-ostinato easier to start with.
It's a wrapper around python-ostinato with pretty good documentation.
Srivats
On Fri, May 6, 2016 at 1:45 AM, Fabrice Meyer <
fab.f...@gmail.com> wrote:
> Hi everyone,
>
> I'm trying to automatize the process of a traffic generator using the python
> API of Ostinato.
> I want to create multiple stream and run them one after an other. I managed
> to create a single stream and change parameters using the Ostinato doc
> (
https://github.com/pstavirs/ostinato/wiki/PythonScripting) but i have no
> idea how to do this and how can you control the stream without the sleep
> like in the example (basically run the stream till whole packets in
> parameters are sent).
>
> Someone have an idea? Some examples?
>
>
>
> --
> Get Ostinato News and Updates on Twitter - Follow @ostinato
> (
http://twitter.com/ostinato)
> ---
> You received this message because you are subscribed to the Google Groups
> "ostinato" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
ostinato+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
http://ostinato.org/
@ostinato