NetRL Documentation

NetRL is a Python library that wraps Gymnasium environments with realistic communication-channel models. Instead of receiving observations directly, an RL agent or central node receives them through a simulated wireless link — complete with packet loss, propagation delay, retransmissions, and medium contention. The agent sees a sliding-window buffer of past observations rather than the raw current state.

import gymnasium as gym
from netrl import NetworkedEnv, NetworkConfig

env = NetworkedEnv(
    gym.make("CartPole-v1"),
    NetworkConfig(loss_bad=0.3, delay_steps=2, buffer_size=10),
)
obs, info = env.reset()
# obs["observations"].shape == (10, 4)   ← sliding window
# obs["recv_mask"].shape    == (10,)     ← delivery flags
Quick Start

Get running in five minutes with a single-observer networked environment.

Quick Start
Guides

Step-by-step guides for single-observer, multi-view, channel selection, and writing custom channel backends.

Guides
API Reference

Complete class and function reference auto-generated from source.

API Reference
Reference

Architecture overview, ns-3 protocol spec, and troubleshooting.

Reference

Channel backends

Backend

Class

Description

Gilbert–Elliott (default)

GEChannel

Two-state Markov loss model, C++ core, no external dependencies.

802.11a WiFi ⚡ (fast)

NS3WiFiChannelFast

Same CSMA/CA physics as below but runs in-process via a pybind11 C++ extension — no subprocess, no pipe IPC. Built automatically by pip install -e . when ns3 is pip-installed. 15–20× faster.

802.11a WiFi

NS3WifiChannel

CSMA/CA MAC, log-distance path loss, via ns-3 subprocess.

5G mmWave

NS3MmWaveChannel

28 GHz mmWave EPC (3GPP TR 38.901), via ns-3-mmwave subprocess.

5G NR (5G-LENA)

NS3LenaChannel

NR with configurable numerology and beamforming, via 5G-LENA.

Multi-UE WiFi

NS3WifiUEChannel

N UEs sharing one 802.11a infrastructure BSS; realistic contention.

Contents