Labeling Packets with Textual Tags¶
The PacketLabeler module attaches a textual label to incoming packets based on a configured packet classifier function. Other modules such as LabelScheduler and LabelClassifier, can use these labels as input for the treatment of the packet. For example, LabelClassifier classifies packets to one of its outputs, based on the presence of certain labels. Labels allow the place of identifying the packet as belonging to some category and the place of acting upon that classification information to be physically separate.
In this example network, packets are produced periodically by an active packet source (ActivePacketSource). The single source is connected to a classifier (LabelClassifier). The packets are consumed by two passive packet sinks (PassivePacketSink). The classifier forwards packets alternately to one or the other sink based on the packet’s label. The label is attached by a PacketLabeler based on the packet length.
In this example network, an active packet source (ActivePacketSource)
generates randomly either 1-byte or 2-byte packets. The packets are pushed into
a PacketLabeler, which attaches the small
text label to 1-byte packets,
and the large
text label to 2-byte packets. The labeler pushes packets into a
LabelClassifier, which classifies packets labeled small
to
consumer1
, and packets labeled large
to consumer2
.
network LabelerTutorialStep
{
@display("bgb=800,300");
submodules:
producer: ActivePacketSource {
@display("p=100,100");
}
labeler: ContentBasedLabeler {
@display("p=300,100");
}
classifier: LabelClassifier {
@display("p=500,100");
}
consumer1: PassivePacketSink {
@display("p=700,100");
}
consumer2: PassivePacketSink {
@display("p=700,200");
}
connections allowunconnected:
producer.out --> labeler.in;
labeler.out --> classifier.in;
classifier.out++ --> consumer1.in;
classifier.out++ --> consumer2.in;
}
[Config Labeler]
network = LabelerTutorialStep
sim-time-limit = 10s
*.producer.packetLength = intuniform(1B, 2B)
*.producer.productionInterval = 1s
*.labeler.packetFilters = [expr(totalLength == 1B), expr(totalLength == 2B)]
*.labeler.labels = "small large"
*.classifier.labelsToGateIndices = "small 0 large 1"