Overview
Packet diagrams in Sirena visualize network packet structures and protocol formats. They show how data is organized within network packets, including field layouts, bit ranges, and data organization across multiple rows.
Packet diagrams are useful for:
-
Documenting network protocol specifications
-
Visualizing packet header structures
-
Teaching network communication concepts
-
Analyzing packet formats and field layouts
-
Designing new network protocols
-
Understanding data transmission formats
Syntax specification
Diagram declaration
Packet diagrams are declared using the packet-beta keyword:
packet-beta
<diagram-content>
Examples
Basic packet structure
packet-beta
title Hello world
0-10: "hello"
This creates a simple packet with:
-
A title
-
One field spanning bits 0-10
TCP header structure
packet-beta
title TCP Header
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
100-105: "Reserved"
106: "URG"
107: "ACK"
108: "PSH"
109: "RST"
110: "SYN"
111: "FIN"
112-127: "Window Size"
128-143: "Checksum"
144-159: "Urgent Pointer"
This demonstrates:
-
Standard TCP header fields
-
Mix of different field sizes
-
Single-bit flags (URG, ACK, etc.)
-
Multi-byte fields (ports, sequence numbers)
IP packet header
packet-beta
title IPv4 Header
0-3: "Version"
4-7: "IHL"
8-13: "DSCP"
14-15: "ECN"
16-31: "Total Length"
32-47: "Identification"
48-50: "Flags"
51-63: "Fragment Offset"
64-71: "Time to Live"
72-79: "Protocol"
80-95: "Header Checksum"
96-127: "Source IP Address"
128-159: "Destination IP Address"
This shows:
-
IPv4 header structure
-
Various field sizes from 2 bits to 32 bits
-
Standard network protocol layout
Features
Limitations
Best practices
Use descriptive field names
Give fields clear, technical names:
%% Good
packet-beta
0-3: "Version"
4-7: "Header Length"
%% Less clear
packet-beta
0-3: "V"
4-7: "HL"
Include title for context
Always include a title identifying the packet type:
%% Good
packet-beta
title TCP Segment
...
%% Missing context
packet-beta
0-15: "Port"
Follow protocol standards
For standard protocols, use official field names:
%% Good - standard TCP terminology
packet-beta
title TCP Header
0-15: "Source Port"
16-31: "Destination Port"
%% Confusing - non-standard names
packet-beta
title TCP
0-15: "From Port"
16-31: "To Port"
Organize fields logically
Order fields as they appear in the actual packet:
%% Good - sequential order
packet-beta
0-15: "Field A"
16-31: "Field B"
32-47: "Field C"
%% Confusing - out of order
packet-beta
32-47: "Field C"
0-15: "Field A"
16-31: "Field B"
Document all header fields
Include all relevant header fields for completeness:
%% Good - complete header
packet-beta
title UDP Header
0-15: "Source Port"
16-31: "Destination Port"
32-47: "Length"
48-63: "Checksum"
%% Incomplete
packet-beta
title UDP Header
0-15: "Source Port"
16-31: "Destination Port"