Table Of Contents
Table Of Contents

Example: Input 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 input “interfaces”. Here is the network, with the conceptual network nodes highlighted:

../../../_images/InputQueueSwitching.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. Input queue switching is susceptible to head-of-line blocking, i.e. if the first packet in the queue cannot be forwarded for some reason (e.g. the target sink is busy receiving another packet), it can delay subsequent packets in the queue that would otherwise be transmittable at the current time.

Note

The next example demonstrates output queue switching, which is not susceptible to head-of-line blocking.

network InputQueueSwitching
{
    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");
        }
        queue[numSources]: PacketQueue {
            @display("p=700,150,col,150");
        }
        server[numSources]: InstantServer {
            @display("p=900,150,col,150");
        }
        join: PacketMultiplexer {
            @display("p=1100,150");
        }
        classifier: ContentBasedClassifier {
            @display("p=1300,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 --> {  datarate = 1Gbps; delay = 1ns; } --> switchRx[i].in;
            switchRx[i].out --> queue[i].in;
            queue[i].out --> server[i].in;
            server[i].out --> join.in++;
        }
        join.out --> classifier.in;
        for i=0..numSinks-1 {
            classifier.out++ --> switchTx[i].in;
            switchTx[i].out --> {  datarate = 1Gbps; delay = 1ns; } --> sinkRx[i].in;
            sinkRx[i].out --> sink[i].in;
        }
}
[Config InputQueueSwitching]
network = InputQueueSwitching
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)]