Skip to content

Commit 9fcfccd

Browse files
committed
ai: added agent rules for .ned .ini
1 parent 4bc7fa7 commit 9fcfccd

3 files changed

Lines changed: 647 additions & 0 deletions

File tree

.agent/rules/architecture.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+

.agent/rules/ini.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
trigger: glob
3+
glob: **/*.ini
4+
description: Rules and best practices for editing and creating INI files in the INET Framework
5+
---
6+
# INET Framework .ini File Rules
7+
8+
## 1. General Structure
9+
10+
- **[General] Section**: Every `.ini` file MUST have a `[General]` section at the top. This section should contain:
11+
- `network`: The name of the NED network to be simulated (unless specified in sub-configs).
12+
- Global simulation limits (e.g., `sim-time-limit`, `cpu-time-limit`).
13+
- Global random number generator settings (`num-rngs`, seeds).
14+
- Shared module parameters (e.g., visualizer settings, global physical environment).
15+
16+
- **Config Sections**: Use `[Config <Name>]` to define specific simulation scenarios.
17+
- **Naming**: Use PascalCase for config names (e.g., `[Config SimpleRREQ]`).
18+
- **Description**: Every config MUST have a `description = "..."` entry explaining its purpose.
19+
- **Inheritance**: Use `extends = <ParentConfig>` to inherit settings from other configurations. This reduces duplication and keeps files organized.
20+
21+
- **Abstract Configs**: If a configuration is intended as a base for others and not to be run directly, set `abstract = true`.
22+
23+
## 2. Parameter Assignment
24+
25+
- **Wildcards**: Use wildcards (`**`, `*`) judiciously to set parameters for multiple modules.
26+
- `**` matches any number of hierarchy levels.
27+
- `*` matches one level or a part of a name.
28+
- Example: `**.mobility.constraintAreaMaxX = 600m` (sets it for all mobility modules anywhere).
29+
30+
- **Specific Parameters**: Be specific when necessary to avoid unintended side effects.
31+
- Example: `*.host[0].app[0].destAddr = "host[1]"`
32+
33+
- **Units**: ALWAYS include units for physical quantities (time, distance, bitrate, etc.).
34+
- Time: `s`, `ms`, `us`, `ns`
35+
- Distance: `m`, `km`
36+
- Data rate: `bps`, `kbps`, `Mbps`, `Gbps`
37+
- Data size: `B`, `kB`, `MB`
38+
- Power: `W`, `mW`, `dBm`
39+
40+
- **Random Distributions**: Use OMNeT++ distribution functions for variability.
41+
- Example: `uniform(1s, 5s)`, `exponential(100ms)`, `normal(10mps, 2mps)`.
42+
43+
## 3. Organization and Style
44+
45+
- **Comments**: Use `#` for comments.
46+
- Group related settings with section headers (e.g., `# Mobility`, `# Application`, `# Wi-Fi`).
47+
- Explain complex parameter choices.
48+
49+
- **Ordering**:
50+
1. `[General]`
51+
2. Base configurations (Abstract)
52+
3. Specific configurations (derived from base)
53+
54+
- **Formatting**:
55+
- Use spaces around `=` (e.g., `key = value`).
56+
- Indentation is not strictly required but consistent indentation improves readability.
57+
58+
## 4. Common Patterns
59+
60+
- **Visualizers**: Enable visualizers in the `[General]` or base config to aid debugging and demonstration.
61+
- Example: `*.visualizer.interfaceTableVisualizer.displayInterfaceTables = true`
62+
63+
- **Scenario Manager**: Use `ScenarioManager` with XML scripts for dynamic events (node failure, mobility changes).
64+
- `*.scenarioManager.script = xmldoc("scenario.xml")`
65+
66+
- **Configurators**: Use `Ipv4NetworkConfigurator` (or IPv6 equivalent) for automatic IP address assignment and routing.
67+
- `*.configurator.config = xml(...)` can be used for custom configuration.
68+
69+
## 5. Example Template
70+
71+
```ini
72+
[General]
73+
network = MyNetwork
74+
sim-time-limit = 100s
75+
num-rngs = 3
76+
# ... global settings ...
77+
78+
[Config Base]
79+
description = "Base configuration with common settings"
80+
abstract = true
81+
# ... common parameters ...
82+
83+
[Config Scenario1]
84+
description = "Scenario 1: Low traffic"
85+
extends = Base
86+
# ... specific settings ...
87+
88+
[Config Scenario2]
89+
description = "Scenario 2: High traffic"
90+
extends = Base
91+
# ... specific settings ...
92+
```

0 commit comments

Comments
 (0)