|
| 1 | +--- |
| 2 | +trigger: always_on |
| 3 | +glob: |
| 4 | +description: This document provides a comprehensive guide for AI agents and developers to navigate, understand, and work with the INET Framework repository. |
| 5 | +--- |
| 6 | +# INET Framework Workspace Rules & Agent Guide |
| 7 | + |
| 8 | +## 1. Project Overview |
| 9 | + |
| 10 | +The INET Framework is an open-source communication networks simulation package for the OMNeT++ simulation environment. It contains models for the Internet stack (TCP, UDP, IPv4, IPv6, OSPF, BGP, etc.), wired and wireless link layers (Ethernet, IEEE 802.11, etc.), support for mobility, MANET protocols, DiffServ, MPLS with RSVP-TE and LDP, and many other protocols and components. |
| 11 | + |
| 12 | +### Key Directories |
| 13 | + |
| 14 | +- **`src/inet`**: The core source code of the framework. |
| 15 | + - `applications`: Traffic generators and application models (HTTP, Ping, DHCP, etc.). |
| 16 | + - `transportlayer`: Transport protocols (TCP, UDP, SCTP). |
| 17 | + - `networklayer`: Network protocols (IPv4, IPv6, ICMP, ARP). |
| 18 | + - `routing`: Routing protocols (AODV, OSPF, BGP, RIP). |
| 19 | + - `linklayer`: L2 protocols (Ethernet, IEEE 802.11, PPP). |
| 20 | + - `physicallayer`: Radio propagation, antenna, and transmitter/receiver models. |
| 21 | + - `mobility`: Node mobility models. |
| 22 | + - `node`: Pre-assembled node models (StandardHost, Router, AccessPoint). |
| 23 | +- **`examples`**: Simulation examples demonstrating various features. Organized by protocol or feature. |
| 24 | +- **`tests`**: Regression and unit tests. |
| 25 | +- **`showcases`**: More complex, tutorial-style simulation scenarios. |
| 26 | +- **`tutorials`**: Step-by-step tutorials for learning INET. |
| 27 | + |
| 28 | +## 2. Development Workflow |
| 29 | + |
| 30 | +### Building the Project |
| 31 | + |
| 32 | +1. **Environment Setup**: Ensure OMNeT++ and INET is in your PATH. i.e. `opp_run`, `inet` and `inet_dbg` are available in the PATH after sourcing the environment. If not, source them from the root of the repository and from ~/omnetpp-6.3.0 |
| 33 | + |
| 34 | +2. **Compile**: Build the project using `make`. Use `MODE=debug` or `MODE=release` to |
| 35 | + select the build mode. Prefer debug mode for development. |
| 36 | + Use parallel build for speed: |
| 37 | + ```bash |
| 38 | + make -j$(nproc) MODE=debug |
| 39 | + ``` |
| 40 | + *Note: The output binary is usually a shared library or the `inet` or `inet_dbg` executable in the `src` directory.* |
| 41 | + |
| 42 | +### Running Simulations |
| 43 | + |
| 44 | +Simulations are defined by `.ned` files (network topology) and `omnetpp.ini` (configuration). |
| 45 | + |
| 46 | +1. **Navigate** to the directory where the .ini file is located (e.g., `examples/aodv`). |
| 47 | +2. **Run** using the `inet` or `inet_dbg` executable depending on build mode with additional arguments as needed: |
| 48 | + |
| 49 | + - `-u Cmdenv`: Runs in command-line mode (faster, no GUI, preferred if no user interaction is required). |
| 50 | + - `-c <ConfigName>`: Selects a configuration from `omnetpp.ini`. |
| 51 | + - `-r <RunNumber>`: Selects a specific run (if using parameter studies). |
| 52 | + |
| 53 | +### Modifying Code |
| 54 | + |
| 55 | +- **NED Files (`.ned`)**: Define module structure, parameters, and gates. |
| 56 | +- **Message Files (`.msg`)**: Define packet and message structures. These generate `_m.h` and `_m.cc` files. |
| 57 | +- **C++ Files (`.cc`, `.h`)**: Implement module behavior. |
| 58 | + - **Simple Modules**: Implement `handleMessage()` or `activity()`. |
| 59 | + - **Channel Models**: Implement transmission logic. |
| 60 | +
|
| 61 | +## 3. Navigation & Understanding |
| 62 | +
|
| 63 | +### Finding Code |
| 64 | +
|
| 65 | +- **Protocols**: Look in `src/inet/<layer>/<protocol>`. |
| 66 | + - Example: AODV is in `src/inet/routing/aodv`. |
| 67 | + - Example: TCP is in `src/inet/transportlayer/tcp`. |
| 68 | +- **Interfaces**: Interface definitions (e.g., `IApp`, `IMac`) are often in `contract` subpackages or base classes. |
| 69 | +
|
| 70 | +### Understanding NED |
| 71 | +
|
| 72 | +- **`simple`**: A basic module implemented in C++. |
| 73 | +- **`module`**: A compound module composed of other modules. |
| 74 | +- **`network`**: A top-level module that can be run as a simulation. |
| 75 | +- **`@display`**: Visual properties (ignore for logic). |
| 76 | +- **`gates`**: Input/output ports for connecting modules. |
| 77 | +
|
| 78 | +### Understanding `.ini` files |
| 79 | +
|
| 80 | +- **`[General]`**: Global settings. |
| 81 | +- **`[Config <Name>]`**: Specific simulation scenarios. |
| 82 | +- **`extends`**: Inherits settings from another config. |
| 83 | +- **`**.param = value`**: Wildcard matching to set module parameters. |
| 84 | +
|
| 85 | +## 4. Testing |
| 86 | +
|
| 87 | +- **Fingerprint Tests**: Regression tests that check if simulation output matches a reference "fingerprint". |
| 88 | + - Located in `tests/fingerprint`. |
| 89 | + - Run via script or `make check` (if configured). |
| 90 | +- **Unit Tests**: C++ unit tests in `tests/unit`. |
| 91 | +
|
| 92 | +## 5. Common Issues & Tips |
| 93 | +
|
| 94 | +- **"Class not found"**: Usually means the C++ class is not linked or not registered with `Define_Module()`. |
| 95 | +- **"Parameter not set"**: A module parameter lacks a default value and wasn't set in `omnetpp.ini`. |
| 96 | +- **Dangling Pointers**: Common in C++. Use OMNeT++'s `check_and_cast` or `dynamic_cast` carefully. |
| 97 | +- **Simulation Time**: Use `simTime()` to get current simulation time. |
| 98 | +
|
| 99 | +## 6. Agent-Specific Instructions |
| 100 | +- **Search First**: Before modifying, search for existing implementations or base classes. |
| 101 | +- **Check Dependencies**: When modifying a module, check its `.ned` file for dependencies (imports). |
| 102 | +- **Verify**: After changes, try to compile (`make`) and run a relevant example to ensure no regressions. |
| 103 | +
|
0 commit comments