# cjtarre/cmsc-131-lab1-starter architecture

> Architecture diagram of the GitHub repository cjtarre/cmsc-131-lab1-starter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cjtarre/cmsc-131-lab1-starter
- Repository: https://github.com/cjtarre/cmsc-131-lab1-starter

## Overview

renpkt is a small command-line tool for decoding and encoding fixed 20-byte IPv4 headers. Users choose a decode or encode command: decoding reads a header, extracts its fields, checks its checksum, and prints the result; encoding parses field options, constructs a header, and writes it. The assembly routines implement bit-level transformations and checksum arithmetic, called through the C driver. The README documents the encode/checksum relationship; assembly implementations were not sampled, so other internal calls are not inferred.

Main entry points: [`driver.c`](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c) (Decode command), [`encode.asm`](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/encode.asm) (Header encoder), [`checksum.asm`](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/checksum.asm) (Checksum routine), [`cdecl.h`](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/cdecl.h) (cdecl macros)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driver["Command-line driver"]
  node_decode_flow["Decode command<br/>[driver.c]"]
  node_encode_flow["Encode command<br/>[driver.c]"]
  node_read_print["File and output<br/>[driver.c]"]
end

subgraph group_assembly["Assembly routines"]
  node_decode["Header decoder<br/>[decode.asm]"]
  node_encode["Header encoder<br/>[encode.asm]"]
  node_checksum["Checksum routine<br/>[checksum.asm]"]
end

subgraph group_abi["Calling convention"]
  node_cdecl["cdecl macros<br/>[cdecl.h]"]
end

node_user(("CLI user"))

node_user -->|"selects decode"| node_decode_flow
node_user -->|"selects encode"| node_encode_flow
node_decode_flow -->|"reads header"| node_read_print
node_decode_flow -->|"calls decoder"| node_decode
node_decode_flow -->|"checks checksum"| node_checksum
node_decode_flow -->|"prints fields"| node_read_print
node_encode_flow -->|"calls encoder"| node_encode
node_encode_flow -->|"writes header"| node_read_print
node_encode -->|"uses checksum"| node_checksum
node_decode_flow -->|"uses declarations"| node_cdecl
node_encode_flow -->|"uses declarations"| node_cdecl

click node_decode_flow "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c"
click node_encode_flow "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c"
click node_read_print "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c"
click node_decode "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/decode.asm"
click node_encode "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/encode.asm"
click node_checksum "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/checksum.asm"
click node_cdecl "https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/cdecl.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_decode_flow,node_encode_flow,node_read_print,node_user toneBlue
class node_decode,node_encode,node_checksum toneAmber
class node_cdecl toneMint
```

## Components

### Command-line driver

- [Decode command](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c): `driver.c`
- [Encode command](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c): `driver.c`
- [File and output](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/driver.c): `driver.c`

### Assembly routines

- [Header decoder](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/decode.asm): `decode.asm`
- [Header encoder](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/encode.asm): `encode.asm`
- [Checksum routine](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/checksum.asm): `checksum.asm`

### Calling convention

- [cdecl macros](https://github.com/cjtarre/cmsc-131-lab1-starter/blob/main/cdecl.h): `cdecl.h`

### Other components

- **CLI user**

## Connections

- CLI user → Decode command: selects decode (evidence: `driver.c`)
- CLI user → Encode command: selects encode (evidence: `driver.c`)
- Decode command → File and output: reads header (evidence: `driver.c`)
- Decode command → Header decoder: calls decoder (evidence: `driver.c`)
- Decode command → Checksum routine: checks checksum (evidence: `driver.c`)
- Decode command → File and output: prints fields (evidence: `driver.c`)
- Encode command → Header encoder: calls encoder (evidence: `driver.c`)
- Encode command → File and output: writes header (evidence: `driver.c`)
- Header encoder → Checksum routine: uses checksum
- Decode command → cdecl macros: uses declarations (evidence: `driver.c`)
- Encode command → cdecl macros: uses declarations (evidence: `driver.c`)
