Content-Based Classifier¶
The ContentBasedClassifier module classifies packets according to the configured packet filter and packet data filter expressions.
In this example network, packets are generated by an active packet source (ActivePacketSource). The packets are pushed into a ContentBasedClassifier, which is connected to two passive packet sinks (PassivePacketSink). The packet source generates 1-byte packets with either 0 or 1 as data randomly. The classifier’s packet data filter is configured to send packets which contain 0 to output 0, and those that contain 1 to output 1.
network ContentBasedClassifierTutorialStep
{
@display("bgb=600,300");
submodules:
producer: ActivePacketSource {
@display("p=100,100");
}
classifier: ContentBasedClassifier {
@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 ContentBasedClassifier]
network = ContentBasedClassifierTutorialStep
sim-time-limit = 10s
*.producer.packetLength = 1B
*.producer.packetData = intuniform(0, 1)
*.producer.productionInterval = 1s
*.classifier.packetFilters = [expr(ByteCountChunk.data == 0), expr(ByteCountChunk.data == 1)]