Table Of Contents
Table Of Contents

Enqueueing Packets

This step demonstrates the PacketQueue module, which can store a configurable number of packets. By default, it works as a FIFO queue and has unlimited capacity. Optionally, the queue can be limited (both by number of packets and byte count), and ordering can be specified.

In the following example network, packets are produced at random intervals by an active packet source (ActivePacketSource). The packets are pushed into an unlimited FIFO queue (PacketQueue), where they are stored temporarily. An active packet sink (ActivePacketSink) module pops packets from the queue at random intervals.

../../../_images/PacketQueue.png
network PacketQueueTutorialStep
{
    @display("bgb=600,200");
    submodules:
        producer: ActivePacketSource {
            @display("p=100,100");
        }
        queue: PacketQueue {
            @display("p=300,100");
        }
        collector: ActivePacketSink {
            @display("p=500,100");
        }
    connections allowunconnected:
        producer.out --> queue.in;
        queue.out --> collector.in;
}
[Config PacketQueue]
network = PacketQueueTutorialStep
sim-time-limit = 10s

*.producer.packetLength = 1B
*.producer.productionInterval = uniform(0s, 1s)
*.collector.collectionInterval = uniform(0s, 2s)