Table Of Contents
Table Of Contents

Duplicating Packets Based On Their Ordinal Number

The OrdinalBasedDuplicator module duplicates packets based on the ordinal number of incoming packets. The packets to be duplicated can be configured by listing their ordinal numbers in a parameter. When the packets to be duplicated need to be selected using more complex criteria, a duplicator module can be combined with a classifier and a multiplexer to achieve that.

In this example network, packets are produced periodically by an active packet source (ActivePacketSource). The packet source pushed packets into a duplicator (OrdinalBasedDuplicator). The duplicator is configured to duplicate every second packet on its ordinal number. The packets are then consumed by a passive packet sink (PassivePacketSink).

../../../_images/OrdinalBasedDuplicator.png
network OrdinalBasedDuplicatorTutorialStep
{
    submodules:
        producer: ActivePacketSource {
            @display("p=100,100");
        }
        duplicator: OrdinalBasedDuplicator {
            @display("p=200,100");
        }
        consumer: PassivePacketSink {
            @display("p=300,100");
        }
    connections:
        producer.out --> duplicator.in;
        duplicator.out --> consumer.in;
}
[Config OrdinalBasedDuplicator]
network = OrdinalBasedDuplicatorTutorialStep
sim-time-limit = 10s

*.producer.packetLength = 1B
*.producer.productionInterval = 1s
*.duplicator.duplicatesVector = "0; 2; 4; 6; 8; 10"