Mermaid Packet Diagrams
Packet diagrams visualize network packet structures and protocol layers. Perfect for documenting network protocols, packet formats, and communication protocols.
Use Case
Use packet diagrams when you need to:
- Document network protocols
- Show packet structures
- Visualize protocol layers
- Explain packet formats
- Design communication protocols
Code
1```mermaid
2packet
3 0-15: "Source Port"
4 16-31: "Destination Port"
5 32-63: "Sequence Number"
6 64-95: "Acknowledgment Number"
7```
Result:
Explanation
packet- Start packet diagram- Format:
start-end: "Field Name"for bit ranges - Format:
position: "Field Name"for single bits - Field labels must be in quotes
- Fields listed in order from top to bottom
Examples
Example 1: TCP Header
1```mermaid
2packet
3 0-15: "Source Port"
4 16-31: "Destination Port"
5 32-63: "Sequence Number"
6 64-95: "Acknowledgment Number"
7 96-99: "Data Offset"
8 100-105: "Reserved"
9 106: "URG"
10 107: "ACK"
11 108: "PSH"
12 109: "RST"
13 110: "SYN"
14 111: "FIN"
15 112-127: "Window"
16 128-143: "Checksum"
17 144-159: "Urgent Pointer"
18 160-191: "(Options and Padding)"
19 192-255: "Data (variable length)"
20```
Result:
Example 2: IP Header
1```mermaid
2packet
3 0-3: "Version"
4 4-7: "IHL"
5 8-15: "Type of Service"
6 16-31: "Total Length"
7 32-47: "Identification"
8 48-50: "Flags"
9 51-63: "Fragment Offset"
10 64-71: "TTL"
11 72-79: "Protocol"
12 80-95: "Header Checksum"
13 96-127: "Source Address"
14 128-159: "Destination Address"
15```
Result:
Example 3: With Title
1```mermaid
2---
3title: "TCP Packet"
4---
5packet
6 0-15: "Source Port"
7 16-31: "Destination Port"
8 32-63: "Sequence Number"
9 64-95: "Acknowledgment Number"
10 96-99: "Data Offset"
11 100-105: "Reserved"
12 106: "URG"
13 107: "ACK"
14 108: "PSH"
15 109: "RST"
16 110: "SYN"
17 111: "FIN"
18 112-127: "Window"
19 128-143: "Checksum"
20 144-159: "Urgent Pointer"
21```
Result:
Notes
- Use
packetkeyword (notpacket-beta) - Format:
start-end: "Field Name"for bit ranges - Format:
position: "Field Name"for single bits - Field labels must be in double quotes
- Fields listed in order from top to bottom
- Can include title using frontmatter syntax
---\ntitle: "Title"\n---
Gotchas/Warnings
- ⚠️ Syntax: Use
packet(notpacket-beta) - ⚠️ Quotes: Field labels must be in double quotes
- ⚠️ Format: Use
start-end: "name"for ranges,position: "name"for single bits - ⚠️ Order: Fields should be listed sequentially from top to bottom
Related Snippets
- Architecture Diagrams (C4 Model)
Create system architecture diagrams using C4 model with Mermaid - Chart.js Bar Chart
Create bar charts for data visualization - Graphviz DOT Diagrams
Create complex graph layouts with Graphviz DOT language - KaTeX Math Examples and Tips
Comprehensive guide to KaTeX math notation with examples and tips - Mermaid Arbitrary Graphs
Create arbitrary graphs and networks with Mermaid - Mermaid Block Diagrams
Create block diagrams for system architecture with Mermaid - Mermaid Charts (Pie, Bar, Line)
Create pie charts, bar charts, and line charts with Mermaid - Mermaid Class Diagrams (UML)
Create UML class diagrams with Mermaid - Mermaid Entity Relationship Diagrams
Create Entity Relationship Diagrams (ERD) with Mermaid - Mermaid Flowchart
Create flowcharts and decision trees with Mermaid - Mermaid Gantt Chart
Create Gantt charts for project timelines and scheduling - Mermaid Git Diagrams
Create Git branch and commit diagrams with Mermaid - Mermaid Kanban Boards
Create Kanban boards for project management with Mermaid - Mermaid Mindmaps
Create mindmaps for brainstorming and organizing ideas with Mermaid - Mermaid Quadrant Charts
Create quadrant charts for prioritization with Mermaid - Mermaid Radar Charts
Create radar charts for multi-dimensional comparisons with Mermaid - Mermaid Requirement Diagrams
Create requirement diagrams for system requirements with Mermaid - Mermaid Sankey Diagrams
Create Sankey diagrams for flow visualization with Mermaid - Mermaid Sequence Diagram
Create sequence diagrams for interactions and API flows - Mermaid State Diagrams
Create state diagrams and state machines with Mermaid - Mermaid Timeline Diagrams
Create timeline diagrams for chronological events with Mermaid - Mermaid Treemap Diagrams
Create treemap diagrams for hierarchical data visualization with Mermaid - Mermaid User Journey Diagrams
Create user journey maps with Mermaid - Mermaid ZenUML Diagrams
Create ZenUML sequence diagrams with Mermaid - P5.js Interactive Visualizations
Create interactive visualizations and animations with P5.js