moonip
00 · showcase

Two instruments · one of them is the library

Two things
a packet does.

A datagram is cut apart and put back together by the numbers in its header. An address is asked a short series of questions until one of them answers. The first happens in a stack, not in this package; the second is this package's whole job. Both are drawn here with the numbers they actually have.

01 · reassembly

RFC 791 · offset in eights · the more-fragments flag

One datagram, six fragments,
no order.

The wire hands over fragment 4 first, then 1, then 6. Where each one belongs is not in the order it arrives but in its offset field: thirteen bits, counted in eight-byte units from the start of the original. Scroll, and the buffer fills around the holes.

id 0x1a2b 47 bytes of payload six fragments scroll to deliver

0 / 47 bytes · 0 / 6 fragments

    fig. 1 The payload is the sentence the exhibit is about — the offset says where; the length says how much — in ASCII, so a gap in the buffer is a gap in the reading. No library call is made here: fragmentation is a datagram operation and this package never holds a datagram. What is exact is the arithmetic — offsets on eight-byte boundaries, the flag clear on the last fragment only, and the byte counts adding to 47.

    02 · trace

    seven questions · the first yes stops it

    An address,
    asked seven times.

    Classification is not one comparison. It is a walk down the rows of two registries — loopback, multicast, link local, private — and the walk ends at the first row that claims the address. A public address climbs all seven rungs before the last one answers; ::1 stops at the second; and the one block that belongs to neither side reaches the bottom with nothing to show for it.

    classification 100.64.0.1 Addr::is_…
    01is_unspecified()0.0.0.0 · ::·
    02is_loopback()127.0.0.0/8 · ::1·
    03is_multicast()224.0.0.0/4 · ff00::/8·
    04is_link_local()169.254.0.0/16 · fe80::/10·
    05is_site_local()fec0::/10·
    06is_private()the rows the registry marks off·
    07is_global()what is left·
    verdict reading

    asking the compiler's answers, in order

    fig. 2 Each rung is one predicate the package exposes, called on the address you typed; the answers are read from the same compiled build that runs the explorer. The order is the order the two IANA registries list their rows, read from the specific to the general — it is a way of showing the walk, not the code path, which compares against prefix tables instead of asking seven times.

    03 · why these two

    exact, both ways

    A question with a checkable answer.

    A fragment is 47 bytes of ASCII and a set of offsets; an address is 32 or 128 bits. Neither needs a socket, and neither answer depends on the network being there. That is the whole shape of this package: values in, text out, and a refusal that says where it stopped being possible.

    The guide walks the surface in ten steps; the explorer takes blocks apart with the same compiled build; the reference is generated from the interface the compiler emits.

    top top