Table Of Contents
Table Of Contents

Building Complex Queues via Composition

This step demonstrates a compound priority queue (ExampleCompoundPriorityQueue) built from queueing components. The compound queue contains three packet queues. A classifier pushes packets to the first two queues and a passive packet sink in a round-robin fashion. An active packet source produces packets into the third queue. The three queues are connected to a priority scheduler, which pops packets from the first non-empty queue; the earlier queues have priority.

In this step, packets are produced at random intervals by an active packet source (ActivePacketSource). The source is connected to a compound priority queue (ExampleCompoundPriorityQueue) where packets are stored temporarily. Packets are collected at random intervals by an active packet sink (ActivePacketSink).

../../../_images/CompoundQueue.png
../../../_images/CompoundQueue_Queue.png
network CompoundPacketQueueTutorialStep
{
    @display("bgb=600,200");
    submodules:
        producer: ActivePacketSource {
            @display("p=100,100");
        }
        queue: ExampleCompoundPriorityQueue {
            @display("p=300,100");
        }
        collector: ActivePacketSink {
            @display("p=500,100");
        }
    connections allowunconnected:
        producer.out --> queue.in;
        queue.out --> collector.in;
}
module ExampleCompoundPriorityQueue extends CompoundPacketQueueBase
{
    parameters:
        @class(::inet::queueing::CompoundPacketQueueBase);
    submodules:
        classifier: WrrClassifier {
            @display("p=100,100");
        }
        queue1: PacketQueue {
            @display("p=325,100");
        }
        queue2: PacketQueue {
            @display("p=325,225");
        }
        queue3: PacketQueue {
            @display("p=475,350");
        }
        consumer: PassivePacketSink {
            @display("p=175,350");
        }
        producer: ActivePacketSource {
            @display("p=325,350");
        }
        scheduler: PriorityScheduler {
            @display("p=550,100");
        }
    connections:
        in --> { @display("m=w"); } --> classifier.in;
        classifier.out++ --> queue1.in;
        classifier.out++ --> queue2.in;
        classifier.out++ --> consumer.in;
        queue1.out --> scheduler.in++;
        queue2.out --> scheduler.in++;
        producer.out --> queue3.in;
        queue3.out --> scheduler.in++;
        scheduler.out --> { @display("m=e"); } --> out;
}
[Config CompoundQueue]
network = CompoundPacketQueueTutorialStep
sim-time-limit = 10s

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