msdp

package
v0.511.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package msdp decodes MSDP (Multicast Source Discovery Protocol) packets per RFC 3618. MSDP is the inter-domain multicast protocol that completes the multicast trio alongside IGMP (host↔router, covered by `igmp_decode`) and PIM (router↔router intra-domain, covered by `pim_decode`). Each PIM-SM domain has its own Rendezvous Points (RPs); MSDP connects RPs across domains so that a receiver in one domain can join a multicast group whose source is in another.

Operationally, every major Internet exchange + carrier core that carries multicast traffic (financial-market data feeds, IPTV peering, content distribution) runs MSDP between RPs over TCP port 639.

Wrap-vs-native judgement

Native. RFC 3618 is fully public; MSDP messages are
plain TLVs: 1-byte Type + 2-byte Length (including the
3-byte header) + per-type body. No crypto, no
compression. Operators paste MSDP bytes (TCP port 639)
from a `tcpdump -X tcp port 639` line or a Wireshark
Follow-TCP-Stream view and get the documented type +
body breakdown.

What this package covers

  • **3-byte TLV header** (RFC 3618 §3):

  • byte 0: **Type** with **6-entry name table**: 1 IPv4 Source-Active, 2 IPv4 SA Request, 3 IPv4 SA Response, 4 Keepalive, 6 Notification, 7 Traceroute in Progress (deprecated), 8 Traceroute Reply (deprecated).

  • bytes 1-2: Length (uint16 BE; total including this 3-byte header).

  • **IPv4 Source-Active body** (Type 1; RFC 3618 §4.1):

  • byte 0: Entry Count (uint8; number of (S, G) entries).

  • bytes 1-4: RP Address (IPv4 — the originating Rendezvous Point).

  • **Entry × Entry Count** (each 12 bytes):

  • 3-byte Reserved.

  • 1-byte Sprefix Len (typically 32; the source prefix length).

  • 4-byte Group Address (IPv4 multicast).

  • 4-byte Source Address (IPv4 unicast).

  • Optional encapsulated multicast datagram (raw hex — typically the first packet from a new source, sent to bootstrap MSDP peers that haven't yet built (S, G) state).

  • **IPv4 SA Request body** (Type 2; RFC 3618 §4.2):

  • byte 0: Reserved.

  • bytes 1-4: Group Address (IPv4 multicast).

  • **IPv4 SA Response body** (Type 3; RFC 3618 §4.3) — same layout as Source-Active.

  • **Keepalive body** (Type 4) — empty (header only; length = 3).

  • **Notification body** (Type 6; RFC 3618 §6.1):

  • byte 0: **O (Open) bit** (high bit) + 7-bit **Error Code** with **7-entry name table** (RFC 3618 §6.1): 1 Message Header Error, 2 SA-Request Error, 3 SA-Message/SA-Response Error, 4 Hold Timer Expired, 5 Finite State Machine Error, 6 Notification, 7 Cease.

  • byte 1: Error Subcode.

  • bytes 2+: Data (variable; surfaced as hex).

What this package does NOT cover (deliberately out of scope)

  • TCP framing — feed MSDP bytes after the TCP payload extraction. MSDP runs on TCP port 639.

  • MSDP state-machine reasoning (peer setup, SA cache, hold-timer expiry, mesh-group RPF check) — higher- level analysis.

  • Encapsulated multicast datagram dissection — when SA carries a bootstrap data packet, it's surfaced as opaque hex; operators can feed it into `ip_packet_decode` to walk the inner IP frame.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Type     int    `json:"type"`
	TypeName string `json:"type_name"`
	Length   int    `json:"length"`
	BodyHex  string `json:"body_hex,omitempty"`

	// Decoded forms populated for known types.
	SourceActive *SourceActiveBody `json:"source_active,omitempty"`
	SARequest    *SARequestBody    `json:"sa_request,omitempty"`
	SAResponse   *SourceActiveBody `json:"sa_response,omitempty"`
	Notification *NotificationBody `json:"notification,omitempty"`
}

Message is one MSDP TLV record.

type NotificationBody

type NotificationBody struct {
	OpenBit       bool   `json:"open_bit"`
	ErrorCode     int    `json:"error_code"`
	ErrorCodeName string `json:"error_code_name"`
	ErrorSubcode  int    `json:"error_subcode"`
	DataHex       string `json:"data_hex,omitempty"`
}

NotificationBody is the decoded body of a Type 6 Notification.

type Result

type Result struct {
	Messages   []Message `json:"messages"`
	TotalBytes int       `json:"total_bytes"`
	Notes      []string  `json:"notes,omitempty"`
}

Result is the top-level decoded view of an MSDP packet. A single TCP segment may contain multiple TLVs, so the decoder returns a slice of Messages.

func Decode

func Decode(hexStr string) (*Result, error)

Decode parses one or more MSDP TLVs from hex.

type SARequestBody

type SARequestBody struct {
	GroupAddress string `json:"group_address"`
}

SARequestBody is the decoded body of a Type 2 SA Request.

type SourceActiveBody

type SourceActiveBody struct {
	EntryCount        int                 `json:"entry_count"`
	RPAddress         string              `json:"rp_address"`
	Entries           []SourceActiveEntry `json:"entries"`
	EncapsulatedHex   string              `json:"encapsulated_datagram_hex,omitempty"`
	EncapsulatedBytes int                 `json:"encapsulated_datagram_bytes,omitempty"`
}

SourceActiveBody is the decoded body of a Type 1 (or Type 3) Source-Active / SA Response message.

type SourceActiveEntry

type SourceActiveEntry struct {
	Index         int    `json:"index"`
	SprefixLength int    `json:"sprefix_length"`
	GroupAddress  string `json:"group_address"`
	SourceAddress string `json:"source_address"`
}

SourceActiveEntry is one (S, G) record from an SA / SA Response body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL