Blocking/Unblocking Packet Flow (Active Source)¶
The PacketGate module allows packets to pass through when it is open, and blocks them when it is closed. The gate opens and closes according to the configured schedule. There are multiple ways to specify the schedule: simple open/close time parameters, a script parameter, or programmatically (via C++).
In this example network, packets are produced periodically by an active packet source (ActivePacketSource). The packets pass through a packet gate if it is open, otherwise packets are not generated. The packets are consumed by a passive packet sink (PassivePacketSink). The time of opening and closing the gate is configured via parameters.
network Gate1TutorialStep
{
@display("bgb=600,200");
submodules:
producer: ActivePacketSource {
@display("p=100,100");
}
gate: PacketGate {
@display("p=300,100");
}
consumer: PassivePacketSink {
@display("p=500,100");
}
connections:
producer.out --> gate.in;
gate.out --> consumer.in;
}
[Config Gate1]
network = Gate1TutorialStep
sim-time-limit = 10s
*.producer.packetLength = 1B
*.producer.productionInterval = 1s
*.gate.openTime = 3s
*.gate.closeTime = 7s