# simer-deep/cse-160-project-3 architecture

> Architecture diagram of the GitHub repository simer-deep/cse-160-project-3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/simer-deep/cse-160-project-3
- Repository: https://github.com/simer-deep/cse-160-project-3
- Video tour (about a minute): https://gitdiagram.com/simer-deep/cse-160-project-3/video

## Overview

This is a TinyOS/nesC distance-vector routing project. A command requests a ping; the node routes the ping and reply over learned next hops, while neighbor discovery feeds routing updates. The README also documents poison reverse, route expiry and withdrawal, packet-capacity handling, and a separate flooding path. The Python simulator bindings and command-message adapter are represented as supporting runtime interfaces. Most nesC implementations were not excerpted, so links based on documented behavior cite the README; implementation-level wiring is not inferred.

Main entry points: [`lib/modules/IPRoutingP.nc`](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/IPRoutingP.nc) (IP routing), [`lib/modules/DVExchangeP.nc`](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/DVExchangeP.nc) (DV exchange), [`lib/modules/SimpleSendP.nc`](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/SimpleSendP.nc) (SimpleSend queue), [`lib/modules/CommandHandlerP.nc`](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/CommandHandlerP.nc) (Command handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Command and packet control"]
  node_command_handler["Command handler<br/>[CommandHandlerP.nc]"]
  node_command_format["Command message<br/>[CommandMsg.h]"]
  node_packet_format["Packet format<br/>[packet.h]"]
  node_protocols["Protocol IDs<br/>[protocol.h]"]
  node_channels["Debug channels<br/>[channels.h]"]
end

subgraph group_routing["Routing and discovery"]
  node_neighbor["Neighbor discovery"]
  node_dv_exchange["DV exchange<br/>[DVExchangeP.nc]"]
  node_dv_state[("Route state<br/>[dv.h]")]
  node_ip_routing["IP routing<br/>[IPRoutingP.nc]"]
  node_flooding["Flooding<br/>[FloodingP.nc]"]
end

subgraph group_transport["Packet transport"]
  node_simple_send["SimpleSend queue<br/>[SimpleSendP.nc]"]
  node_send_info["Send buffer item<br/>[sendInfo.h]"]
end

subgraph group_interfaces["Runtime interfaces"]
  node_command_python["Command adapter<br/>[CommandMsg.py]"]
  node_tossim_binding["TOSSIM binding<br/>[TOSSIM.py]"]
  node_socket_format["Socket definitions<br/>[socket.h]"]
end

node_user(("Ping requester"))

node_user -->|"requests ping"| node_command_handler
node_command_handler -->|"starts routed ping"| node_ip_routing
node_neighbor -->|"informs neighbors"| node_dv_exchange
node_dv_exchange -->|"updates routes"| node_dv_state
node_ip_routing -->|"looks up next hop"| node_dv_state
node_ip_routing -->|"submits packets"| node_simple_send
node_dv_exchange -->|"sends updates"| node_simple_send
node_simple_send -->|"queues packet copies"| node_send_info
node_ip_routing -->|"routes replies"| node_ip_routing
node_ip_routing -->|"does not flood"| node_flooding
node_command_python -->|"encodes commands"| node_command_format
node_tossim_binding -.->|"exposes simulator"| node_command_python

click node_command_handler "https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/CommandHandlerP.nc"
click node_command_format "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/CommandMsg.h"
click node_packet_format "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/packet.h"
click node_protocols "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/protocol.h"
click node_channels "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/channels.h"
click node_neighbor "https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/NeighborDiscoveryP.nc"
click node_dv_exchange "https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/DVExchangeP.nc"
click node_dv_state "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/dv.h"
click node_ip_routing "https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/IPRoutingP.nc"
click node_flooding "https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/FloodingP.nc"
click node_simple_send "https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/SimpleSendP.nc"
click node_send_info "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/sendInfo.h"
click node_command_python "https://github.com/simer-deep/cse-160-project-3/blob/main/CommandMsg.py"
click node_tossim_binding "https://github.com/simer-deep/cse-160-project-3/blob/main/TOSSIM.py"
click node_socket_format "https://github.com/simer-deep/cse-160-project-3/blob/main/includes/socket.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_command_handler,node_command_format,node_packet_format,node_protocols,node_channels toneBlue
class node_neighbor,node_dv_exchange,node_dv_state,node_ip_routing,node_flooding toneAmber
class node_simple_send,node_send_info,node_user toneMint
class node_command_python,node_tossim_binding,node_socket_format toneRose
```

## Components

### Command and packet control

- [Command handler](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/CommandHandlerP.nc): `lib/modules/CommandHandlerP.nc`
- [Command message](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/CommandMsg.h): `includes/CommandMsg.h`
- [Packet format](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/packet.h): `includes/packet.h`
- [Protocol IDs](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/protocol.h): `includes/protocol.h`
- [Debug channels](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/channels.h): `includes/channels.h`

### Routing and discovery

- [Neighbor discovery](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/NeighborDiscoveryP.nc): `lib/modules/NeighborDiscoveryP.nc`
- [DV exchange](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/DVExchangeP.nc): `lib/modules/DVExchangeP.nc`
- [Route state](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/dv.h): `includes/dv.h`
- [IP routing](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/IPRoutingP.nc): `lib/modules/IPRoutingP.nc`
- [Flooding](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/FloodingP.nc): `lib/modules/FloodingP.nc`

### Packet transport

- [SimpleSend queue](https://github.com/simer-deep/cse-160-project-3/blob/main/lib/modules/SimpleSendP.nc): `lib/modules/SimpleSendP.nc`
- [Send buffer item](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/sendInfo.h): `includes/sendInfo.h`

### Runtime interfaces

- [Command adapter](https://github.com/simer-deep/cse-160-project-3/blob/main/CommandMsg.py): `CommandMsg.py`
- [TOSSIM binding](https://github.com/simer-deep/cse-160-project-3/blob/main/TOSSIM.py): `TOSSIM.py`
- [Socket definitions](https://github.com/simer-deep/cse-160-project-3/blob/main/includes/socket.h): `includes/socket.h`

### Other components

- **Ping requester**

## Connections

- Ping requester → Command handler: requests ping (evidence: `README.md`)
- Command handler → IP routing: starts routed ping (evidence: `README.md`)
- Neighbor discovery → DV exchange: informs neighbors (evidence: `README.md`)
- DV exchange → Route state: updates routes (evidence: `README.md`)
- IP routing → Route state: looks up next hop (evidence: `README.md`)
- IP routing → SimpleSend queue: submits packets (evidence: `README.md`)
- DV exchange → SimpleSend queue: sends updates (evidence: `README.md`)
- SimpleSend queue → Send buffer item: queues packet copies (evidence: `README.md`)
- IP routing → IP routing: routes replies (evidence: `README.md`)
- IP routing → Flooding: does not flood (evidence: `README.md`)
- Command adapter → Command message: encodes commands (evidence: `CommandMsg.py`)
- TOSSIM binding → Command adapter: exposes simulator
