HNet is a routing emulator for a hypothetical hierarchical computer network. It models a system with an alternative, human-readable IP addressing format, designed around geographic and administrative hierarchy.
HNet uses a globally structured address format that is both machine-readable and human-friendly. Each address reflects a fixed geographic and administrative location.
[2 bytes] Continent — "EU", "AS", "NA", "AF", "SA", "OC", "AN"
[2 bytes] Country — ISO-3166 code, e.g., "RU", "US", "FR"
[4 bytes] Provider — Alphanumeric identifier, e.g., "MGTS", "NTNT"
[4 bytes] Subnet — Hex value, unique within the provider, e.g., 045A
[4 bytes] Host — Device identifier within the subnet, e.g., 1C2F
NA:US:NTNT:045A:1C2F
^ ^ ^ ^ ^
| | | | └── Device 0x1C2F
| | | └──────── Subnet 0x045A
| | └────────────── Provider "NTNT"
| └───────────────── Country "US"
└──────────────────── Continent "NA"
Each router (HNetRouter
) follows this internal structure:
Stores mappings from hierarchical address prefixes to interface identifiers:
HashMap<String, String> // prefix => interface_id
Prefixes are matched in order of decreasing specificity:
EU:RU:MGTS:045A:1C2F
EU:RU:MGTS:045A:*
EU:RU:MGTS:*:*
EU:RU:*:*:*
EU:*:*:*:*
Maps interface IDs to neighboring routers (connected peers):
HashMap<String, HNetRouter> // interface_id => connected router
- A packet is received by a router.
- The router generates all prefix variants for the destination (from most to least specific).
- It checks the
routing_table
for the first matching prefix. - It retrieves the associated
interface_id
and forwards the packet through the interface usinginterfaces
. - The process repeats until the packet reaches its final destination or no route is found.
by AndcoolSystems, 17 May, 2025