Throttling and delay can be made with special throttle handlers.
TcpCrusherBuilder.builder()
// ...
// 200 ms constant delay with 20 ms random jitter
.withIncomingThrottlerFactory((addr) ->
new DelayThrottler(200, 20, TimeUnit.MILLISECONDS))
.withOutgoingThrottlerFactory((addr) ->
new DelayThrottler(200, 20, TimeUnit.MILLISECONDS))
// ...
buildAndOpen();
Throttler filter limits throughput for the crusher.
TcpCrusherBuilder.builder()
// ...
.withIncomingThrottlerFactory((addr) ->
new ByteRateThrottler(INCOMING_BYTES_PER_SEC, 1, TimeUnit.SECONDS))
.withOutgoingThrottlerFactory((addr) ->
new ByteRateThrottler(OUTGOING_BYTES_PER_SEC, 1, TimeUnit.SECONDS))
// ...
buildAndOpen();
Also for DatagramCrusher a packet throttler is available:
DatagramCrusherBuilder.builder()
// ...
.withIncomingGlobalThrottler(new PacketRateThrottler(PACKET_PER_SEC, 1, TimeUnit.SECONDS))
.withOutgoingThrottlerFactory((addr) ->
new PacketRateThrottler(PACKET_PER_SEC, 1, TimeUnit.SECONDS))
// ...
buildAndOpen();
Note that DatagramCrusher has a single incoming throttler for all incoming traffic.
Any throttling of DatagramCrusher could lead to potential packet loss as UDP is not reliable protocol.