MPLS Label Stack Utility

MPLS Label Stack Decoder

Decode raw MPLS shim-header bytes and inspect every label stack entry, including its 20-bit label value, Traffic Class, Bottom-of-Stack bit, TTL and reserved-label meaning.

✓ 20-bit Label ✓ Traffic Class ✓ Bottom of Stack ✓ TTL ✓ Multiple Labels ✓ Reserved Labels
MPLS
MPLS Label Stack Decode
● Ready
Enter one or more complete 4-byte MPLS label stack entries. Spaces, commas, colons, hyphens, line breaks, continuous hexadecimal and 0x-prefixed bytes are accepted.
Strict mode expects exactly one Bottom-of-Stack marker on the final label.
MPLS shim header: every stack entry is exactly 32 bits. Bits 31–12 contain the 20-bit label, bits 11–9 contain Traffic Class, bit 8 is the Bottom-of-Stack bit and bits 7–0 contain TTL.
MPLS Label Stack Decode Result Stack Decoded
Decoded MPLS Stack
Stack Entries
Top Label
Bottom Label
Bottom S Bit
Top TC
Top TTL
Reserved Labels
Total Bytes
S=1 Entries
Highest Label
Lowest TTL
Stack Status
Label Stack Entries
Bit-Level Breakdown
Validation

What Is an MPLS Label Stack?

Multiprotocol Label Switching forwards packets using short label values rather than performing a complete network-layer destination lookup at every MPLS hop. Each MPLS shim header contains a label plus Traffic Class, Bottom-of-Stack and TTL fields.

Multiple MPLS headers can be stacked. The first header is the outer or top label, while the header whose S bit equals 1 identifies the bottom of the MPLS label stack.

MPLS Shim Header Format

31 12 11 9 8 7 0 +-------------------------+------+---+----------------+ | Label (20 bits) | TC | S | TTL (8) | +-------------------------+------+---+----------------+ Label = 20 bits TC = 3 bits S = 1 bit TTL = 8 bits Total = 32 bits = 4 bytes

MPLS Label Field

The Label field occupies the upper 20 bits of the shim header. Its numerical range is 0 through 1,048,575.

20-bit maximum: 2^20 - 1 = 1,048,575 = 0xFFFFF

Label values from 0 through 15 are reserved for special purposes rather than ordinary dynamically assigned MPLS forwarding labels.

MPLS Traffic Class Field

The three-bit Traffic Class field is commonly called TC. Historically this field was also called EXP. Its interpretation can depend on the MPLS QoS model being used.

TC range: 000 = 0 001 = 1 ... 111 = 7

MPLS Bottom-of-Stack Bit

The S bit marks the final label in the current MPLS stack.

S = 0 Another MPLS label follows S = 1 This is the bottom label

A normal label stack should therefore have S=0 on all entries except the final entry, where S=1.

MPLS TTL Field

The final eight bits of every MPLS shim header contain the TTL value. Like IP TTL or Hop Limit, it helps prevent indefinite forwarding loops.

TTL range: 0 through 255

Reserved MPLS Labels

Label Name Meaning
0 IPv4 Explicit NULL Pop the label and continue forwarding as IPv4
1 Router Alert Packet requires special examination
2 IPv6 Explicit NULL Pop the label and continue forwarding as IPv6
3 Implicit NULL Signals penultimate-hop popping; normally not sent in the label stack
7 Entropy Label Indicator Signals that an entropy label follows
13 Generic Associated Channel Label Identifies an associated channel

MPLS Label Stack Example

Top Label: 100 TC = 3 S = 0 TTL = 64 Bottom Label: 200 TC = 1 S = 1 TTL = 63 Decoded stack: [100] ↓ [200, Bottom]

How to Calculate an MPLS Shim Header

A 32-bit MPLS entry can be constructed mathematically from its four fields.

Header = (Label << 12) | (TC << 9) | (S << 8) | TTL

The decoder performs the reverse operation to recover each field.

How to Extract an MPLS Label

Label = Header >>> 12 TC = (Header >>> 9) & 0x7 S = (Header >>> 8) & 0x1 TTL = Header & 0xFF

Single MPLS Label vs Label Stack

An MPLS packet can contain only one label or multiple stacked labels. A single-label packet has its S bit set to 1 in that only shim header.

For multiple labels, the outer labels use S=0 while the final MPLS shim header uses S=1.

MPLS Label Stack Decoder FAQs

How many bytes is an MPLS label header?
Each standard MPLS shim header is exactly four bytes, or 32 bits.
How many bits are used for an MPLS label?
The Label field occupies 20 bits of the 32-bit MPLS shim header.
What does the MPLS S bit mean?
The S bit means Bottom of Stack. A value of 1 marks the final MPLS label in the current stack.
What is MPLS label 0?
Label 0 is IPv4 Explicit NULL.
What is MPLS label 2?
Label 2 is IPv6 Explicit NULL.
What is MPLS label 3?
Label 3 is Implicit NULL. It is commonly used to signal penultimate-hop popping and is not normally transmitted as an ordinary stack entry.
What is the maximum MPLS label value?
The 20-bit field can represent values through 1,048,575, although portions of the label space are reserved or allocated according to MPLS rules.
Can MPLS contain multiple labels?
Yes. MPLS supports a stack of labels. The Bottom-of-Stack bit identifies the last shim header before the encapsulated payload.
Scroll to Top