Skip to content

6LoWPAN header-size budget

Compare IPv6 and 6LoWPAN header and payload budgets for link-local, mesh-local and global addressing.

Packet Pete, your practice guide

Packet Pete
Packet Pete: inspect the input, calculation and observed output before choosing a route.
Predict the reading, then compare it with the measurement.

Python 3 in your browser (JupyterLite)

Python · no install

Tier 2 · Web · paste-in setup · No account

Last tested October 2026.

Open the notebook in your browser and run each Python cell; no install or account is needed.

Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.

Open in your browser (new tab)

Steps

The tool may have moved on since the screenshots were taken — the text steps are the contract.

  1. 1 Step 1

    Do
    In the JupyterLite notebook, run step 1 to set the 127-byte frame and MAC assumptions.
    You will see

    Run the cell. You should see:

    • RFC 4944 section 4 frame example; PHY limit=127 bytes; maximum MAC overhead=25 bytes; available MAC payload=102 bytes
    Why it matters
    The PHY limit exceeds the space available to upper layers.
    Code for step 1
    import platform
    import pyodide
    print(f"Runtime: Python {platform.python_version()} / Pyodide {pyodide.__version__}")
    
    """RFC 6282 IPHC/NHC byte budget with declared address assumptions."""
    
    PHY = 127
    MAC_OVERHEAD = 25  # RFC 4944 section 4 maximum frame overhead example
    MAC_PAYLOAD = PHY - MAC_OVERHEAD
    IPV6 = 40
    UDP = 8
    UNCOMPRESSED_DISPATCH = 1
    IPHC = 2  # includes the dispatch bits, not a further dispatch byte
    NHC_UDP = 1
    UDP_PORTS = 1  # both ports in f0b0::/12, four bits each
    UDP_CHECKSUM = 2  # retained, not elided
    
    CASES = (
        ("link-local, stateless IID elision", 0, 0),
        ("mesh-local, shared context + CID", 0, 1),
        ("global, no shared context", 32, 0),
        ("global, shared context + CID", 0, 1),
    )
    
    
    def compressed(address_bytes, cid_bytes):
        return IPHC + cid_bytes + address_bytes + NHC_UDP + UDP_PORTS + UDP_CHECKSUM
    
    
    def run_step(n):
        if n == 1:
            lines = ["RFC 4944 section 4 frame example",
                     f"PHY limit={PHY} bytes; maximum MAC overhead={MAC_OVERHEAD} bytes",
                     f"available MAC payload={MAC_PAYLOAD} bytes",
                     "Assume no link-layer security, mesh header or fragmentation.",
                     "These additional fields would reduce application space."]
        elif n == 2:
            raw = UNCOMPRESSED_DISPATCH + IPV6 + UDP
            lines = ["Uncompressed IPv6 + UDP case",
                     f"IPv6 dispatch={UNCOMPRESSED_DISPATCH} byte; IPv6={IPV6} bytes; UDP={UDP} bytes",
                     f"header total={raw} bytes",
                     f"application payload={MAC_PAYLOAD}-{raw}={MAC_PAYLOAD-raw} bytes",
                     "The 127-byte PHY limit is not all available to IPv6."]
        elif n == 3:
            lines = ["RFC 6282 compressed field assumptions",
                     f"IPHC={IPHC} bytes (includes dispatch); UDP NHC={NHC_UDP} byte",
                     f"both ports in 0xf0b0-0xf0bf={UDP_PORTS} byte; checksum={UDP_CHECKSUM} bytes",
                     "link-local: IID-derived source/destination => 0 inline address bytes",
                     "mesh-local: shared prefix context adds 1 CID byte",
                     "global: no context => 16+16 inline address bytes"]
        elif n == 4:
            lines = ["Address case | compressed header | app bytes in MAC payload",
                     *[f"{name} | {compressed(a,c):>2} B | {MAC_PAYLOAD-compressed(a,c):>2} B"
                       for name, a, c in CASES],
                     "Numbers assume both UDP ports qualify for 4-bit compression."]
        elif n == 5:
            link = compressed(0, 0)
            global_plain = compressed(32, 0)
            lines = ["RESULT CARD: compression depends on address context",
                     f"uncompressed payload={MAC_PAYLOAD-(1+IPV6+UDP)} B",
                     f"link-local compressed payload={MAC_PAYLOAD-link} B",
                     f"global without context payload={MAC_PAYLOAD-global_plain} B",
                     f"link-local saving={1+IPV6+UDP-link} header bytes",
                     "This does not establish on-air size for a particular MAC/security configuration."]
        else:
            raise ValueError(n)
        lines.append(f"STEP {n} complete")
        print("\n".join(lines))
    
    
    
    run_step(1)
    Real JupyterLite notebook output for step 1 of 6LoWPAN header-size budget.
    Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
  2. 2 Step 2

    Do
    In the JupyterLite notebook, run step 2 to calculate the uncompressed IPv6 plus UDP baseline.
    You will see

    Run the cell. You should see:

    • Uncompressed IPv6 + UDP case; IPv6 dispatch=1 byte; IPv6=40 bytes; UDP=8 bytes; header total=49 bytes
    Why it matters
    An uncompressed baseline makes the comparison meaningful.
    Code for step 2
    run_step(2)
    Real JupyterLite notebook output for step 2 of 6LoWPAN header-size budget.
    Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
  3. 3 Step 3

    Do
    Run step 3 to list every compressed field charged.
    You will see

    Run the cell. You should see:

    • RFC 6282 compressed field assumptions; IPHC=2 bytes (includes dispatch); UDP NHC=1 byte; both ports in 0xf0b0-0xf0bf=1 byte; checksum=2 bytes
    Why it matters
    IPHC, NHC, ports, checksum and context all consume bytes.
    Code for step 3
    run_step(3)
    Real JupyterLite notebook output for step 3 of 6LoWPAN header-size budget.
    Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
  4. 4 Step 4

    Do
    In the JupyterLite notebook, run step 4 to compare address-context budgets.
    You will see

    Run the cell. You should see:

    • Address case | compressed header | app bytes in MAC payload; link-local, stateless IID elision | 6 B | 96 B; mesh-local, shared context + CID | 7 B | 95 B
    Why it matters
    Context availability determines inline address cost.
    Code for step 4
    run_step(4)
    Real JupyterLite notebook output for step 4 of 6LoWPAN header-size budget.
    Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.
  5. 5 Step 5

    Do
    In the JupyterLite notebook, run step 5 to record the savings and the boundary.
    You will see

    Run the cell. You should see:

    • RESULT CARD: compression depends on address context; uncompressed payload=53 B; link-local compressed payload=96 B
    Why it matters
    The budget is conditional on MAC and compression settings.
    Code for step 5
    run_step(5)
    Real JupyterLite notebook output for step 5 of 6LoWPAN header-size budget.
    Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture.

Chapter checks

These questions refer to the chapter’s examples. Use the return links to review their answers.

  1. A 6LoWPAN design promises that every packet will compress to the same tiny header size. What evidence should a reviewer request?

    Return to the chapter’s knowledge check
  2. Which release evidence best proves an IPv6 and 6LoWPAN deployment is ready for constrained IoT traffic?

    Return to the chapter’s knowledge check

Caution

Before you start

Read this before you start.

This RFC-based teaching budget assumes 25 MAC overhead bytes, qualifying compressed ports, no security, no mesh header and no fragmentation. It does not establish the size of a particular on-air frame.

Technical details
Version tested
Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 148.0.7778.96; captureSource playwright:jupyterlite. Date: 2026-10-08.
QR code that opens the 6LoWPAN header-size budget lab page
Open this lab online: https://iotclass.org/labs/lowpan-header-budget.html

Return to IPv6 and 6LoWPAN for IoT · Browse Labs