Table Of Contents
Table Of Contents

Content-Based Filtering (Active Source)

The ContentBasedFilter module filters packets according to the configured packet filter and packet data filter. Packets that match the filter expressions are pushed/popped on the output; non-maching packets are dropped.

In this example network, an active packet source (ActivePacketSource) generates 1-byte and 2-byte packets randomly. The source pushes packets into a filter (ContentBasedFilter), which pushes 1-byte packets into a passive packet sink (PassivePacketSink) and drops 2-byte ones.

../../../_images/Filter1.png
network Filter1TutorialStep
{
    @display("bgb=600,200");
    submodules:
        producer: ActivePacketSource {
            @display("p=100,100");
        }
        filter: ContentBasedFilter {
            @display("p=300,100");
        }
        consumer: PassivePacketSink {
            @display("p=500,100");
        }
    connections allowunconnected:
        producer.out --> filter.in;
        filter.out --> consumer.in;
}
[Config Filter1]
network = Filter1TutorialStep
sim-time-limit = 10s

*.producer.packetLength = intuniform(1B, 2B)
*.producer.productionInterval = 1s
*.filter.packetFilter = expr(totalLength == 1B)