Table Of Contents
Table Of Contents

Storing Packets on Behalf of Multiple Queues

The PacketBuffer module stores packets on behalf of multiple queues, acting as a shared buffer for them. Instead of each individual queue having a separate capacity, the whole group of queues has a global, shared capacity, represented by the buffer. The buffer keeps a record of which packets belong to which queue, and also maintains the order of packets.

In this example network, packets are produced at random intervals by two active packet sources (ActivePacketSource). Each packet source pushes packets into its associated queue (PacketQueue). The two queues share a packet buffer module (PacketBuffer). The buffer is configured to have a capacity of 2 packets. Packets are popped from the queues by two active packet sinks (ActivePacketSink). Since the buffer has a limited packet capacity, and the PacketAtCollectionBeginDropper function is used as the dropper function, the buffer drops packets from the beginning of the buffer when it gets overloaded.

network BufferTutorialStep
        buffer: PacketBuffer {
        producer1: ActivePacketSource {
        producer2: ActivePacketSource {
        queue1: PacketQueue {
            bufferModule = "^.buffer";
        queue2: PacketQueue {
            bufferModule = "^.buffer";
        collector1: ActivePacketSink {
        collector2: ActivePacketSink {
        producer1.out -->;
        queue1.out -->;
        producer2.out -->;
        queue2.out -->;
[Config Buffer]
network = BufferTutorialStep
sim-time-limit = 10s

*.buffer.dropperClass = "inet::queueing::PacketAtCollectionBeginDropper"
*.producer*.packetLength = 1B
*.producer*.productionInterval = uniform(0s, 1s)
*.collector*.collectionInterval = uniform(0s, 2s)
*.buffer.packetCapacity = 2