# goose — IEC 61850-8-1 Substation Protection Trip Events (0x88b8) (`goose`)

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

- **Full Protocol Name:** IEC 61850-8-1 Generic Object Oriented Substation Events
- **Keyword:** `goose`
- **OSI Layer & Transport:** Layer 2 · EtherType 0x88b8
- **Host Endpoint Rule:** MAC-Only or IP
- **Standards:** IEC 61850-8-1, IEEE 802.1Q
- **Wireshark Display Filter:** `goose`
- **Wire Encapsulation:** `Ethernet II -> IEC 61850 GOOSE (EtherType 0x88b8)`

## Overview

Substation protection relays don’t wait for TCP handshakes when a 500 kV line faults — `goose` fires ASN.1 BER `0x88b8` multicast trip events (`stnum` increments, `sqnum` resets) in under 4 milliseconds.

Generic Object Oriented Substation Events (`goose`, IEC 61850-8-1) delivers sub-4-millisecond protective-relay trip commands, breaker status interlocks, and busbar protection signals directly over Layer 2 Ethernet (`EtherType 0x88b8`) to IEC multicast MACs (`01:0c:cd:01:00:00..ff`). Every GOOSE frame carries an 8-byte header (`APPID`, `Length`, `Reserved1`, `Reserved2`) wrapping an ASN.1 BER `goosePdu` (`0x61`) with `gocbRef`, `timeAllowedtoLive`, `datSet`, `goID`, `stNum` (state change counter), `sqNum` (retransmission sequence), `simulation`, `confRev`, `ndsCom`, and `allData`.

FrameAssembly encodes valid ASN.1 BER tag-length-value trees and IEC multicast destination MACs automatically—making it safe to validate substation NERC CIP IDS rules (`stNum` jump / spoofed trip injection) without touching energized 230kV switchgear.

## Minimal Quickstart (`goose_quickstart.frasm`)

```frameassembly
host relay_ied1 { mac 00:1b:21:61:85:01 }
host breaker_mu { mac 01:0c:cd:01:00:01 }

compile {
    relay_ied1 -> breaker_mu goose appid 0x1001 gocbref "IED1PROT/LLN0$GO$gcbTrip" datset "IED1PROT/LLN0$TripSet" stnum 1 sqnum 0 vlan 100 pcp 6
}
```

### Automatic Wire Calculations

- Sets Ethernet II EtherType to `0x88b8` and targets IEC 61850 GOOSE multicast `01:0c:cd:01:00:01` when `dstmac` / peer MAC is default.
- Writes the 8-byte IEC 61850 header (`APPID`, total `Length`, `Reserved 0x0000 0x0000`) and constructs a complete ASN.1 BER `0x61` `goosePdu` sequence.
- Computes exact BER definite lengths across nested context-specific tags `[0]`..`[11]` so Wireshark `goose` dissects zero malformed-BER warnings.

## Practical Lab Example: Substation Breaker Trip Event: Steady Heartbeat -> Fault Trip -> Fast Retransmit (`goose_breaker_trip_sequence.frasm`)

Captures steady-state `stnum 1` GOOSE heartbeats on Substation VLAN 200 (`pcp 6`), followed by an overcurrent trip (`stnum 2`, `sqnum 0..2`) at exponential sub-4ms intervals.

```frameassembly
host feeder_ied { mac 00:1b:21:50:01:10 }
host bus_group  { mac 01:0c:cd:01:00:10 }

compile {
    // 1. Steady-state heartbeat before fault (stNum=1, sqNum=42, TTL=2000ms)
    feeder_ied -> bus_group goose appid 0x1010 gocbref "BAY01_IED/LLN0$GO$BreakerTrip" datset "BAY01_IED/LLN0$ProtTrip" goid "BAY01_TRIP" stnum 1 sqnum 42 timetolive 2000 confrev 1 numdatsetentries 2 vlan 200 pcp 6 wait 10ms
    // 2. Overcurrent fault! State number increments (stNum=2), sequence resets (sqNum=0)
    feeder_ied -> bus_group goose appid 0x1010 gocbref "BAY01_IED/LLN0$GO$BreakerTrip" datset "BAY01_IED/LLN0$ProtTrip" goid "BAY01_TRIP" stnum 2 sqnum 0 timetolive 4 confrev 1 numdatsetentries 2 vlan 200 pcp 6 wait 2ms
    // 3. Fast IEC 61850 retransmission burst (sqNum=1, sqNum=2)
    feeder_ied -> bus_group goose appid 0x1010 gocbref "BAY01_IED/LLN0$GO$BreakerTrip" datset "BAY01_IED/LLN0$ProtTrip" goid "BAY01_TRIP" stnum 2 sqnum 1 timetolive 8 confrev 1 numdatsetentries 2 vlan 200 pcp 6 wait 4ms
    feeder_ied -> bus_group goose appid 0x1010 gocbref "BAY01_IED/LLN0$GO$BreakerTrip" datset "BAY01_IED/LLN0$ProtTrip" goid "BAY01_TRIP" stnum 2 sqnum 2 timetolive 16 confrev 1 numdatsetentries 2 vlan 200 pcp 6
}
```

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

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

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

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

## All `goose` Keywords & Header Options

Packet line pattern: `src_host -> dst_host goose [appid <0..65535>] [gocbref "<text>"] [timetolive <number>] [datset "<text>"] [goid "<text>"] [stnum <number>] [sqnum <number>] [simulation] [confrev <number>] [ndscom] [numdatsetentries <number>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `appid <0..65535>` | 16-bit IEC 61850 APPID (typically 0x0000..0x3fff or 0x8000..0xbfff) | `0x1000` | Sets bytes 0..1 of the 8-byte GOOSE header. |
| `gocbref "<text>"` | GOOSE Control Block Reference string | `"IED1/LLN0$GO$gcb01"` | Encodes BER context tag `[0]` (`gocbRef`). |
| `timetolive <number>` | Milliseconds (timeAllowedtoLive) | `2000` | Encodes BER context tag `[1]` (`timeAllowedtoLive` in milliseconds). |
| `datset "<text>"` | Dataset ObjectReference string | `"IED1/LLN0$dataset01"` | Encodes BER context tag `[2]` (`datSet`). |
| `goid "<text>"` | GOOSE Identifier string | `"GOOSE1"` | Encodes BER context tag `[3]` (`goID`). |
| `stnum <number>` | State Number counter (>= 1) | `1` | Encodes BER context tag `[5]` (`stNum`, increments on every dataset value transition). |
| `sqnum <number>` | Sequence Number counter (>= 0) | `0` | Encodes BER context tag `[6]` (`sqNum`, increments on heartbeats; resets to `0` on state change). |
| `simulation` | Boolean test-mode flag | `false (0x00)` | Sets BER context tag `[7]` (`simulation = true`) so live relays ignore test-bench GOOSE frames. |
| `confrev <number>` | Configuration Revision counter | `1` | Encodes BER context tag `[8]` (`confRev` SCL configuration revision). |
| `ndscom` | Needs Commissioning boolean flag | `false` | Sets BER context tag `[9]` (`ndsCom = true`). |
| `numdatsetentries <number>` | Number of dataset members | `1` | Encodes BER context tag `[10]` (`numDatSetEntries`) and matching `allData` `[11]` entries. |

## Cross-Layer Options Valid with `goose`

| 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. |

## Common Mistakes & Quick Fixes

### Use timetolive for GOOSE Hold Time (ttl Is Reserved for Layer 3 IP)

- **Avoid:** `ied1 -> bus goose ttl 2000 st_num 1`
- **Valid v3.3.0 Syntax:** `ied1 -> bus goose timetolive 2000 stnum 1`

GOOSE runs directly over Layer 2 (`0x88b8`); use `timetolive` for the IEC 61850 `timeAllowedtoLive` field and lowercase `stnum`/`sqnum`/`gocbref` without underscores.

### Quote IEC 61850 Strings Containing $ Object Separators

- **Avoid:** `ied1 -> bus goose gocbref IED1/LLN0$GO$gcb01`
- **Valid v3.3.0 Syntax:** `ied1 -> bus goose gocbref "IED1/LLN0$GO$gcb01"`

IEC 61850 object references contain `/` and `$` characters and must always be enclosed in double quotes.
