# Packet diagram (PacketDiag) PacketDiag maps bit ranges onto a fixed word width and draws the grid. It removes the entire class of errors that comes from drawing header diagrams by hand. --- ## What this example shows * colwidth, which sets the word size. * Inclusive bit ranges per field. * Single-bit flag fields. --- ## A worked example Open it, edit it, or copy the source below. ![Packet diagram (PacketDiag)](https://help.gocapable.com/images/att1423835219.svg) The source, which you can paste into a new diagram and edit: ``` packetdiag { colwidth = 32; node_height = 60; 0-15: "Source port"; 16-31: "Destination port"; 32-63: "Sequence number"; 64-95: "Acknowledgement number"; 96-99: "Offset"; 100-105: "Reserved"; 106: "U"; 107: "A"; 108: "P"; 109: "R"; 110: "S"; 111: "F"; 112-127: "Window"; 128-143: "Checksum"; 144-159: "Urgent pointer"; } ``` --- ## Making it your own * colwidth must match the real word size or every offset misleads. * Ranges are inclusive, so 0-15 is sixteen bits. * For byte-oriented structures with nesting, use Bytefield. --- ## Related [Rack diagram (RackDiag)An elevation that matches the room.](https://help.gocapable.com/diagrams/rack-diagram-rackdiag.html) [System context (Structurizr)One model, and views onto it.](https://help.gocapable.com/diagrams/system-context-structurizr.html) [More languagesBack to the rest of these examples.](https://help.gocapable.com/diagrams/more-languages.html) --- _Specialists. Borrow one when you need it._