Example: Simulating a Transmission Channel¶
This example network demonstrates how queueing components can be combined to simulate a point-to-point link with a finite bit rate. (This is only interesting as a demonstration of the power of the queueing library, network links are never actually simulated like this in OMNeT++ or INET.)
The network features two hosts (ExampleHost
) communicating. The hosts are
connected by a cable module (ExampleCable
) which adds delay to the connection.
Each host contains a packet source and a packet sink application, connected to
the network level by an interface module (ExampleInterface
).
network ExampleNetworkTutorialStep
{
submodules:
source: ExampleHost {
@display("p=100,100");
}
cable: ExampleCable {
@display("p=200,100");
}
destination: ExampleHost {
@display("p=300,100");
}
connections:
source.lowerOut --> cable.aIn;
cable.aOut --> destination.lowerIn;
destination.lowerOut --> cable.bIn;
cable.bOut --> source.lowerIn;
}
module ExampleHost
{
parameters:
@display("i=device/pc");
gates:
input lowerIn;
output lowerOut;
submodules:
sourceApplication: ActivePacketSource {
@display("p=100,100");
}
destinationApplication: PassivePacketSink {
@display("p=300,100");
}
interface: ExampleInterface {
@display("p=200,200");
}
connections:
sourceApplication.out --> interface.upperIn;
interface.lowerOut --> lowerOut;
lowerIn --> interface.lowerIn;
interface.upperOut --> destinationApplication.in;
}
module ExampleInterface
{
@display("bgb=400,300;i=device/card");
gates:
input lowerIn;
input upperIn;
output lowerOut;
output upperOut;
submodules:
queue: PacketQueue {
@display("p=200,100");
}
server: PacketServer {
@display("p=200,225");
}
connections:
upperIn --> queue.in;
queue.out --> server.in;
server.out --> { @display("m=s"); } --> lowerOut;
lowerIn --> { @display("m=m,66,100,66,0"); } --> upperOut;
}
module ExampleCable
{
parameters:
@display("i=block/mac");
gates:
input aIn;
output aOut;
input bIn;
output bOut;
submodules:
aDelayer: PacketDelayer {
@display("p=100,100");
}
bDelayer: PacketDelayer {
@display("p=100,200");
}
connections:
aIn --> { @display("m=w"); } --> aDelayer.in;
aDelayer.out --> { @display("m=e"); } --> aOut;
bIn --> { @display("m=e"); } --> bDelayer.in;
bDelayer.out --> { @display("m=w"); } --> bOut;
}
[Config ExampleNetwork]
network = ExampleNetworkTutorialStep
sim-time-limit = 10s
*.*.sourceApplication.packetLength = 1B
*.*.sourceApplication.productionInterval = uniform(0s, 2s)
*.*.interface.server.processingTime = uniform(0s, 2s)
*.cable.*Delayer.delay = uniform(0s, 2s)