# portrate/reliable-file-transfer-over-udp architecture

> Architecture diagram of the GitHub repository portrate/reliable-file-transfer-over-udp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/portrate/reliable-file-transfer-over-udp
- Repository: https://github.com/portrate/reliable-file-transfer-over-udp

## Overview

This is a Go-Back-N reliable file-transfer application over UDP. A client requests a named file; the server reads and segments it, sends sequenced packets within a sliding window, and retransmits unacknowledged packets after timeouts. The client checks packet integrity and order, writes accepted payloads, and returns cumulative ACKs until EOF. The README also documents configurable packet loss and corruption simulation. The supplied tree contains only the two endpoint programs; responsibilities below are separated conceptually within those files.

Main entry points: [`Client/client.py`](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py) (Client workflow), [`Server/server.py`](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py) (Server workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_runtime["Client workflow<br/>[client.py]"]
  node_client_codec["Packet codec<br/>[client.py]"]
  node_client_integrity["Integrity check<br/>[client.py]"]
  node_client_order["Order and ACK<br/>[client.py]"]
  node_client_output["Output file<br/>[client.py]"]
end

subgraph group_server["Server"]
  node_server_runtime["Server workflow<br/>[server.py]"]
  node_server_codec["Packet codec<br/>[server.py]"]
  node_server_file["File segmentation<br/>[server.py]"]
  node_server_window["Window and retry<br/>[server.py]"]
end

subgraph group_protocol["Transfer protocol"]
end

node_user(("File requester"))
node_network{{"UDP network"}}
node_source_files[("Server files")]

node_user -->|"requests file"| node_client_runtime
node_client_runtime -->|"packs request"| node_client_codec
node_client_runtime -->|"sends request"| node_network
node_network -->|"delivers request"| node_server_runtime
node_server_runtime -->|"unpacks request"| node_server_codec
node_server_runtime -->|"loads segments"| node_server_file
node_server_file -->|"reads file"| node_source_files
node_server_runtime -->|"starts transfer"| node_server_window
node_server_window -->|"packs data and EOF"| node_server_codec
node_server_window -->|"sends or retransmits"| node_network
node_network -->|"delivers packets"| node_client_runtime
node_client_runtime -->|"unpacks packets"| node_client_codec
node_client_runtime -->|"checks payload"| node_client_integrity
node_client_runtime -->|"checks sequence"| node_client_order
node_client_order -->|"writes in-order data"| node_client_output
node_client_order -->|"packs ACK"| node_client_codec
node_client_runtime -->|"sends ACK"| node_network
node_network -->|"delivers ACK"| node_server_window

click node_client_runtime "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py"
click node_client_codec "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py"
click node_client_integrity "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py"
click node_client_order "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py"
click node_client_output "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py"
click node_server_runtime "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py"
click node_server_codec "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py"
click node_server_file "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py"
click node_server_window "https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py"

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_client_runtime,node_client_codec,node_client_integrity,node_client_order,node_client_output toneBlue
class node_server_runtime,node_server_codec,node_server_file,node_server_window,node_source_files toneAmber
class node_user toneMint
class node_network toneIndigo
```

## Components

### Client

- [Client workflow](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py): `Client/client.py`
- [Packet codec](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py): `Client/client.py`
- [Integrity check](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py): `Client/client.py`
- [Order and ACK](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py): `Client/client.py`
- [Output file](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Client/client.py): `Client/client.py`

### Server

- [Server workflow](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py): `Server/server.py`
- [Packet codec](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py): `Server/server.py`
- [File segmentation](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py): `Server/server.py`
- [Window and retry](https://github.com/portrate/reliable-file-transfer-over-udp/blob/main/Server/server.py): `Server/server.py`

### Other components

- **File requester**
- **UDP network**
- **Server files**

## Connections

- File requester → Client workflow: requests file
- Client workflow → Packet codec: packs request
- Client workflow → UDP network: sends request
- UDP network → Server workflow: delivers request
- Server workflow → Packet codec: unpacks request
- Server workflow → File segmentation: loads segments
- File segmentation → Server files: reads file
- Server workflow → Window and retry: starts transfer
- Window and retry → Packet codec: packs data and EOF
- Window and retry → UDP network: sends or retransmits
- UDP network → Client workflow: delivers packets
- Client workflow → Packet codec: unpacks packets
- Client workflow → Integrity check: checks payload
- Client workflow → Order and ACK: checks sequence
- Order and ACK → Output file: writes in-order data
- Order and ACK → Packet codec: packs ACK
- Client workflow → UDP network: sends ACK
- UDP network → Window and retry: delivers ACK
