# sbktckp/computer-networks architecture

> Architecture diagram of the GitHub repository sbktckp/computer-networks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sbktckp/computer-networks
- Repository: https://github.com/sbktckp/computer-networks

## Overview

#### Purpose and Scope
This is a C17 Computer Networks lab repository. The present assignment teaches low-level C concepts needed for networking work: pointer mutation, struct passing semantics, byte-level representation, packet reconstruction, and host endianness.

#### Entry Points and Execution
Each `.c` source file is an independently runnable program with its own `main`. The repository-level `run` launcher selects a question and optionally its compact variant; it forwards remaining CLI arguments to the selected executable. `Makefile` builds all programs and cleans generated binaries.

Core entry paths:
- `run`
- `Makefile`
- `Assignment 2 - C Basics and Endianness/README.md`

#### Assignment Module Layout
Assignment 2 is organized as five numbered exercises, with a full instructional implementation at the assignment root and a behavior-equivalent minimal implementation in `compact/`.

Primary module paths:
- `Assignment 2 - C Basics and Endianness/2.1_swap_pointer.c`
- `Assignment 2 - C Basics and Endianness/2.2_struct_call_by_value_address.c`
- `Assignment 2 - C Basics and Endianness/2.3_byte_extraction.c`
- `Assignment 2 - C Basics and Endianness/2.4_struct_pkt_reassemble.c`
- `Assignment 2 - C Basics and Endianness/2.5_endianness_check.c`

#### Pointer and Struct Semantics
The first two programs establish C memory and parameter-passing behavior. The pointer swap exercise mutates caller-owned values through addresses, while the struct exercise contrasts a copied struct received by value against mutation through a struct address.

Relevant paths:
- `Assignment 2 - C Basics and Endianness/2.1_swap_pointer.c`
- `Assignment 2 - C Basics and Endianness/2.2_struct_call_by_value_address.c`
- `Assignment 2 - C Basics and Endianness/compact/2.2_struct_call_by_value_address.c`

#### Byte Representation and Packet Assembly
The byte extraction exercise interprets an integer’s individual bytes, using unsigned-byte handling to avoid signed-extension issues. The packet reassembly exercise is the assignment’s networking-oriented boundary: it combines component byte fields into a reconstructed structured packet/value representation.

Relevant paths:
- `Assignment 2 - C Basics and Endianness/2.3_byte_extraction.c`
- `Assignment 2 - C Basics and Endianness/2.4_struct_pkt_reassemble.c`
- `Assignment 2 - C Basics and Endianness/compact/2.4_struct_pkt_reassemble.c`

#### Endianness Boundary
Host byte order is explicitly detected rather than assumed, using a union-based probe. This connects in-memory integer layout to network-data interpretation and complements extraction/reassembly behavior.

Relevant paths:
- `Assignment 2 - C Basics and Endianness/2.5_endianness_check.c`
- `Assignment 2 - C Basics and Endianness/compact/2.5_endianness_check.c`

#### Runtime and Build Constraints
Programs target standard C17 and compile with GCC under warning-focused flags (`-Wall -Wextra -Wpedantic`). The intended runtime environments are Codespaces, WSL, Linux, and macOS; no application server, database, or external network service is involved. Full sources prioritize explanatory comments; compact sources preserve output while minimizing implementation size.

Relevant paths:
- `Assignment 2 - C Basics and Endianness/compact/README.md`
- `Makefile`
- `run`

Main entry points: [`Makefile`](https://github.com/sbktckp/computer-networks/blob/main/Makefile) (Makefile), [`run`](https://github.com/sbktckp/computer-networks/blob/main/run) (run launcher), [`Assignment 2 - C Basics and Endianness/2.4_struct_pkt_reassemble.c`](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.4_struct_pkt_reassemble.c) (Packet reassembly), [`Assignment 2 - C Basics and Endianness/README.md`](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/README.md) (Assignment guide)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_full["Full instructional programs"]
  node_swap["Pointer swap<br/>C executable<br/>[2.1_swap_pointer.c]"]
  node_struct["Struct passing<br/>C executable"]
  node_bytes["Byte extraction<br/>C executable"]
  node_packet["Packet reassembly<br/>C executable"]
  node_endian["Endianness probe<br/>C executable"]
end

subgraph group_compact["Compact equivalents"]
  node_compact_readme["Compact guide<br/>documentation<br/>[README.md]"]
  node_compact_struct["Compact struct passing<br/>C executable"]
  node_compact_packet["Compact packet reassembly<br/>C executable"]
  node_compact_endian["Compact endianness probe<br/>C executable"]
end

node_launcher["run launcher<br/>CLI selector"]
node_make["Makefile<br/>build system"]
node_readme["Assignment guide<br/>documentation<br/>[README.md]"]
node_c17["C17 / GCC runtime<br/>native toolchain"]

node_readme -.->|"introduces"| node_swap
node_readme -.->|"introduces"| node_struct
node_readme -.->|"introduces"| node_bytes
node_readme -.->|"introduces"| node_packet
node_readme -.->|"introduces"| node_endian
node_make -->|"builds"| node_swap
node_make -->|"builds"| node_struct
node_make -->|"builds"| node_bytes
node_make -->|"builds"| node_packet
node_make -->|"builds"| node_endian
node_make -->|"builds"| node_compact_struct
node_make -->|"builds"| node_compact_packet
node_make -->|"builds"| node_compact_endian
node_launcher -->|"runs selected exercise"| node_swap
node_launcher -->|"runs selected exercise"| node_struct
node_launcher -->|"runs selected exercise"| node_bytes
node_launcher -->|"runs selected exercise"| node_packet
node_launcher -->|"runs selected exercise"| node_endian
node_launcher -->|"runs compact variant"| node_compact_struct
node_launcher -->|"runs compact variant"| node_compact_packet
node_launcher -->|"runs compact variant"| node_compact_endian
node_struct -.->|"equivalent behavior"| node_compact_struct
node_packet -.->|"equivalent behavior"| node_compact_packet
node_endian -.->|"equivalent behavior"| node_compact_endian
node_bytes -.->|"byte fields inform assembly"| node_packet
node_endian -.->|"interprets host byte layout"| node_packet
node_c17 -->|"compiles with"| node_make

click node_launcher "https://github.com/sbktckp/computer-networks/blob/main/run"
click node_make "https://github.com/sbktckp/computer-networks/blob/main/Makefile"
click node_readme "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/README.md"
click node_swap "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.1_swap_pointer.c"
click node_struct "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.2_struct_call_by_value_address.c"
click node_bytes "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.3_byte_extraction.c"
click node_packet "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.4_struct_pkt_reassemble.c"
click node_endian "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.5_endianness_check.c"
click node_compact_readme "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/README.md"
click node_compact_struct "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/2.2_struct_call_by_value_address.c"
click node_compact_packet "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/2.4_struct_pkt_reassemble.c"
click node_compact_endian "https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/2.5_endianness_check.c"

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_swap,node_struct,node_bytes,node_packet,node_endian toneBlue
class node_compact_readme,node_compact_struct,node_compact_packet,node_compact_endian toneAmber
class node_launcher,node_make,node_readme,node_c17 toneNeutral
```

## Components

### Full instructional programs

Independently runnable C17 exercises.

- [Pointer swap](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.1_swap_pointer.c): C executable · Mutates caller-owned values through pointers. · `Assignment 2 - C Basics and Endianness/2.1_swap_pointer.c`
- [Struct passing](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.2_struct_call_by_value_address.c): C executable · Contrasts by-value copies with address-based mutation. · `Assignment 2 - C Basics and Endianness/2.2_struct_call_by_value_address.c`
- [Byte extraction](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.3_byte_extraction.c): C executable · Extracts integer bytes using unsigned-byte handling. · `Assignment 2 - C Basics and Endianness/2.3_byte_extraction.c`
- [Packet reassembly](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.4_struct_pkt_reassemble.c): C executable · Combines byte fields into a structured packet representation. · `Assignment 2 - C Basics and Endianness/2.4_struct_pkt_reassemble.c`
- [Endianness probe](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/2.5_endianness_check.c): C executable · Detects host byte order with a union-based probe. · `Assignment 2 - C Basics and Endianness/2.5_endianness_check.c`

### Compact equivalents

Minimal implementations with equivalent behavior.

- [Compact guide](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/README.md): documentation · Documents the minimal exercise variants. · `Assignment 2 - C Basics and Endianness/compact/README.md`
- [Compact struct passing](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/2.2_struct_call_by_value_address.c): C executable · Minimal equivalent of struct passing behavior. · `Assignment 2 - C Basics and Endianness/compact/2.2_struct_call_by_value_address.c`
- [Compact packet reassembly](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/2.4_struct_pkt_reassemble.c): C executable · Minimal equivalent of packet reconstruction. · `Assignment 2 - C Basics and Endianness/compact/2.4_struct_pkt_reassemble.c`
- [Compact endianness probe](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/compact/2.5_endianness_check.c): C executable · Minimal equivalent host-order detection. · `Assignment 2 - C Basics and Endianness/compact/2.5_endianness_check.c`

### Other components

- [run launcher](https://github.com/sbktckp/computer-networks/blob/main/run): CLI selector · Selects an exercise and forwards CLI arguments. · `run`
- [Makefile](https://github.com/sbktckp/computer-networks/blob/main/Makefile): build system · Builds all exercise binaries and cleans outputs. · `Makefile`
- [Assignment guide](https://github.com/sbktckp/computer-networks/blob/main/Assignment%202%20-%20C%20Basics%20and%20Endianness/README.md): documentation · Explains the assignment exercises and usage. · `Assignment 2 - C Basics and Endianness/README.md`
- **C17 / GCC runtime**: native toolchain · Warning-focused GCC compilation on local Unix-like environments.

## Connections

- Assignment guide → Pointer swap: introduces
- Assignment guide → Struct passing: introduces
- Assignment guide → Byte extraction: introduces
- Assignment guide → Packet reassembly: introduces
- Assignment guide → Endianness probe: introduces
- Makefile → Pointer swap: builds
- Makefile → Struct passing: builds
- Makefile → Byte extraction: builds
- Makefile → Packet reassembly: builds
- Makefile → Endianness probe: builds
- Makefile → Compact struct passing: builds
- Makefile → Compact packet reassembly: builds
- Makefile → Compact endianness probe: builds
- run launcher → Pointer swap: runs selected exercise
- run launcher → Struct passing: runs selected exercise
- run launcher → Byte extraction: runs selected exercise
- run launcher → Packet reassembly: runs selected exercise
- run launcher → Endianness probe: runs selected exercise
- run launcher → Compact struct passing: runs compact variant
- run launcher → Compact packet reassembly: runs compact variant
- run launcher → Compact endianness probe: runs compact variant
- Struct passing → Compact struct passing: equivalent behavior
- Packet reassembly → Compact packet reassembly: equivalent behavior
- Endianness probe → Compact endianness probe: equivalent behavior
- Byte extraction → Packet reassembly: byte fields inform assembly
- Endianness probe → Packet reassembly: interprets host byte layout
- C17 / GCC runtime → Makefile: compiles with
