Table Of Contents
Table Of Contents

Example: Output Queue Switching

In this example, we’ll build a network containing three packet sources, a switch, and two packet sinks, from queueing components. The queues in the switch are in the output “interfaces”. Here is the network, with the conceptual network nodes highlighted:

../../../_images/OutputQueueSwitching.png

The sources generate packets, which randomly contain either 0 or 1 as data. The classifier in the switch sends packets based on this data to either sink0 or sink1. Output queue switching isn’t susceptible to head-of-line blocking, as opposed to input queue switching.

network OutputQueueSwitching
{
    parameters:
        int numSources;
        int numSinks;
    submodules:
        source[numSources]: ActivePacketSource {
            @display("p=100,150,col,150");
        }
        sourceTx[numSources]: PacketTransmitter {
            @display("p=300,150,col,150");
        }
        switchRx[numSources]: PacketReceiver {
            @display("p=500,150,col,150");
        }
        join: PacketMultiplexer {
            @display("p=700,150");
        }
        classifier: ContentBasedClassifier {
            @display("p=900,150");
        }
        queue[numSinks]: PacketQueue {
            @display("p=1100,150,col,150");
        }
        server[numSinks]: InstantServer {
            @display("p=1300,150,col,150");
        }
        switchTx[numSinks]: PacketTransmitter {
            @display("p=1500,150,col,150");
        }
        sinkRx[numSinks]: PacketReceiver {
            @display("p=1700,150,col,150");
        }
        sink[numSinks]: PassivePacketSink {
            @display("p=1900,150,col,150");
        }
    connections:
        for i=0..numSources-1 {
            source[i].out --> sourceTx[i].in;
            sourceTx[i].out --> DatarateChannel { delay = 1ns; } --> switchRx[i].in;
            switchRx[i].out --> join.in++;
        }
        join.out --> classifier.in;
        for i=0..numSinks-1 {
            classifier.out++ --> queue[i].in;
            queue[i].out --> server[i].in;
            server[i].out --> switchTx[i].in;
            switchTx[i].out --> DatarateChannel { delay = 1ns; } --> sinkRx[i].in;
            sinkRx[i].out --> sink[i].in;
        }
}
[Config OutputQueueSwitching]
network = OutputQueueSwitching
sim-time-limit = 1000s

*.numSources = 3
*.numSinks = 2

*.*.datarate = 16bps

*.source[*].packetLength = 1B
*.source[*].packetData = intuniform(1, 2)
*.source[*].productionInterval = exponential(1s)

*.classifier.packetFilters = [expr(ByteCountChunk.data % 2 == 0), expr(ByteCountChunk.data % 2 == 1)]