← Back to list

Five steps to recording signals in an OMNET++ project

Define the @statistic keyword in the .ned file of the module.

Chaamihewage · 2023-09-16 04:37 · 269 claps · 2.2 min read
#omnet #c-programming #networking #signaling #diagramming
Open on Medium ↗
Wiki topics: CRY · Crypto & Web3 💻 · Programming

Five steps to recording signals in an OMNET++ project

  1. Define the @statistic keyword in the .ned file of the module.

In the .ned file (ComputerNetwork.ned), I have defined statistics for the ComputerNetwork network module using the @statistics keyword.

I have declared two statistics: total messages received and total delay.

The source attribute specifies which statistic from the child modules contributes to this network-level statistic, and the record attribute indicates how the data should be collected (e.g., “count” for counting occurrences or “vector” for storing a list of values).

2. Define the @signal keyword in the .ned file of the module.

I have defined statistics for the Computer module in the .ned file in this code snippet.

I have declared two statistics: messagesRecieved and delay.

These statistics are specified using the @signal keyword. The “type” attribute indicates the data type of the statistic.

3. Define simsignal_t type in the .h file of the module

In this C++ header file (Computer.h), I have declared two signal types: messagesRecievedSignal and delaySignal.

These signal types are used to handle and manage signals within the “Computer” module. simsignal_t is a data type provided by OMNeT++ for handling signals.

4. Register the signal in the initalise() using the registerSignal() function in the .cc file.

In the initialize() function in the C++ source file (computer.cc), I have performed the following tasks:

  1. Create a message (information) and send it through the module’s port.

  2. Register the two signals, messagesRecievedSignal and delaySignal, using the registerSignal() function. This step informs OMNeT++ to recognize and record these signals during the simulation.

5. Generate statistic values using the emit function in the cc file.

In the handleMessage() function of the C++ source file (computer.cc), you handle incoming messages. Here’s what the code does:

  1. Increments the messagesRecieved count each time a message is received.

  2. Generates a random delay value between 10 and 60.

  3. Send a response message (answer) with the calculated delay.

  4. Uses the emit function to record the messagesRecieved count and delay value using the previously registered signals (messagesRecievedSignal and delaySignal).


메타데이터
post_id
16cae5af54c6
slug
five-steps-to-recording-signals-in-an-omnet-project-16cae5af54c6
url
https://medium.com/@chaamihewage/five-steps-to-recording-signals-in-an-omnet-project-16cae5af54c6
canonical_url
https://medium.com/@chaamihewage/five-steps-to-recording-signals-in-an-omnet-project-16cae5af54c6
author_url
https://medium.com/@chaamihewage
status
ok
fetched_at
2026-07-25 05:43:20