IPv6 network packet: GraphViz block diagram (.dot) source

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.7

This page hosts a formal specification of IPv6 network packet using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

ipv6_packet.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__ipv6_packet {
		label="Ipv6Packet";
		graph[style=dotted];

		ipv6_packet__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="version_pos">0</TD><TD PORT="version_size">4b</TD><TD>b4</TD><TD PORT="version_type">version</TD></TR>
			<TR><TD PORT="traffic_class_pos">0:4</TD><TD PORT="traffic_class_size">1</TD><TD>b8</TD><TD PORT="traffic_class_type">traffic_class</TD></TR>
			<TR><TD PORT="flow_label_pos">1:4</TD><TD PORT="flow_label_size">20b</TD><TD>b20</TD><TD PORT="flow_label_type">flow_label</TD></TR>
			<TR><TD PORT="payload_length_pos">4</TD><TD PORT="payload_length_size">2</TD><TD>u2be</TD><TD PORT="payload_length_type">payload_length</TD></TR>
			<TR><TD PORT="next_header_type_pos">6</TD><TD PORT="next_header_type_size">1</TD><TD>u1</TD><TD PORT="next_header_type_type">next_header_type</TD></TR>
			<TR><TD PORT="hop_limit_pos">7</TD><TD PORT="hop_limit_size">1</TD><TD>u1</TD><TD PORT="hop_limit_type">hop_limit</TD></TR>
			<TR><TD PORT="src_ipv6_addr_pos">8</TD><TD PORT="src_ipv6_addr_size">16</TD><TD></TD><TD PORT="src_ipv6_addr_type">src_ipv6_addr</TD></TR>
			<TR><TD PORT="dst_ipv6_addr_pos">24</TD><TD PORT="dst_ipv6_addr_size">16</TD><TD></TD><TD PORT="dst_ipv6_addr_type">dst_ipv6_addr</TD></TR>
			<TR><TD PORT="next_header_pos">40</TD><TD PORT="next_header_size">...</TD><TD>switch (next_header_type)</TD><TD PORT="next_header_type">next_header</TD></TR>
			<TR><TD PORT="rest_pos">...</TD><TD PORT="rest_size">?</TD><TD></TD><TD PORT="rest_type">rest</TD></TR>
		</TABLE>>];
ipv6_packet__seq_next_header_switch [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
	<TR><TD BGCOLOR="#F0F2E4">case</TD><TD BGCOLOR="#F0F2E4">type</TD></TR>
	<TR><TD>17</TD><TD PORT="case0">UdpDatagram</TD></TR>
	<TR><TD>0</TD><TD PORT="case1">OptionHopByHop</TD></TR>
	<TR><TD>4</TD><TD PORT="case2">Ipv4Packet</TD></TR>
	<TR><TD>6</TD><TD PORT="case3">TcpSegment</TD></TR>
	<TR><TD>59</TD><TD PORT="case4">NoNextHeader</TD></TR>
</TABLE>>];
		subgraph cluster__no_next_header {
			label="Ipv6Packet::NoNextHeader";
			graph[style=dotted];

			no_next_header__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__option_hop_by_hop {
			label="Ipv6Packet::OptionHopByHop";
			graph[style=dotted];

			option_hop_by_hop__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="next_header_type_pos">0</TD><TD PORT="next_header_type_size">1</TD><TD>u1</TD><TD PORT="next_header_type_type">next_header_type</TD></TR>
				<TR><TD PORT="hdr_ext_len_pos">1</TD><TD PORT="hdr_ext_len_size">1</TD><TD>u1</TD><TD PORT="hdr_ext_len_type">hdr_ext_len</TD></TR>
				<TR><TD PORT="body_pos">2</TD><TD PORT="body_size">(hdr_ext_len - 1)</TD><TD></TD><TD PORT="body_type">body</TD></TR>
				<TR><TD PORT="next_header_pos">...</TD><TD PORT="next_header_size">...</TD><TD>switch (next_header_type)</TD><TD PORT="next_header_type">next_header</TD></TR>
			</TABLE>>];
option_hop_by_hop__seq_next_header_switch [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
	<TR><TD BGCOLOR="#F0F2E4">case</TD><TD BGCOLOR="#F0F2E4">type</TD></TR>
	<TR><TD>0</TD><TD PORT="case0">OptionHopByHop</TD></TR>
	<TR><TD>6</TD><TD PORT="case1">TcpSegment</TD></TR>
	<TR><TD>59</TD><TD PORT="case2">NoNextHeader</TD></TR>
</TABLE>>];
		}
	}
	ipv6_packet__seq:next_header_type -> ipv6_packet__seq_next_header_switch [style=bold];
	ipv6_packet__seq_next_header_switch:case0 -> udp_datagram__seq [style=bold];
	ipv6_packet__seq_next_header_switch:case1 -> option_hop_by_hop__seq [style=bold];
	ipv6_packet__seq_next_header_switch:case2 -> ipv4_packet__seq [style=bold];
	ipv6_packet__seq_next_header_switch:case3 -> tcp_segment__seq [style=bold];
	ipv6_packet__seq_next_header_switch:case4 -> no_next_header__seq [style=bold];
	ipv6_packet__seq:next_header_type_type -> ipv6_packet__seq:next_header_type [color="#404040"];
	option_hop_by_hop__seq:hdr_ext_len_type -> option_hop_by_hop__seq:body_size [color="#404040"];
	option_hop_by_hop__seq:next_header_type -> option_hop_by_hop__seq_next_header_switch [style=bold];
	option_hop_by_hop__seq_next_header_switch:case0 -> option_hop_by_hop__seq [style=bold];
	option_hop_by_hop__seq_next_header_switch:case1 -> tcp_segment__seq [style=bold];
	option_hop_by_hop__seq_next_header_switch:case2 -> no_next_header__seq [style=bold];
	option_hop_by_hop__seq:next_header_type_type -> option_hop_by_hop__seq:next_header_type [color="#404040"];
}