# vkerob/ft_ping architecture

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

- Interactive diagram: https://gitdiagram.com/vkerob/ft_ping
- Repository: https://github.com/vkerob/ft_ping
- Video tour (about a minute): https://gitdiagram.com/vkerob/ft_ping/video

## Overview

ft_ping is an IPv4 ICMP echo utility. Its workflow parses a target and options, resolves the host, configures an ICMP socket, then sends echo requests and handles replies until stopped or timed out; it prints per-reply information and final packet/RTT statistics. The README also documents payload patterns, flood/preload, TTL/TOS, IP timestamps, numeric output and verbose diagnostics. The map follows the sampled entry point and modules; some receive-path details are only partially excerpted, so uncertain internal wiring is omitted.

Main entry points: [`main.c`](https://github.com/vkerob/ft_ping/blob/main/main.c) (Program entry), [`src/packet.c`](https://github.com/vkerob/ft_ping/blob/main/src/packet.c) (Ping loop), [`src/packet_receive.c`](https://github.com/vkerob/ft_ping/blob/main/src/packet_receive.c) (Receive and decode), [`src/packet_send.c`](https://github.com/vkerob/ft_ping/blob/main/src/packet_send.c) (Echo transmission)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Invocation setup"]
  node_main["Program entry<br/>[main.c]"]
  node_args["Options and help<br/>[parse_args.c]"]
  node_parse_utils["Option parsing helpers<br/>[parse_utils.c]"]
  node_resolve["IPv4 resolution<br/>[utils.c]"]
  node_socket["ICMP socket setup<br/>[socket.c]"]
  node_signals["Signal handling<br/>[signal.c]"]
end

subgraph group_probe["Probe runtime"]
  node_ping["Ping loop<br/>[packet.c]"]
  node_request["Echo request update<br/>[packet_utils.c]"]
  node_send["Echo transmission<br/>[packet_send.c]"]
  node_checksum["ICMP checksum<br/>[packet_utils.c]"]
end

subgraph group_reply["Reply handling"]
  node_receive["Receive and decode<br/>[packet_receive.c]"]
  node_reply_wait["Reply wait<br/>[packet_receive.c]"]
  node_stats["Ping statistics<br/>[packet_utils.c]"]
end

subgraph group_network["Network services"]
  node_kernel["IPv4 ICMP socket"]
  node_name_service["Host name service"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_main
node_main -->|"parses options"| node_args
node_args -->|"validates values"| node_parse_utils
node_main -->|"resolves target"| node_resolve
node_resolve -->|"queries IPv4"| node_name_service
node_main -->|"creates socket"| node_socket
node_socket -->|"configures socket"| node_kernel
node_main -->|"sets handlers"| node_signals
node_main -->|"starts probing"| node_ping
node_ping -->|"updates sequence"| node_request
node_ping -->|"sends requests"| node_send
node_send -->|"calculates checksum"| node_checksum
node_send -->|"sends ICMP"| node_kernel
node_ping -->|"handles readiness"| node_receive
node_receive -->|"receives packets"| node_kernel
node_ping -->|"waits after run"| node_reply_wait
node_reply_wait -->|"processes arrivals"| node_receive
node_receive -.->|"looks up sender"| node_name_service
node_ping -->|"prints summary"| node_stats

click node_main "https://github.com/vkerob/ft_ping/blob/main/main.c"
click node_args "https://github.com/vkerob/ft_ping/blob/main/src/parse_args.c"
click node_parse_utils "https://github.com/vkerob/ft_ping/blob/main/src/parse_utils.c"
click node_resolve "https://github.com/vkerob/ft_ping/blob/main/src/utils.c"
click node_socket "https://github.com/vkerob/ft_ping/blob/main/src/socket.c"
click node_signals "https://github.com/vkerob/ft_ping/blob/main/src/signal.c"
click node_ping "https://github.com/vkerob/ft_ping/blob/main/src/packet.c"
click node_request "https://github.com/vkerob/ft_ping/blob/main/src/packet_utils.c"
click node_send "https://github.com/vkerob/ft_ping/blob/main/src/packet_send.c"
click node_checksum "https://github.com/vkerob/ft_ping/blob/main/src/packet_utils.c"
click node_receive "https://github.com/vkerob/ft_ping/blob/main/src/packet_receive.c"
click node_reply_wait "https://github.com/vkerob/ft_ping/blob/main/src/packet_receive.c"
click node_stats "https://github.com/vkerob/ft_ping/blob/main/src/packet_utils.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_main,node_args,node_parse_utils,node_resolve,node_socket,node_signals,node_user toneBlue
class node_ping,node_request,node_send,node_checksum toneAmber
class node_receive,node_reply_wait,node_stats toneMint
class node_kernel,node_name_service toneRose
```

## Components

### Invocation setup

- [Program entry](https://github.com/vkerob/ft_ping/blob/main/main.c): `main.c`
- [Options and help](https://github.com/vkerob/ft_ping/blob/main/src/parse_args.c): `src/parse_args.c`
- [Option parsing helpers](https://github.com/vkerob/ft_ping/blob/main/src/parse_utils.c): `src/parse_utils.c`
- [IPv4 resolution](https://github.com/vkerob/ft_ping/blob/main/src/utils.c): `src/utils.c`
- [ICMP socket setup](https://github.com/vkerob/ft_ping/blob/main/src/socket.c): `src/socket.c`
- [Signal handling](https://github.com/vkerob/ft_ping/blob/main/src/signal.c): `src/signal.c`

### Probe runtime

- [Ping loop](https://github.com/vkerob/ft_ping/blob/main/src/packet.c): `src/packet.c`
- [Echo request update](https://github.com/vkerob/ft_ping/blob/main/src/packet_utils.c): `src/packet_utils.c`
- [Echo transmission](https://github.com/vkerob/ft_ping/blob/main/src/packet_send.c): `src/packet_send.c`
- [ICMP checksum](https://github.com/vkerob/ft_ping/blob/main/src/packet_utils.c): `src/packet_utils.c`

### Reply handling

- [Receive and decode](https://github.com/vkerob/ft_ping/blob/main/src/packet_receive.c): `src/packet_receive.c`
- [Reply wait](https://github.com/vkerob/ft_ping/blob/main/src/packet_receive.c): `src/packet_receive.c`
- [Ping statistics](https://github.com/vkerob/ft_ping/blob/main/src/packet_utils.c): `src/packet_utils.c`

### Network services

- **IPv4 ICMP socket**
- **Host name service**

### Other components

- **CLI user**

## Connections

- CLI user → Program entry: invokes
- Program entry → Options and help: parses options
- Options and help → Option parsing helpers: validates values
- Program entry → IPv4 resolution: resolves target
- IPv4 resolution → Host name service: queries IPv4
- Program entry → ICMP socket setup: creates socket
- ICMP socket setup → IPv4 ICMP socket: configures socket
- Program entry → Signal handling: sets handlers
- Program entry → Ping loop: starts probing
- Ping loop → Echo request update: updates sequence
- Ping loop → Echo transmission: sends requests
- Echo transmission → ICMP checksum: calculates checksum
- Echo transmission → IPv4 ICMP socket: sends ICMP
- Ping loop → Receive and decode: handles readiness
- Receive and decode → IPv4 ICMP socket: receives packets
- Ping loop → Reply wait: waits after run
- Reply wait → Receive and decode: processes arrivals
- Receive and decode → Host name service: looks up sender
- Ping loop → Ping statistics: prints summary
