# lisp — UDP 4341/4342 EID-to-RLOC Mapping & SD-Access Overlays (`lisp`)

> **FrameAssembly v3.3.0** · Protocol 48 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/lisp

- **Full Protocol Name:** Locator/ID Separation Protocol (Data & Control Plane)
- **Keyword:** `lisp`
- **OSI Layer & Transport:** Layer 3 · UDP 4341 (Data) / UDP 4342 (Control)
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** RFC 9300, RFC 9301, RFC 8060
- **Wireshark Display Filter:** `lisp || lisp-data`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> LISP (RFC 9300 / 9301) (UDP 4341 (Data) / UDP 4342 (Control))`

## Overview

Under the hood of every Cisco SD-Access campus fabric sits LISP: `lisp` routes control lookups (`maprequest`, `mapreply`, `mapregister`) to UDP `4342` and Instance-ID data packets (`lisp data`) to UDP `4341` automatically.

Locator/ID Separation Protocol (`lisp`, RFC 9300 / RFC 9301) decouples endpoint identities (**EIDs**) from underlay routing locators (**RLOCs**), serving as the control-plane backbone for **Cisco SD-Access (SDA)** campus fabrics (paired with VXLAN-GPO data planes) and multi-site VM mobility overlays. LISP splits across two IANA UDP ports: **UDP `4341`** for data-plane encapsulation (`data`, carrying a 24-bit Instance ID `iid`) and **UDP `4342`** for Map-Server / Map-Resolver control messages (`maprequest`, `mapreply`, `mapregister`, `mapnotify`, and `ecm` Encapsulated Control Messages).

FrameAssembly automatically selects UDP `4341` for `lisp data` and UDP `4342` for control messages, encodes 64-bit echo `nonce` values, sets the Instance-ID bit (`I=1`) when `iid` is specified, and packs AFI-prefixed EID CIDR prefixes and RLOC locator records (`priority`, `weight`).

## Minimal Quickstart (`lisp_quickstart.frasm`)

```frameassembly
host sda_edge { ip 172.16.100.11 }
host map_srv  { ip 172.16.100.2 }

compile {
    sda_edge -> map_srv lisp maprequest iid 4099 nonce 0x1122334455667788 eid "10.50.10.25/32" rloc 172.16.100.11 wait 2ms
    sda_edge <- map_srv lisp mapreply iid 4099 nonce 0x1122334455667788 eid "10.50.10.25/32" rloc 172.16.100.22 priority 1 weight 100
}
```

### Automatic Wire Calculations

- Selects UDP `dstport 4341` automatically for `lisp data` (`lisp-data` dissector) and UDP `dstport 4342` for `maprequest`, `mapreply`, `mapregister`, `mapnotify`, and `ecm` (`lisp` dissector).
- Encodes IANA Address Family Identifiers (`AFI 1` IPv4, `AFI 2` IPv6, plus LCAF Instance ID `Type 2` when `iid` is set) across EID-Prefix and RLOC Locator records.
- Writes the 8-byte RFC 9300 LISP data shim (`N/L/E/V/I` flags + 24-bit `iid`) plus an inner IPv4/IPv6 probe header on `lisp data` frames.

## Practical Lab Example: Campus SD-Access Host Registration, EID Resolution & LISP Data-Plane Forwarding (`lisp_sda_fabric_flow.frasm`)

Traces Edge ETR-B registering host `10.200.5.40/32` with a Map-Server (`mapregister` -> `mapnotify`), Edge ITR-A resolving that EID (`maprequest` -> `mapreply`), and ITR-A encapsulating data to ETR-B on UDP `4341`.

```frameassembly
host itr_edge_a { ip 172.20.0.11 }
host etr_edge_b { ip 172.20.0.22 }
host ms_mr_node { ip 172.20.0.2 }

compile {
    // 1. ETR-B registers mobile endpoint 10.200.5.40/32 in VN Instance 4100 on Map-Server (UDP 4342)
    etr_edge_b -> ms_mr_node lisp mapregister iid 4100 nonce 0xaabbccdd00112233 eid "10.200.5.40/32" rloc 172.20.0.22 priority 1 weight 100 wait 1ms
    etr_edge_b <- ms_mr_node lisp mapnotify iid 4100 nonce 0xaabbccdd00112233 eid "10.200.5.40/32" rloc 172.20.0.22 priority 1 weight 100 wait 2ms
    // 2. ITR-A queries Map-Resolver for 10.200.5.40/32 and receives RLOC 172.20.0.22
    itr_edge_a -> ms_mr_node lisp maprequest iid 4100 nonce 0x9988776655443322 eid "10.200.5.40/32" rloc 172.20.0.11 wait 1ms
    itr_edge_a <- ms_mr_node lisp mapreply iid 4100 nonce 0x9988776655443322 eid "10.200.5.40/32" rloc 172.20.0.22 priority 1 weight 100 wait 2ms
    // 3. ITR-A encapsulates tenant traffic directly to ETR-B over LISP Data Plane (UDP 4341)
    itr_edge_a -> etr_edge_b lisp data iid 4100 eid "10.200.5.40/32" dscp 34 df payload "sda-vn4100-payload"
}
```

```bash
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show lisp_sda_fabric_flow.frasm

# 2. Compile .frasm -> classic .pcap, nanosecond .pcapng, or pipe via '-'
frameassembly lisp_sda_fabric_flow.frasm lisp_sda_fabric_flow.pcap
frameassembly lisp_sda_fabric_flow.frasm lisp_sda_fabric_flow.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse lisp_sda_fabric_flow.pcap lisp_sda_fabric_flow_edited.frasm

# 4. Verify dissected protocol fields in tshark
tshark -r lisp_sda_fabric_flow.pcap
```

## All `lisp` Keywords & Header Options

Packet line pattern: `src_host -> dst_host lisp [data | maprequest | mapreply | mapregister | mapnotify | ecm] [flags <0..255>] [iid <0..16777215>] [nonce <number>] [eid "<cidr>"] [rloc <ip>] [priority <0..255>] [weight <0..255>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `data \| maprequest \| mapreply \| mapregister \| mapnotify \| ecm` | LISP data or control message mode | `maprequest (UDP 4342)` | Selects UDP `4341` Data encapsulation or UDP `4342` Control Type (`1`=Map-Request, `2`=Map-Reply, `3`=Map-Register, `4`=Map-Notify, `8`=Encapsulated Control Message). |
| `iid <0..16777215>` | 24-bit LISP Instance ID / Virtual Network ID | `0 (omitted unless specified)` | Sets the 24-bit Instance ID (`I=1` bit on `data` shim, or LCAF Type `2` Instance-ID wrapper on control EIDs). |
| `eid "<cidr>" \| rloc <ip>` | Quoted IPv4/IPv6 EID prefix & RLOC locator IP | `"10.0.0.0/24", source/dest host IP` | Populates the Endpoint ID prefix record and Routing Locator address in Map-Request/Reply/Register/Notify records. |
| `nonce <number>` | 64-bit unsigned echo/replay nonce | `0x0102030405060708` | Writes the 8-byte Nonce field correlating Map-Request <-> Map-Reply and Map-Register <-> Map-Notify. |
| `priority <0..255> \| weight <0..255>` | 8-bit RLOC locator preference & load-share weight | `priority 1, weight 100` | Sets RLOC Priority (`lower = preferred`, `255 = do not use`) and Weight (`0..100` equal-priority split). |
| `flags <0..255>` | 8-bit LISP flags override | `Auto per message type` | Overrides the upper flag bits in the LISP control or data header. |

## Cross-Layer Options Valid with `lisp`

| Option | Range / Format | Default | Effect |
| --- | --- | --- | --- |
| `wait <number><ns\|us\|ms\|s\|m>` | Time gap (ns, us, ms, s, m) | `10ms` | Advances the packet timestamp clock after sending this packet and before the next packet (`wait 0ns` sends back-to-back). |
| `comment "<text>"` | Quoted UTF-8 annotation | `Omitted` | Attaches an Enhanced Packet Block `opt_comment` annotation when compiling to `.pcapng` (Wireshark `pkt_comment` filter). |
| `payload "<text>" \| hexpayload "<hex>"` | Quoted text or hex bytes (choose one) | `Omitted` | Appends or overrides raw payload bytes (`"deadbeef"`, `"de:ad:be:ef"`, or `"\x01\x02"`) and updates packet lengths and checksums. |
| `srcmac <mac> \| dstmac <mac> \| ethertype <0..65535>` | Colon/hyphen/Cisco MAC · EtherType 0..65535 (e.g. 0x0800) | `Host MAC / RFC multicast MAC / auto EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or standalone Layer 2 16-bit EtherType. |
| `fcs \| badfcs` | Ethernet CRC-32 trailer flags (choose one) | `Omitted` | `fcs` appends a valid IEEE 802.3 4-byte CRC-32 Frame Check Sequence trailer; `badfcs` XOR-corrupts the CRC-32 for NIC/tap negative tests. |
| `vlan <0..4095> [pcp <0..7>] [dei <0\|1>]` | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | `Untagged` | Wraps the packet in an IEEE 802.1Q VLAN tag (`0x8100`) with optional 802.1p QoS priority. |
| `qinq <0..4095> [innervlan <0..4095>]` | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | `Untagged (innervlan 1 when qinq is set)` | Double-tags the packet with outer IEEE 802.1ad S-Tag (`0x88a8`) plus inner IEEE 802.1Q C-Tag (`0x8100`). |
| `mpls <0..1048575> [label <0..1048575>] [exp\|tc <0..7>] [bos <0\|1>] [mplsttl <0..255>]` | Repeatable label stack (0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255) | `Unlabeled (auto bos=0 on outer labels, bos=1 on bottom)` | Prepends one or more 32-bit MPLS label shims (`0x8847`, e.g. `mpls 16000 mpls 24010`) ahead of Layer 2 EoMPLS or Layer 3 payloads. |
| `ttl <0..255> [dscp <0..63>] [ecn <0..3>]` | TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3 | `ttl 64, dscp 0, ecn 0` | Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings. |
| `ipid <0..65535> [df] [mf] [fragoffset <0..8191>] [routeralert] [badipchecksum]` | IPv4 ID, DF/MF flags, offset 0..8191, Router Alert & checksum fault | `ipid 1, flags 0, fragoffset 0, valid RFC 1071 checksum` | Sets IPv4 Identification/fragmentation, injects RFC 2113 Router Alert (`20 04 00 00`), or corrupts the 16-bit IPv4 header checksum (`badipchecksum`). |
| `flowlabel <0..1048575>` | 20-bit IPv6 Flow Label (0..1048575) | `0` | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (valid on IPv6 endpoint pairs only). |
| `srcport <0..65535> \| dstport <0..65535>` | Port number 0..65535 | `srcport 49152 (remembered), UDP 4341 (Data) / UDP 4342 (Control)` | Overrides source or destination port and remembers the port pair automatically on `<-` replies. |
| `badchecksum \| nochecksum` | L4 checksum fault or UDP zero-checksum flag | `Valid RFC checksum / CRC-32c` | `badchecksum` corrupts the L4 checksum for negative firewall/NIC offload tests; `nochecksum` writes `0x0000` in UDP headers. |

## Common Mistakes & Quick Fixes

### Quote CIDR Prefixes Passed to eid "<cidr>"

- **Avoid:** `itr -> mr lisp maprequest eid 10.200.0.0/16 rloc 172.16.0.1`
- **Valid v3.3.0 Syntax:** `itr -> mr lisp maprequest eid "10.200.0.0/16" rloc 172.16.0.1`

In `.frasm`, CIDR prefixes containing `/` (`"10.200.0.0/16"` or `"2001:db8::/48"`) are always double-quoted strings, whereas bare IP literals (`rloc 172.16.0.1`) are unquoted.

### Remember Data Uses UDP 4341 While Control Uses UDP 4342

- **Avoid:** `Filtering Wireshark with udp.port == 4342 when inspecting lisp data`
- **Valid v3.3.0 Syntax:** `Use Wireshark filter lisp || lisp-data (ports 4342 and 4341)`

Wireshark separates `lisp` (UDP `4342` control plane) from `lisp-data` (UDP `4341` data plane).
