Protocol 14 of 81Layer 2FrameAssembly v3.3.0
Raw .mdllms-full.txt
nshNetwork Service Header (Service Function Chaining)

nsh — RFC 8300 Service Function Chaining (SPI, SI & Context)

Default Port / Protocol
EtherType 0x894f
Host Endpoint Rule
MAC-Only or IP
Wireshark Display Filter
nsh
Standards & Specs
RFC 8300, RFC 7665
Wire Stack:Ethernet IINSH (RFC 8300) (EtherType 0x894f)
L2 Tagging: vlan · qinq · repeatable mpls · fcsHost Family: MAC-Only or IPL3 QoS & TTL: N/A (Pure L2)L4 State: L2 Ethernet

What It Does on the Wire

Steer packets through NFV firewall and scrubber chains on 0x894f: nsh packs the 24-bit spi, hop-decrementing si, 16-byte mdtype 1 context, and enforces the 6-bit ttl <= 63 rule at compile time.

Network Service Header (nsh, RFC 8300, EtherType 0x894f) is the IETF data-plane encapsulation for Service Function Chaining (SFC) across NFV firewalls, DPI scrubbers, carrier NATs, and SD-WAN service appliances. An NSH header combines a 4-byte Base Header (version, oam bit, 6-bit ttl, length, mdtype, nextproto), a 4-byte Service Path Header (24-bit Service Path Identifier spi + 8-bit Service Index si), and fixed 16-byte (mdtype 1) or variable TLV (mdtype 2) Context Headers.

FrameAssembly validates the 6-bit NSH ttl bound (0..63) at compile time, auto-computes the 6-bit NSH Length field in 4-byte words (0x06 for MD Type 1, 0x02+ for MD Type 2), and maps symbolic nextproto names ("ipv4", "ipv6", "ethernet", "nsh", "mpls").

01. Application

Service Function Forwarder (SFF) Service-Index Decrement Testing

Model packets traversing a 3-hop NFV chain (spi 100, si 255 -> si 254 -> si 253) with subscriber policy metadata carried inside the 16-byte MD Type 1 context.

02. Application

SFC Active OAM Liveness & Loop Detection (ttl <= 63)

Set the oam flag and low ttl 1 values to verify Service Function Forwarder loop-drop counters and SFC OAM responders.

03. Application

FD.io VPP, Open vSwitch & SmartNIC NSH Offload Captures

Generate clean 0x894f Ethernet-NSH test vectors for hardware parser pipelines and Wireshark nsh dissection.

Fig. 1 · RFC Octet & Bit Schematic

RFC Wire Header Layout (nsh)

Select any 32-bit wire word or field slice below to inspect which .frasm modifiers control those octets and what defaults the compiler writes.

0 ··············· 15 · 16 ··············· 31 bit
Selected Wire Segment
NSH (RFC 8300) Wire PDU & Payload (Variable)
Controlling .frasm Modifiers
nsh version · oam · ttl · mdtype · nextproto · payload · hexpayload
Compiler Default Behavior
RFC-compliant NSH (RFC 8300) defaults (RFC 8300)

Minimal Quickstart (nsh_quickstart.frasm)

Select Preview Packets to compile in-browser and inspect timestamps + wire byte lengths, or open directly in the Playground.

nsh_quickstart.frasm6 lines
Open in Playground
host sff_ingress { mac 00:1c:73:50:00:01 }
host sf_firewall { mac 00:1c:73:50:00:10 }
compile {
sff_ingress -> sf_firewall nsh spi 100 si 255 mdtype 1 nextproto "ipv4" context "00000001000000020000000300000004"
}

Handled Automatically on the Wire

  • Sets Ethernet II EtherType to 0x894f and bit-packs the 2-bit version, oam flag, 6-bit ttl (default 63), and 6-bit 32-bit-word Length field.
  • Packs the 24-bit Service Path Identifier (spi) and 8-bit Service Index (si) into the 4-byte Service Path Header.
  • Pads or sizes the Context Header to 16 bytes for mdtype 1 (Length = 6) or 4-byte-aligned variable octets for mdtype 2.
Multi-Frame Example

Multi-Hop NFV Service Chain: Classifier -> Firewall SF -> IPS SF (SI 255 -> 253)

Traces a packet classified onto Service Path spi 420 stepping through two Service Functions as si decrements from 255 to 254 to 253, followed by an oam health check.

nsh_sfc_chain.frasm16 lines
Open in Playground
host classifier { mac 00:1c:73:01:00:01 }
host sff_core { mac 00:1c:73:01:00:02 }
host sf_ngfw { mac 00:1c:73:01:00:11 }
host sf_ips { mac 00:1c:73:01:00:12 }
compile {
// 1. Classifier pushes NSH SPI 420, SI 255 with tenant ID in MD Type 1 context
classifier -> sff_core nsh spi 420 si 255 ttl 63 mdtype 1 nextproto "ethernet" context "000001a4000000100000000000000000" wait 1ms
// 2. SFF steers packet through NGFW (decrements SI -> 254) and IPS (SI -> 253)
sff_core -> sf_ngfw nsh spi 420 si 255 ttl 62 mdtype 1 nextproto "ethernet" context "000001a4000000100000000000000000" wait 1ms
sf_ngfw -> sff_core nsh spi 420 si 254 ttl 62 mdtype 1 nextproto "ethernet" context "000001a4000000100000000100000000" wait 1ms
sff_core -> sf_ips nsh spi 420 si 254 ttl 61 mdtype 1 nextproto "ethernet" context "000001a4000000100000000100000000" wait 1ms
sf_ips -> sff_core nsh spi 420 si 253 ttl 61 mdtype 1 nextproto "ethernet" context "000001a4000000100000000300000000" wait 2ms
// 3. SFC OAM probe on MD Type 2 (variable-length context omitted, Length = 2)
classifier -> sff_core nsh oam spi 420 si 255 ttl 63 mdtype 2 nextproto "nsh"
}
Terminal Commands (FrameAssembly CLI v3.3.0)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show nsh_sfc_chain.frasm

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

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

# 4. Verify dissected protocol fields in tshark
tshark -r nsh_sfc_chain.pcap -Y "nsh"

All nsh Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after nsh:

src_host -> dst_host nsh [version <0..3>] [oam] [ttl <0..63>] [mdtype <1|2>] [nextproto <0..255 | "ipv4" | "ipv6" | "ethernet" | "nsh" | "mpls">] [spi <0..16777215>] [si <0..255>] [context "<hex>"]
Keyword / OptionAccepted ValueDefaultEffect on Packet
version <0..3>2-bit NSH version (0..3)0Sets the 2-bit RFC 8300 NSH Base Header Version (0 standard).
oamBoolean flagUnset (0)Sets the O (Operations, Administration, and Maintenance) bit in the NSH Base Header.
ttl <0..63>6-bit NSH Service Plane TTL (0..63)63Sets the 6-bit loop-prevention TTL inside the NSH Base Header (validated <= 63 at compile time).
mdtype <1|2>Metadata Type (1 = Fixed 16B, 2 = Variable)1Selects Fixed 4x32-bit Context Header (1, Length=6) or Variable Context (2).
nextproto <"ipv4"|"ipv6"|"ethernet"|"nsh"|"mpls"|0..255>Protocol name or 8-bit code"ipv4" (0x01)Sets Next Protocol (1=IPv4, 2=IPv6, 3=Ethernet, 4=NSH, 5=MPLS).
spi <0..16777215>24-bit Service Path Identifier1Writes the big-endian 24-bit Service Path ID in bytes 4..6 of the NSH header.
si <0..255>8-bit Service Index255Writes the 8-bit Service Index hop counter in byte 7 of the NSH header.
context "<hex>"Quoted hex bytes (16B on mdtype 1)16 zero bytes on mdtype 1Populates the NSH Mandatory Context Header (mdtype 1) or variable metadata (mdtype 2).

Cross-Layer Wrappers Valid with nsh

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

8 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
comment "<text>"Quoted UTF-8 annotationOmittedAttaches 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)OmittedAppends 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 EtherTypeOverrides the 14-byte Ethernet II source MAC, destination MAC, or standalone Layer 2 16-bit EtherType.
fcs | badfcsEthernet CRC-32 trailer flags (choose one)Omittedfcs 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..1UntaggedWraps 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..4095Untagged (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.

Gotchas & Quick Fixes

NSH ttl Is Strictly 6 Bits (0..63, Never 64 or 255)

Rejected
sff1 -> sff2 nsh spi 100 ttl 64
Valid v3.3.0 Syntax
sff1 -> sff2 nsh spi 100 ttl 63

RFC 8300 allocates a 6-bit TTL field in the NSH Base Header (max 63), so ttl 64 or ttl 255 fails compile-time semantic validation on nsh statements.

Use nextproto (Never nextheader) on NSH Frames

Rejected
sff1 -> sff2 nsh spi 100 nextheader 1
Valid v3.3.0 Syntax
sff1 -> sff2 nsh spi 100 nextproto "ipv4"

nextproto sets the NSH Base Header Next Protocol field ("ipv4", "ipv6", "ethernet", "nsh", "mpls").

Field Guide 05
VLANs, QinQ, MPLS, Tunnel Soup & Dual-Stack IPv6