3.8 KB154 lines
Blame
1> **Warning**
2>
3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
4>
5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/packet.md](../../packages/mermaid/src/docs/syntax/packet.md).
6
7# Packet Diagram (v11.0.0+)
8
9## Introduction
10
11A packet diagram is a visual representation used to illustrate the structure and contents of a network packet. Network packets are the fundamental units of data transferred over a network.
12
13## Usage
14
15This diagram type is particularly useful for developers, network engineers, educators, and students who require a clear and concise way to represent the structure of network packets.
16
17## Syntax
18
19```
20packet
21start: "Block name" %% Single-bit block
22start-end: "Block name" %% Multi-bit blocks
23... More Fields ...
24```
25
26### Bits Syntax (v11.7.0+)
27
28Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `+<count>` to set the number of bits, thus:
29
30```
31packet
32+1: "Block name" %% Single-bit block
33+8: "Block name" %% 8-bit block
349-15: "Manually set start and end, it's fine to mix and match"
35... More Fields ...
36```
37
38## Examples
39
40```mermaid-example
41---
42title: "TCP Packet"
43---
44packet
450-15: "Source Port"
4616-31: "Destination Port"
4732-63: "Sequence Number"
4864-95: "Acknowledgment Number"
4996-99: "Data Offset"
50100-105: "Reserved"
51106: "URG"
52107: "ACK"
53108: "PSH"
54109: "RST"
55110: "SYN"
56111: "FIN"
57112-127: "Window"
58128-143: "Checksum"
59144-159: "Urgent Pointer"
60160-191: "(Options and Padding)"
61192-255: "Data (variable length)"
62```
63
64```mermaid
65---
66title: "TCP Packet"
67---
68packet
690-15: "Source Port"
7016-31: "Destination Port"
7132-63: "Sequence Number"
7264-95: "Acknowledgment Number"
7396-99: "Data Offset"
74100-105: "Reserved"
75106: "URG"
76107: "ACK"
77108: "PSH"
78109: "RST"
79110: "SYN"
80111: "FIN"
81112-127: "Window"
82128-143: "Checksum"
83144-159: "Urgent Pointer"
84160-191: "(Options and Padding)"
85192-255: "Data (variable length)"
86```
87
88```mermaid-example
89packet
90title UDP Packet
91+16: "Source Port"
92+16: "Destination Port"
9332-47: "Length"
9448-63: "Checksum"
9564-95: "Data (variable length)"
96```
97
98```mermaid
99packet
100title UDP Packet
101+16: "Source Port"
102+16: "Destination Port"
10332-47: "Length"
10448-63: "Checksum"
10564-95: "Data (variable length)"
106```
107
108## Details of Syntax
109
110- **Ranges**: Each line after the title represents a different field in the packet. The range (e.g., `0-15`) indicates the bit positions in the packet.
111- **Field Description**: A brief description of what the field represents, enclosed in quotes.
112
113## Configuration
114
115Please refer to the [configuration](/config/schema-docs/config-defs-packet-diagram-config.html) guide for details.
116
117<!--
118
119Theme variables are not currently working due to a mermaid bug. The passed values are not being propagated into styles function.
120
121## Theme Variables
122
123| Property | Description | Default Value |
124| ---------------- | -------------------------- | ------------- |
125| byteFontSize | Font size of the bytes | '10px' |
126| startByteColor | Color of the starting byte | 'black' |
127| endByteColor | Color of the ending byte | 'black' |
128| labelColor | Color of the labels | 'black' |
129| labelFontSize | Font size of the labels | '12px' |
130| titleColor | Color of the title | 'black' |
131| titleFontSize | Font size of the title | '14px' |
132| blockStrokeColor | Color of the block stroke | 'black' |
133| blockStrokeWidth | Width of the block stroke | '1' |
134| blockFillColor | Fill color of the block | '#efefef' |
135
136## Example on config and theme
137
138```mermaid-example
139---
140config:
141 packet:
142 showBits: true
143 themeVariables:
144 packet:
145 startByteColor: red
146---
147packet
1480-15: "Source Port"
14916-31: "Destination Port"
15032-63: "Sequence Number"
151```
152
153-->
154