Class PacketRepeater

All Implemented Interfaces:
PcapProConfigurator.PreRxProcessor, PcapProConfigurator.RxProcessor

public final class PacketRepeater extends PcapProConfigurator<PacketRepeater> implements PcapProConfigurator.PreRxProcessor
A packet repeater pre-processor. The repeater is able to repeat, or reinsert a previously seen packet back into the Pcap Pro packet distream any number of times. This allows every packet to be repeated a certain number of times.

You can also add a delay or inter-frame-gap between each of the repeated packets, allowing certain amount of spacing. Optionally, you can also the repeater rewrite the "timestamp" field of the pcap header, so that each packet has an updated timestamp that is different from the original packet.

Author:
Sly Technologies Inc, repos@slytechs.com
  • Field Details

    • PROPERTY_PACKET_REPEATER_ENABLE

      public static final String PROPERTY_PACKET_REPEATER_ENABLE
      The Constant PROPERTY_PACKET_REPEATER_ENABLE.
      See Also:
    • PROPERTY_PACKET_REPEATER_REPEAT_COUNT

      public static final String PROPERTY_PACKET_REPEATER_REPEAT_COUNT
      The Constant PROPERTY_PACKET_REPEATER_REPEAT_COUNT.
      See Also:
    • PROPERTY_PACKET_REPEATER_DELAY_NANO

      public static final String PROPERTY_PACKET_REPEATER_DELAY_NANO
      The Constant PROPERTY_PACKET_REPEATER_DELAY_NANO.
      See Also:
  • Constructor Details

    • PacketRepeater

      public PacketRepeater()
      Instantiates a new packet repeater.
  • Method Details

    • discardAllPackets

      public PacketRepeater discardAllPackets()
      Discard all packets. No packets, including the originals, will be sent through. Setting a repeat count value after making a call to this method, will reset the discard flag.
      Returns:
      this packet repeater
    • discardAllPackets

      public PacketRepeater discardAllPackets(boolean discard)
      Discard all packets, conditionally. No packets, including the originals, will be sent through. Setting a repeat count value after making a call to this method, will reset the discard flag.
      Parameters:
      discard - the discard flag which can be enabled or disabled
      Returns:
      this packet repeater
    • discardAllPackets

      public PacketRepeater discardAllPackets(BooleanSupplier discard)
      Discard all packets if the discard flag supplier returns true. Causes all packets, including the original packet to be discarded.
      Parameters:
      discard - a discard flag supplier
      Returns:
      this packet repeater
    • getIfgForRepeated

      public long getIfgForRepeated(TimeUnit unit)
      Gets the current repeated packet delay or inter-frame-gap (IFG) if any.
      Parameters:
      unit - the time unit requested
      Returns:
      the delay
    • getIfgForRepeatedNano

      public long getIfgForRepeatedNano()
      Gets the current repeated packet delay or inter-frame-gap if any, with nano second precision.
      Returns:
      the delay nano
    • getRepeatCount

      public long getRepeatCount()
      Gets the repeat count value.
      Returns:
      the repeat count
    • isRewriteTimestamp

      public boolean isRewriteTimestamp()
      Checks if is rewrite timestamp flag is set.
      Returns:
      true, if is rewrite timestamp
    • rewriteTimestamp

      public PacketRepeater rewriteTimestamp(boolean enable)
      Rewrite timestamp flag. The rewrite timestamp flag, will rewrite the timestamp in the pcap header for all repeated packets to reflect the calculated timestamp based on the timestamp of the original packet and how much delay was used before the repeated packet is sent.

      This flag has no effect on the original packet. Its timestamp is never modified, only the repeated packets.

      Parameters:
      enable - enables the rewrite timestamp flag
      Returns:
      this packet repeater
    • setIfgForRepeated

      public PacketRepeater setIfgForRepeated(long duration, TimeUnit unit)
      Sets the delay or inter-frame-gap between the original packet and all of subsequent repeated packets.
      Parameters:
      duration - the duration or inter-frame-gap
      unit - the time unit for the delay
      Returns:
      this packet repeater
    • setRepeatCount

      public PacketRepeater setRepeatCount(IntSupplier count)
      Sets the repeat count using a supplier. Each packet captured by pcap is repeated, not duplicated. The exact original packet is repeatedly sent into the pcap packet stream. Each of the repeated packets, will be identical to the original packet being repeated, including its memory addresses for header and packet data pointers.
      Parameters:
      count - how many times to repeat the original packet, where 0 means 0 times so only the original packet will be sent, a 1 means 1 repeat resulting in 2 packets (the original + 1 repeated) will be sent, etc.
      Returns:
      this packet repeater
    • setRepeatCount

      public PacketRepeater setRepeatCount(long count)
      Sets the repeat count. Each packet captured by pcap is repeated, not duplicated. The exact original packet is repeatedly sent into the pcap packet stream. Each of the repeated packets, will be identical to the original packet being repeated, including its memory addresses for header and packet data pointers.
      Parameters:
      count - how many times to repeat the original packet, where 0 means 0 times so only the original packet will be sent, a 1 means 1 repeat resulting in 2 packets (the original + 1 repeated) will be sent, etc.
      Returns:
      this packet repeater
    • setMinimumIfg

      public PacketRepeater setMinimumIfg(long ifg, TimeUnit unit)
      Sets the minimum ifg.
      Parameters:
      ifg - the ifg
      unit - the unit
      Returns:
      the packet repeater
    • setTimestampUnit

      public PacketRepeater setTimestampUnit(com.slytechs.jnet.jnetruntime.time.TimestampUnit unit)
      Sets the timestamp unit.
      Parameters:
      unit - the unit
      Returns:
      the packet repeater
    • setRepeatCount

      public PacketRepeater setRepeatCount(LongSupplier count)
      Sets the repeat count using a supplier. Each packet captured by pcap is repeated, not duplicated. The exact original packet is repeatedly sent into the pcap packet stream. Each of the repeated packets, will be identical to the original packet being repeated, including its memory addresses for header and packet data pointers.
      Parameters:
      count - how many times to repeat the original packet, where 0 means 0 times so only the original packet will be sent, a 1 means 1 repeat resulting in 2 packets (the original + 1 repeated) will be sent, etc.
      Returns:
      this packet repeater
    • getMinimumIfgNano

      public long getMinimumIfgNano()
      Gets the minimum ifg nano.
      Returns:
      the minIfgNano
    • getTimestampUnit

      public com.slytechs.jnet.jnetruntime.time.TimestampUnit getTimestampUnit()
      Gets the timestamp unit.
      Returns:
      the timestampUnit