Table Of Contents
Table Of Contents

Example: Request/Response-Based Communication

This step contains a simplified version of a client/server and a request/response-based communication. The client initiates the communication by sending a request to the server. The server processes requests in order of arrival, and generates the response traffic.

Request packets are produced periodically and randomly by an active packet source (ActivePacketSource) in the client. The generated requests fall into one of two categories based on the data they contain.

The server processes requests in order, one by one, using a compound consumer (RequestConsumer). Each request is first classified based on the data it contains, and then a certain number of tokens are generated as the request is consumed.

The tokens are added to a response server in a compound producer (ResponseProducer). The response producer generates different traffic randomly over a period of time for each kind of request.

The client consumes the response packets by a passive packet sink (PassivePacketSink).

network RequestResponseTutorialStep
        requestProducer: ActivePacketSource {
        responseConsumer: PassivePacketSink {
        requestConsumer: RequestConsumer {
            responseProducerModule = "^.responseProducer";
        responseProducer: ResponseProducer {
            tokenGenerator.storageModule = "^.^.requestConsumer.server";
    connections allowunconnected:
        requestProducer.out -->;
        responseProducer.out -->;
[Config RequestResponse]
network = RequestResponseTutorialStep
sim-time-limit = 100s

*.requestProducer.packetLength = 1B
*.requestProducer.packetData = intuniform(0, 1)
*.requestProducer.productionInterval = uniform(0s, 2s)
*.requestConsumer.numKind = 2
*.requestConsumer.classifier.typename = "ContentBasedClassifier"
*.requestConsumer.classifier.packetFilters = [expr( == 0), expr( == 1)]
*.requestConsumer.tokenGenerator[0].numTokensPerPacket = 10
*.requestConsumer.tokenGenerator[1].numTokensPerPacket = 10
*.responseProducer.numKind = 2
*.responseProducer.provider[0].packetLength = intuniform(1B, 10B)
*.responseProducer.provider[0].providingInterval = uniform(0s, 0.2s)
*.responseProducer.provider[1].packetLength = intuniform(1B, 100B)
*.responseProducer.provider[1].providingInterval = uniform(0s, 0.2s)