主题
数据包图 (v11.0.0+)
🌐 Packet Diagram (v11.0.0+)
介绍
🌐 Introduction
分组图是一种用于展示网络分组结构和内容的可视化表示方式。网络分组是通过网络传输的基本数据单元。
🌐 A 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.
使用方法
🌐 Usage
这种图表类型对于需要以清晰简明的方式表示网络数据包结构的开发者、网络工程师、教育工作者和学生特别有用。
🌐 This 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.
语法
🌐 Syntax
packet
start: "Block name" %% Single-bit block
start-end: "Block name" %% Multi-bit blocks
... More Fields ...Bits 语法 (v11.7.0+)
🌐 Bits Syntax (v11.7.0+)
使用起始和结束位数可能很困难,特别是在修改设计时。为此,我们添加了一个位数字段,它会自动从前一个字段的末尾开始使用。使用 +<count> 来设置位数,如下所示:
🌐 Using 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:
packet
+1: "Block name" %% Single-bit block
+8: "Block name" %% 8-bit block
9-15: "Manually set start and end, it's fine to mix and match"
... More Fields ...示例
🌐 Examples
代码:
mermaid
代码:
mermaid
语法细节
🌐 Details of Syntax
- 范围:标题后的每一行表示数据包中的不同字段。范围(例如
0-15)表示数据包中的位位置。 - 字段描述:用引号括起来的字段含义简要说明。
位编号顺序 (v12.0.0+)
🌐 Bit Numbering Order (v12.0.0+)
行从左边的最低位编号到右边的最高位,这适合网络数据包。硬件寄存器通常画反过来,最重要的位在左边,位0在右边。设置 bitOrder: descending 来镜像每一行:
🌐 Rows are numbered from their lowest bit on the left up to their highest bit on the right, which suits network packets. Hardware registers are conventionally drawn the other way round, with the most significant bit on the left and bit 0 on the right. Set bitOrder: descending to mirror every row:
代码:
mermaid
只有图是镜像的。字段仍然按最低位优先声明(0-7,从不使用 7-0),并保持它们的宽度,所以同一个图可以仅通过改变 bitOrder 就在两种约定之间切换。
🌐 Only the drawing is mirrored. Fields are still declared lowest bit first (0-7, never 7-0) and keep their width, so the same diagram can be switched between the two conventions by changing bitOrder alone.
每一行都会单独镜像,所以宽度超过 bitsPerRow 的数据包会被看作是一堆单词,每个单词从最高位到最低位排列:使用默认的 bitsPerRow: 32 时,第二行是从第 63 位到第 32 位,而不是到第 0 位。未完全填满的行会在左侧补齐,使其最低位与右边缘对齐。
🌐 Each row is mirrored on its own, so a packet wider than bitsPerRow reads as a stack of words that each run from their highest bit down to their lowest: with the default bitsPerRow: 32, the second row runs from bit 63 down to bit 32, not down to bit 0. A row that is not completely filled is padded on the left, keeping its lowest bit flush against the right edge.
配置
🌐 Configuration
详情请参阅配置指南。
🌐 Please refer to the configuration guide for details.