# bobzhuyb/ns3-rdma architecture

> Architecture diagram of the GitHub repository bobzhuyb/ns3-rdma, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bobzhuyb/ns3-rdma
- Repository: https://github.com/bobzhuyb/ns3-rdma

## Overview

##### Project type and purpose
- Type: A modular network-simulator framework (not a client-server web app).
- Purpose: Simulate RDMA over Converged Ethernet (RoCEv2) including custom congestion-control (DCQCN, TIMELY), PFC/ECN, and switch buffering logic.

##### High-level components
a. Build & Deployment
– Visual Studio solution (windows/ns-3-dev/ns-3-dev.sln)
– waf/Makemake build scripts (Makefile, waf, src/*/wscript)
b. Entry point
– main/third.cc → main.exe
– Configuration loader (mix/config.txt)
c. Simulation Core
– src/core (scheduler, events, object-factory, config parser)
– src/mpi (distributed simulation)
– src/emulation hooks, Python bindings
d. Network Stack Modules
– src/internet (IPv4/IPv6, sockets, routing)
– src/point-to-point, src/csma, src/wifi, src/virtual-net-device, etc.
– Helpers & containers (helper/*.cc/.h) for easy topology setup
e. RDMA Extensions & Switch
– src/point-to-point/model/qbb-net-device* (DCQCN, PFC)
– src/network/model/broadcom-node* & utils/broadcom-egress-queue*
– src/applications/model/udp-echo-client.cc (rate throttle)
– src/internet/model/seq-ts-header* (infiniBand sequence & timestamp)
f. Examples & Tests
– examples/* for end-to-end scenarios
– src/*/test and src/test for unit/regression tests
g. Output & Tracing
– Trace generation scattered among network, flow-monitor, stats modules
– Trace file (mix/mix.tr)

##### Component interactions
- User starts main.exe with config.txt
- main calls “Helper” objects to build NodeContainers & NetDeviceContainers
- Helpers instantiate “Model” objects (e.g., QbbNetDeviceModel, BroadcomNodeModel)
- Model objects register with the Core Scheduler and Event system
- During simulation:
– Packet events flow through DeviceModel → ChannelModel → ProtocolModel
– DCQCN/TIMELY modules react on ECN/PFC marks
– Broadcom-model monitors buffer occupancy and triggers PFC/ECN
- Traces are emitted to output modules

##### Architectural patterns & design principles
- Modular plugin-style architecture—each protocol/device is a self-contained module under src/<module>/{model,helper,test,doc}
- Factory and helper patterns for object creation and topology setup
- Event-driven discrete-event simulation core
- Separation of concerns:
– core scheduler & objects
– network layers (L1-L4 implementations)
– application layer (UDP-based RDMA client)
– switch/buffer models

##### Technologies & frameworks
- C++17 on NS-3 v3.17 core
- waf + Makefile for Linux builds
- Visual Studio 2015 solution for Windows
- Python bindings for scripting & tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & IDE
    subgraph "Build & IDE"
        B1["Makefile"]:::build
        B2["waf"]:::build
        B3["NS-3 Solution\nns-3-dev.sln"]:::build
    end

    %% Entry Point
    subgraph "Entry Point"
        EP2["config.txt"]:::external
        EP1["main.cpp\n(main.exe)"]:::core
    end

    %% Simulation Core
    subgraph "Simulation Core"
        C1["Core Scheduler"]:::core
        C2["Event System"]:::core
        C3["Config Parser"]:::core
        C4["Distributed Simulator (MPI)"]:::core
        C5["Emulation Hooks & Python Bindings"]:::core
    end

    %% Network Stack Modules
    subgraph "Network Stack Modules"
        N1["IPv4/IPv6 Routing"]:::network
        N2["Point-to-Point NetDevice"]:::network
        N3["CSMA"]:::network
        N4["WiFi"]:::network
        N5["Virtual NetDevice"]:::network
    end

    %% RDMA & Switch Extensions
    subgraph "RDMA & Switch Extensions"
        R1["QbbNetDeviceModel"]:::rdma
        R2["BroadcomNodeModel"]:::rdma
        R3["BroadcomEgressQueue"]:::rdma
        R4["UDP Echo Client"]:::rdma
        R5["Seq-TS Header"]:::rdma
    end

    %% Helpers & Examples
    subgraph "Helpers & Examples"
        H1["Helpers"]:::examples
        H2["Examples"]:::examples
        H3["Tests"]:::examples
    end

    %% Output & Tracing
    subgraph "Output & Tracing"
        O1["Trace Source Infra"]:::output
        O2["Internet Trace Helper"]:::output
        O3["Network Trace Helper"]:::output
        O4["trace.txt"]:::external
    end

    %% Connections
    EP2 -->|"load config"| EP1
    EP1 -->|"instantiate"| H1
    H1 -->|"setup topology"| N1
    H1 -->|"setup topology"| N2
    H1 -->|"setup topology"| N3
    H1 -->|"setup topology"| N4
    H1 -->|"setup topology"| N5
    H1 -->|"instantiate"| R1
    H1 -->|"instantiate"| R2
    H1 -->|"instantiate"| R3
    H1 -->|"instantiate"| R4
    H1 -->|"instantiate"| R5

    N1 -->|"register"| C1
    N2 -->|"register"| C1
    N3 -->|"register"| C1
    N4 -->|"register"| C1
    N5 -->|"register"| C1
    R1 -->|"register"| C1
    R2 -->|"register"| C1
    R3 -->|"register"| C1
    R4 -->|"register"| C1
    R5 -->|"register"| C1

    C1 -->|"schedule event"| C2
    C2 -->|"emit trace"| O1
    C2 -->|"emit trace"| O2
    C2 -->|"emit trace"| O3
    O3 -->|"write file"| O4

    H1 -->|"run examples"| H2
    H1 -->|"run tests"| H3

    %% Click Events
    click B1 "https://github.com/bobzhuyb/ns3-rdma/tree/master/Makefile"
    click B2 "https://github.com/bobzhuyb/ns3-rdma/tree/master/waf"
    click B3 "https://github.com/bobzhuyb/ns3-rdma/blob/master/windows/ns-3-dev/ns-3-dev.sln"
    click EP1 "https://github.com/bobzhuyb/ns3-rdma/blob/master/windows/ns-3-dev/main/main.cpp"
    click EP2 "https://github.com/bobzhuyb/ns3-rdma/blob/master/windows/ns-3-dev/x64/Release/mix/config.txt"
    click C3 "https://github.com/bobzhuyb/ns3-rdma/tree/master/src/core/wscript"
    click C4 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/mpi/model/distributed-simulator-impl.cc"
    click C5 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/emu/model/emu-net-device.cc"
    click N1 "https://github.com/bobzhuyb/ns3-rdma/tree/master/src/internet/wscript"
    click N2 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/point-to-point/model/point-to-point-net-device.cc"
    click N3 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/csma/model/csma-net-device.cc"
    click N4 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/wifi/helper/wifi-helper.cc"
    click N5 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/virtual-net-device/model/virtual-net-device.cc"
    click R1 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/point-to-point/model/qbb-net-device.cc"
    click R2 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/network/model/broadcom-node.cc"
    click R3 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/network/utils/broadcom-egress-queue.cc"
    click R4 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/applications/model/udp-echo-client.cc"
    click R5 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/internet/model/seq-ts-header.cc"
    click H2 "https://github.com/bobzhuyb/ns3-rdma/tree/master/examples/"
    click H3 "https://github.com/bobzhuyb/ns3-rdma/tree/master/src/core/test/"
    click O1 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/core/model/trace-source-accessor.cc"
    click O2 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/internet/helper/internet-trace-helper.cc"
    click O3 "https://github.com/bobzhuyb/ns3-rdma/blob/master/src/network/helper/trace-helper.cc"
    click O4 "https://github.com/bobzhuyb/ns3-rdma/blob/master/windows/ns-3-dev/x64/Release/mix/trace.txt"

    %% Styles
    classDef build fill:#cccccc,stroke:#333333
    classDef core fill:#bbdefb,stroke:#1e88e5
    classDef network fill:#c8e6c9,stroke:#43a047
    classDef rdma fill:#ffecb3,stroke:#ffb300
    classDef examples fill:#e1bee7,stroke:#8e24aa
    classDef output fill:#ffe0b2,stroke:#fb8c00
    classDef external fill:#f5f5f5,stroke:#999999,stroke-dasharray: 2 2
```
