class fragment.FragmentAction(environment_id=None, correct_order=None, fragsize=-1, segment=True, overlap=0)

Bases: actions.action.Action

Defines the FragmentAction for Geneva - fragments or segments the given packet.

__init__(environment_id=None, correct_order=None, fragsize=-1, segment=True, overlap=0)

Initializes a fragment action object.

  • environment_id (str, optional) – Environment ID of the strategy this object is a part of
  • correct_order (bool, optional) – Whether or not the fragments/segments should be returned in the correct order
  • fragsize (int, optional) – The index this packet should be cut. Defaults to -1, which cuts it in half.
  • segment (bool, optional) – Whether we should perform fragmentation or segmentation
  • overlap (int, optional) – How many bytes the fragments/segments should overlap
fragment(original, fragsize)

Fragments a packet into two, given the size of the first packet (0:fragsize) Always returns two packets


Randomly decides if the fragments should be reversed.

ip_fragment(packet, logger)

Perform IP fragmentation.


Mutates the fragment action - it either chooses a new segment offset, switches the packet order, and/or changes whether it segments or fragments.

parse(string, logger)

Parses a string representation of fragmentation. Nothing particularly special, but it does check for a the fragsize.

Note that the given logger is a DIFFERENT logger than the logger passed to the other functions, and they cannot be used interchangeably. This logger is attached to the main GA driver, and is run outside the evaluator. When the action is actually run, it’s run within the evaluator, which by necessity must pass in a different logger.

run(packet, logger)

The fragment action fragments each given packet.

tcp_segment(packet, logger)

Segments a packet into two, given the size of the first packet (0:fragsize) Always returns two packets, since fragment is a branching action, so if we are unable to segment, it will duplicate the packet.

If overlap is specified, it will select n bytes from the second packet and append them to the first, and increment the sequence number accordingly

frequency = 2