How to modify behavior of a module in Omnet++ and inet with a source.cc file

51 Views Asked by At

I am very new to Omnet++ and network simulation/engineering in general and as such there are some pretty significant holes in my knowledge. Currently I am working on a project involving directional antennas and I have been tasked with creating a simulation. The idea is to have a directional antenna search for other directional antennas to establish connection. I have broken the problem up into a series of smaller steps to help me learn how to use the software, but I have come to a bit of a roadblock, specifically in how simulations work with .ini files.

From my understanding, network topology is created in the ned file and the behavior and properties of the network topology are set in the ini file. My issue is this: the direction that an antenna is pointing is based on mobility and I do not know how to implement the logic to search for other antennas. I've been through the Omnet++ and Inet tutorials and know that I can change the behavior of my simulation with a source.cc file, but I am unclear as to how to do that with an existing model, such as the adhocHost model which is used to implement directional antennas in inet's directional antenna showcase.

As for the specifics of my current project, I am trying to get an antenna to look in the direction of M sectors in a clockwise order. If it detects another antenna, then it stores that antenna's name and the direction it was pointing. Ultimately this will evolve into a much more advanced project involving writing MAC level protocols, but I am trying to put the simulation together piece by piece.

I found that I could change the direction of the antennas on the AdhocHost using code that I mostly took from the directional antenna showcase provided by inet. I did this by setting the antenna's mobility module to linearmobility with zero speed and by changing the initial heading angle. The problem here comes down to the behavior being limited by the ini file. I don't know how to write in logic to change that direction after a set time, let alone how to initiate a handshake. I recognize that I will need to use a source.cc file and I have a basic flow chart for a state machine when it comes time to write the code, I just don't know what I need to edit, change, or create.

I also experimented with CircleMobility, but I don't think it's a good fit for our eventual final model which will ideally switch immediately to different sectors and stay there for a small time rather than moving constantly in a circle.

1

There are 1 best solutions below

0
Rudi On

As you require a special kind of mobility (antenna orientation is considered a mobility too), you will have to create your own mobility model (which is a simple module with its own c++ code) and then set up the simulation to use that module for the antenna mobility.

While you can combine the existing mobility models in various tricky ways using only INI files, new behavior can be added only with c++ code.

I suggest to take a look at FacoingMobility, see the code, create your own copy (with a different name of curse) and once it is working, start modifying the code to implement your own specific mobility behavior.