Blockdiag Package Diagrams¶
The blockdiag
package provides tools for generating several types of diagram, from simple box and arrows diagrams to various diagrams familiar to communications and system engineers.
The diagrams are defined using simple text structures. Various IPython block magics allow these descriptions to be entered directly in to a magicked code cell, and the diagram generated directly therefrom.
The diagrams are generated by default as SVG diagrams and can be saved to a named file if required; .png
format images may also be created.
All the magics are enabled from a single load command:
Block Diagrams¶
Network Diagrams¶
The network diagram type can be used to demonstrate the connectivity of nodes to different IP (internet protocol) network ranges.
In the following diagram, we save the SVG image to an explicit file as an additional output. (The direct output is hidden using a publishing system tag in the original source document.)
We can then explicitly render the image, from the saved file, as required:
Nodes can also be grouped in coloured blocks.
The network diagram type can also be used to sketch higher level network diagrams:
Activity Diagrams¶
The activity diagram type can be used to describe a linear series of activities carried out by one or more actors:
Sequence Diagram¶
A sequence diagram can be used to visualise the message passing sequence used by a communication protocol.
Packet Diagram¶
The packet diagram type can be used to illustrate the bit an bytewise structure of a data packet:
%%packetdiag
colwidth = 32
node_height = 72
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 [rotate = 270]
107: ACK [rotate = 270]
108: PSH [rotate = 270]
109: RST [rotate = 270]
110: SYN [rotate = 270]
111: FIN [rotate = 270]
112-127: Window
128-143: Checksum
144-159: Urgent Pointer
160-191: (Options and Padding)
192-223: data [colheight = 3]
Rack Diagrams¶
The rack diagram (rackdiag
) type is useful for generating diagrams that illustrate the different components that might be present in a physical rack server cabinet.