# syslog — RFC 5424 Structured SIEM Events Over UDP or TCP (`syslog`)

> **FrameAssembly v3.2.2** · Protocol 42 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/syslog

- **Full Protocol Name:** Syslog Event Logging over UDP or TCP
- **Keyword:** `syslog`
- **OSI Layer & Transport:** Layer 7 · UDP 514 (or TCP 514 via transport tcp)
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** RFC 5424, RFC 3164, RFC 6587
- **Wireshark Display Filter:** `syslog`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> UDP 514 (or TCP 514 via transport tcp) (transport tcp|udp) -> Syslog`

## Overview

Compute `<PRI> = facility * 8 + severity` automatically (or override `pri` directly) and ship clean RFC 5424 log frames over UDP `514` or `transport tcp` to verify SIEM alert rules.

Syslog (`syslog`, RFC 5424) is the universal log transport used by routers, firewalls, Linux servers, and OT gateways to ship security and operational events to SIEM collectors (Splunk, Elastic, Sentinel, QRadar, Graylog, rsyslog). By default, `syslog` sends over **UDP port `514`**, and adding `transport tcp` switches cleanly to **TCP port `514`**.

FrameAssembly computes the RFC `<PRI>` header (`facility * 8 + severity`, or an explicit `pri 0..191` override) and formats a clean RFC 5424 Version `1` message with `hostname`, `app`, `procid`, `msgid`, and `msg` fields.

## Minimal Quickstart (`syslog_quickstart.frasm`)

```frameassembly
host edge_fw   { ip 10.10.0.1 }
host siem_node { ip 10.10.50.10 }

compile {
    edge_fw -> siem_node syslog facility 4 severity 4 hostname "fw-dmz-01" app "sshd" msg "Failed password for invalid user admin from 198.51.100.77"
}
```

### Automatic Wire Calculations

- Computes `<PRI> = facility * 8 + severity` automatically (default `facility 16` `local0`, `severity 6` `info` -> `<134>`).
- Formats a complete RFC 5424 `<PRI>1 TIMESTAMP HOSTNAME APP PROCID MSGID - MSG` wire payload that Wireshark and syslog-ng/rsyslog parse out of the box.
- Supports `transport tcp` to stream syslog messages over TCP port `514` with automatic TCP sequence tracking.

## Practical Lab Example: Multi-Severity Security Audit over UDP 514 & Reliable TCP 514 (`syslog_siem_pipeline.frasm`)

Sends a firewall drop alert and OSPF adjacency warning over UDP 514, then opens a TCP 514 session to deliver a high-priority authentication alert.

```frameassembly
host branch_fw { ip 172.16.1.1 }
host log_relay { ip 172.16.100.10 }

compile {
    // 1. Stateless UDP 514 security & routing logs
    branch_fw -> log_relay syslog facility 4 severity 4 hostname "branch-fw-01" app "filterlog" msgid "DROP" msg "Blocked TCP SYN 203.0.113.99:44112 -> 172.16.1.10:3389" wait 2ms
    branch_fw -> log_relay syslog facility 16 severity 3 hostname "branch-fw-01" app "ospfd" msgid "ADJCHG" msg "Neighbor 172.16.0.2 Down: Dead timer expired" wait 4ms
    // 2. Reliable TCP 514 syslog stream (transport tcp)
    branch_fw -> log_relay tcp syn srcport 52514 dstport 514 win 65535 mss 1460 wait 1ms
    branch_fw <- log_relay tcp syn ack win 65535 mss 1460 wait 1ms
    branch_fw -> log_relay tcp ack wait 1ms
    branch_fw -> log_relay syslog facility 10 severity 2 hostname "branch-fw-01" app "sudo" procid "4812" msg "Critical privilege escalation alert" transport tcp
}
```

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

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly syslog_siem_pipeline.frasm syslog_siem_pipeline.pcap
frameassembly syslog_siem_pipeline.frasm syslog_siem_pipeline.pcapng

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

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

## All `syslog` Keywords & Header Options

Packet line pattern: `src_host -> dst_host syslog [facility <0..23>] [severity <0..7>] [pri <0..191>] [hostname "<text>"] [app "<text>"] [procid "<text>"] [msgid "<text>"] [msg "<text>"] [transport <udp|tcp>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `facility <0..23>` | Facility code 0..23 (`4` auth, `10` authpriv, `16..23` local0..local7) | `16 (local0)` | Sets the RFC 5424 Facility number multiplied by `8` inside `<PRI>`. |
| `severity <0..7>` | Severity 0..7 (`0` emerg, `2` crit, `3` err, `4` warn, `6` info, `7` debug) | `6 (Informational)` | Sets the 3-bit Severity level (`0` is highest urgency, `7` is debug). |
| `pri <0..191>` | Combined Priority value (0..191) | `Computed from facility * 8 + severity` | Directly sets the `<PRI>` value, overriding `facility` and `severity`. |
| `hostname "<text>" \| app "<text>" \| procid "<text>" \| msgid "<text>"` | Quoted text fields | `Standard RFC 5424 defaults` | Populates the structured RFC 5424 header fields before the log message body. |
| `msg "<text>"` | Quoted log message text | `"FrameAssembly syslog message"` | Sets the UTF-8 log message text at the end of the syslog record. |
| `transport <udp\|tcp>` | `udp` or `tcp` | `udp` | Switches Layer 4 delivery between UDP port `514` and TCP port `514`. |

## Cross-Layer Options Valid with `syslog`

| 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). |
| `payload "<text>" \| hexpayload "<hex>"` | Quoted text or hex bytes (choose one) | `Omitted` | Appends or overrides raw payload bytes (`"deadbeef"` or `"de:ad:be:ef"`) and updates packet lengths and checksums. |
| `srcmac <mac> \| dstmac <mac> \| ethertype <0..65535>` | Colon/hyphen/Cisco MAC · EtherType u16 (e.g. 0x0800) | `Host MAC / RFC multicast MAC / auto EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or 16-bit EtherType for this single packet. |
| `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>]` | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | `Unlabeled (at most 1 mpls tag per packet)` | Inserts a 32-bit MPLS label header (`0x8847`) ahead of the Layer 3 header. |
| `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>]` | IPv4 ID, DF/MF flags, fragment offset 0..8191 | `ipid 1, flags 0, fragoffset 0` | Sets IPv4 Identification, Do-Not-Fragment (`df`), More-Fragments (`mf`), and fragment offset (ignored over IPv6). |
| `flowlabel <0..1048575>` | 20-bit IPv6 Flow Label (0..1048575) | `0` | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts). |
| `srcport <0..65535> \| dstport <0..65535>` | Port number 0..65535 | `srcport 49152 (remembered), UDP 514 (or TCP 514 via transport tcp)` | Overrides source or destination port and remembers the port pair automatically on `<-` replies. |
| `transport <tcp\|udp>` | `tcp` or `udp` (supported on 9 dual-L4 protocols) | `transport udp` | Switches Layer 4 transport between TCP (`psh ack` + length framing where required) and UDP. |
| `seq <number> \| acknum <number> \| win\|window <0..65535> \| urgent <0..65535> \| syn \| ack \| psh \| fin \| rst \| urg \| ece \| cwr` | TCP sequence/ack numbers, window size, flags & RFC 7323 options | `psh ack, win 65535, automatic TCP seq/acknum` | When using TCP (`transport tcp` or default TCP): overrides automatic TCP sequence tracking, flags, or `mss`/`wscale`/`sackperm`/`tsval`/`tsecr`. |

## Common Mistakes & Quick Fixes

### Facility Must Be 0..23 and Severity Must Be 0..7

- **Avoid:** `edge_fw -> siem_node syslog facility 30 severity 9`
- **Valid v3.2.2 Syntax:** `edge_fw -> siem_node syslog facility 16 severity 4`

RFC 5424 defines facilities `0` through `23` and severities `0` through `7` (giving maximum priority `23 * 8 + 7 = 191`).

### Use msg (Not message) for the Log Body

- **Avoid:** `edge_fw -> siem_node syslog message "Interface Gi0/1 down"`
- **Valid v3.2.2 Syntax:** `edge_fw -> siem_node syslog msg "Interface Gi0/1 down"`

The log text option in `.frasm` is `msg "<text>"`.
