java.lang.Object
com.slytechs.jnet.jnetpcap.PcapProConfigurator<PacketRepeater>
com.slytechs.jnet.jnetpcap.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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.slytechs.jnet.jnetpcap.PcapProConfigurator
PcapProConfigurator.PostRxProcessor, PcapProConfigurator.PostRxProcessorFactory<T extends PcapProConfigurator.PostRxProcessor>, PcapProConfigurator.PreRxProcessor, PcapProConfigurator.PreRxProcessorFactory<T extends PcapProConfigurator.PreRxProcessor>, PcapProConfigurator.RxProcessor, PcapProConfigurator.TxProcessor -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDiscard all packets.discardAllPackets(boolean discard) Discard all packets, conditionally.discardAllPackets(BooleanSupplier discard) Discard all packets if the discard flag supplier returns true.longgetIfgForRepeated(TimeUnit unit) Gets the current repeated packet delay or inter-frame-gap (IFG) if any.longGets the current repeated packet delay or inter-frame-gap if any, with nano second precision.longGets the minimum ifg nano.longGets the repeat count value.com.slytechs.jnet.jnetruntime.time.TimestampUnitGets the timestamp unit.booleanChecks if is rewrite timestamp flag is set.rewriteTimestamp(boolean enable) Rewrite timestamp flag.setIfgForRepeated(long duration, TimeUnit unit) Sets the delay or inter-frame-gap between the original packet and all of subsequent repeated packets.setMinimumIfg(long ifg, TimeUnit unit) Sets the minimum ifg.setRepeatCount(long count) Sets the repeat count.setRepeatCount(IntSupplier count) Sets the repeat count using a supplier.setRepeatCount(LongSupplier count) Sets the repeat count using a supplier.setTimestampUnit(com.slytechs.jnet.jnetruntime.time.TimestampUnit unit) Sets the timestamp unit.Methods inherited from class com.slytechs.jnet.jnetpcap.PcapProConfigurator
enable, enableIf, getPcapContext, isEnabled
-
Field Details
-
PROPERTY_PACKET_REPEATER_ENABLE
The Constant PROPERTY_PACKET_REPEATER_ENABLE.- See Also:
-
PROPERTY_PACKET_REPEATER_REPEAT_COUNT
The Constant PROPERTY_PACKET_REPEATER_REPEAT_COUNT.- See Also:
-
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
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
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
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
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
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
Sets the delay or inter-frame-gap between the original packet and all of subsequent repeated packets.- Parameters:
duration- the duration or inter-frame-gapunit- the time unit for the delay- Returns:
- this packet repeater
-
setRepeatCount
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
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
Sets the minimum ifg.- Parameters:
ifg- the ifgunit- the unit- Returns:
- the packet repeater
-
setTimestampUnit
Sets the timestamp unit.- Parameters:
unit- the unit- Returns:
- the packet repeater
-
setRepeatCount
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
-