Table Of Contents
Table Of Contents

Generic Classifier

The PacketClassifier module classifies packets based on the configured packet classifier function.

In this example network, packets are generated by an active packet source (ActivePacketSource). The packets are pushed into a PacketClassifier module, which are connected to two passive packet sinks (PassivePacketSink).

The source generates 1-byte packets, which randomly contain either 0 or 1 as data. The classifier is configured to use the PacketDataClassifier function to classify packets. The function selects the classifier’s output where the output index matches the data contained in the packet. Thus packets with data 0 are pushed to consumer1, and those with data 1 to consumer2.

network GenericClassifierTutorialStep
{
    @display("bgb=600,300");
    submodules:
        producer: ActivePacketSource {
            @display("p=100,100");
        }
        classifier: PacketClassifier {
            @display("p=300,100");
        }
        consumer1: PassivePacketSink {
            @display("p=500,100");
        }
        consumer2: PassivePacketSink {
            @display("p=500,200");
        }
    connections allowunconnected:
        producer.out --> classifier.in;
        classifier.out++ --> consumer1.in;
        classifier.out++ --> consumer2.in;
}
[Config GenericClassifier]
network = GenericClassifierTutorialStep
sim-time-limit = 10s

*.producer.packetLength = 1B
*.producer.packetData = intuniform(0, 1)
*.producer.productionInterval = 1s
*.classifier.classifierClass = "inet::queueing::PacketDataClassifier"