simple_ostinato package¶
-
class
simple_ostinato.
Drone
(host, connect=True)[source]¶ Bases:
object
Wrapper for
ostinato.core.DroneProxy
.All the protocol buffer related methods are prefixed with
_o_
and are for internal use only.Parameters: -
connect
()[source]¶ Connect to the remote drone instance. By default, it is already called when the object is created.
-
-
class
simple_ostinato.
Port
(drone, port_id)[source]¶ Bases:
object
Represent a remote port. This class provides simple methods to add/remove streams, and send/capture traffic.
Parameters: -
streams
¶ dict – a dictionnary with all the streams configured on this port. It can be refreshed with
fetch_streams()
.
-
port_id
¶ int – id of the port
-
add_stream
(*layers)[source]¶ Create a new stream, on the remote drone instance, and return the corresponding Stream object. The object is also added to
streams
.Layers must be instances of
simple_ostinato.protocols.Protocol
>>> from simple_ostinato import protocols >>> my_port.add_stream(protocols.Mac(), protocols.Ethernet())
-
del_stream
(stream_id)[source]¶ Delete the stream provided as argument.
Parameters: stream_id (int) – id of the stream to delete from the port.
-
fetch_streams
()[source]¶ Fetch the streams configured on this port, from the remote drone instance. The streams are stored in
streams
.
-
get_capture
(save_as=None)[source]¶ Get the lastest capture and return is as a string.
Parameters: save_as (str) – if provided, the capture will also be saved as a pcap file at the specified location on the host that runs drone.
-
get_stream
(stream_id)[source]¶ Return a the
Stream
object corresponding to the given stream ID (int
)
-
get_streams_by_name
(name)[source]¶ Return a list of
Stream
s that have the given name (:class:str). Since most often names are unique, it is common to get a stream doing:>>> my_stream_foo = my_port.get_streams_by_name('stream_foo')[0]
-
start_capture
()[source]¶ Start capturing. By default, this method is non-blocking and returns immediately, and
stop_send()
must be called to stop the capture.
-
is_enabled
¶ If
True
the port is enabled. Otherwise, it is disabled.
-
is_exclusive_control
¶
-
name
¶ Name of the port. This is a read-only attribute.
-
port_id
ID of the port. This is a read-only attribute.
-
transmit_mode
¶ Can be
SEQUENTIAL
orINTERLEAVED
.
-
user_name
¶ Name of the port user.
-
-
class
simple_ostinato.
Stream
(port, stream_id, layers=None)[source]¶ Bases:
object
Represent a stream configured on a port. Besides all the stream configuration parameters, a stream class has layers which define the packets to be sent.
Parameters: -
disable
()[source]¶ Disable the stream. It is equivalent to setting
is_enabled
toFalse
.
-
enable
()[source]¶ Enable the stream. It is equivalent to setting
is_enabled
toTrue
.
-
fetch
()[source]¶ Fetch the stream configuration on the remote drone instance (including all the layers).
-
bursts_per_sec
¶ Number of bursts to send per second.
-
frame_len
¶
-
frame_len_max
¶
-
frame_len_min
¶
-
is_enabled
¶ Return
True
if the stream is enabled,False
otherwise. By default, streams are not enabled.
-
layers
¶ List of all the layers configured for this stream.
-
len_mode
¶ Length mode. It must be either
FIXED
(the default),INC
,DEC
orRANDOM
-
mode
¶ Sending mode. It must be either
FIXED
(the default) orCONTINUOUS
.If set to
FIXED
, a fixed number of packets or bursts is sent. Ifunit
is set toPACKETS
, thennum_packets
packets are sent. If it is set toBURSTS
thennum_bursts
bursts are sent.If set to
CONTINUOUS
, packets or bursts are sent continuously until the port stop transmitting.
-
name
¶ Name of the stream (optional)
-
next
¶ What to do after the current stream finishes. It is ignored if
mode
is set toCONTINUOUS
.STOP
: stop after this streamGOTO_NEXT
: send the next enabled streamGOTO_ID
: send a stream with a given ID.
-
num_bursts
¶ Number of bursts to send. This is ignored if
mode
is set toCONTINUOUS
or ifunit
is set toPACKETS
.
-
num_packets
¶ Number of packets to send. This is ignored if
mode
is set toCONTINUOUS
or ifunit
is set toBURSTS
.
-
packets_per_burst
¶ Number of packets per burst. This is ignored if
mode
is set toCONTINUOUS
or ifunit
is set toPACKETS
-
packets_per_sec
¶ Number of bursts to send per second.
-
unit
¶ Unit to send. It must be either
PACKETS
(the default) orBURSTS
.
-