Protocol – An ASCII Header Generator for Community Protocols

Protocol – An ASCII Header Generator for Community Protocols

0x01 Introduction

Protocol is a straightforward snarl-line tool that serves two functions:

  • Provide a straightforward manner for engineers to bear a behold at genuine network
    protocol headers, valid away from the snarl-line,
    with out a must
    google for the relevant RFC or for grotesque header image diagrams.

  • Provide a model for researchers and engineers to lickety-split generate ASCII
    RFC-love header diagrams for their very personal custom-made protocols.

0x02 Downloading Protocol

The most up-to-date model of protocol is valid away available by job of GitHub. It will probably well well moreover be
downloaded
valid away from right here
or visiting the following web field and clicking on the
button “Download ZIP”.

Alternatively, the code would possibly possibly well well moreover be checked out the utilize of GIT, running the following
snarl (If triggered for a username and password, invent no longer enter any, impartial hit Enter):

  • git clone https://github.com/luismartingarcia/protocol.git

Documentation and additional records is always readily available on this web field.

0x03 Installing Protocol

Protocol would possibly possibly well well moreover be installed by running the incorporated setup.py script as follows:

  • setup.py install

Sign that in characterize to install Protocol, root or administrative privileges
are required. On GNU/Linux techniques, it can well moreover be installed as follows:

  • sudo ./setup.py install

0x04 Working Protocol

As soon as installed, Protocol would possibly possibly well well moreover be traipse from the snarl line. The syntax is
the following:

protocol

or

protocol

The next subsections enlighten every strategy.

0x04.1 Showing New Protocols

The first strategy lets users print ASCII headers for present network
protocols. In explicit, the following protocols are readily available.

"ethernet"            : Ethernet
"8021q"               : IEEE 802.1q
"dot1q"               : IEEE 802.1q
"tcp"                 : Transmission Lend a hand an eye fixed on Protocol (TCP)
"udp"                 : Person Datagram Protocol (TCP)
"ip"                  : Files superhighway Protocol (IP), model 4.
"ipv6"                : Files superhighway Protocol (IP), model 6.
"icmp"                : Files superhighway Lend a hand an eye fixed on Message Protocol (ICMP)
"icmp-destination":   : ICMP Proceed verbalize Unreachable
"icmp-time"           : ICMP Time Exceeded
"icmp-parameter"      : ICMP Parameter Scenario
"icmp-source"         : ICMP Offer Quench
"icmp-redirect"       : ICMP Redirect
"icmp-echo"           : ICMP Echo Interrogate/Answer
"icmp-timestamp"      : ICMP Timestamp Interrogate/Answer
"icmp-records"    : ICMP Files Interrogate/Answer
"icmpv6"              : ICMP for IPv6 (ICMPv6)
"icmpv6-destination"  : ICMPv6 Proceed verbalize Unreachable
"icmpv6-substantial"          : ICMPv6 Packet Too Gargantuan
"icmpv6-time"         : ICMPv6 Time Exceeded
"icmpv6-parameter"    : ICMPv6 Parameter Scenario
"icmpv6-echo"         : ICMPv6 Echo Interrogate/Answer
"icmpv6-rsol"         : ICMPv6 Router Solicitation
"icmpv6-radv"         : ICMPv6 Router Commercial
"icmpv6-nsol"         : ICMPv6 Neighbor Solicitation
"icmpv6-nadv"         : ICMPv6 Neighbor Commercial
"icmpv6-redirect"     : ICMPv6 Redirect

A lot of of the protocols listed above would possibly possibly well well moreover be printed. Listed below are about a
examples:

protocol tcp
protocol dot1q
protocol tcp udp
protocol ipv6 icmpv6 icmpv6-redirect

Sign that protocol names invent no longer ought to be fully specified, as prolonged as there
is no ambiguity. As an illustration ‘protocol et’ is a equivalent to ‘protocol
ethernet’. Whenever there would possibly possibly be ambiguity (e.g. ‘protocol icmpv6-r’, a checklist of
imaginable ideas will doubtless be displayed.

$ protocol icmpv6-r
Ambiguous protocol specifier 'icmpv6-r'. Did you mean any of these?
  icmpv6-radv
  icmpv6-redirect
  icmpv6-rsol

0x04.2 Showing Custom Protocols

As opposed to already present protocols, Protocol can signify any arbitrary
protocol headers. In characterize to enact that, as opposed to specifying the title of
an present protocol, a custom-made protocol specification would possibly possibly well well even be provided. Such
specification must apply a straightforward however disclose syntax:

[?OPTIONS]”

Where [LIST_OF_FIELDS] is a comma-separated list of protocol field names
and lengths (expressed in bits), and [?OPTIONS] is an optional section that
enables users to specify structure modifiers for the ASCII header. Sign that if
any of the field names contains areas, the protocol specification ought to be
enclosed in double quotes.

0x04.1.1 Discipline Lists

A truly unheard of section of a protocol specification are field lists. This
is simply a comma-separated list of title:length tuples, the put title represents
the textual say material that describes the protocol field and would possibly possibly well well contain any character,
other than for ‘?’ and length is an integer increased than zero, representing the
preference of bits the field takes within the header. Listed below are about a examples:

Form:8,Code:8,Checksum: 16,Message Physique: 64

Offer Port: 16,Proceed verbalize Port: 16,Length: 16,Checksum: 16

Sign that there would possibly possibly be now not any whitespace after the commas. Right here is a restriction
that ought to be respected.Also, point to that field lengths invent no longer must align
to the length of the line. If a explicit field is simply too prolonged, Protocol will
impartial wrap it to the subsequent line. Listed below are some examples:

$ protocol "Offer: 16,TTL:8,Reserved: 40"
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Offer            |      TTL      |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +
|                            Reserved                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


$ protocol "Offer: 16,Reserved: 40,TTL:8"
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Offer            |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               +-+-+-+-+-+-+-+-+
|                    Reserved                   |      TTL      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

$ protocol "Reserved: 32,Target Address: 128"
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Reserved                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Target Address                        +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

0x04.1.2 Alternate ideas

As soon as the list of fields has been specified, users would possibly possibly well well also optionally go
formatting ideas to set an eye fixed on the manner the ASCII header is generated.
Alternate ideas are provided as a comma-separated list of model=worth aspects.
The first one is preceded by the ‘?’ ticket, which lets Protocol settle out
the put the field list ends and the put the list of ideas begins. The ideas
presently readily available are the following:

bits=       : Preference of bits per line. By default it's 32, identical as
                 IETF. Right here is precious for protocols that invent no longer align
                 perfectly to 32-bit words, love Ethernet.
numbers=  : Instructs protocol to print or steer clear of printing the bit
                 counts on high of the header.
evenchar=   : Instructs protocol to utilize the provided character, as an alternative
                 of the default "-" as the character in even positions of
                 the horizontal lines.
oddchar=    : Same as evenchar however for characters in queer positions of
                 the horizontal lines. By default it takes the worth '+'
startchar=  : Instructs protocol to utilize the provided character as an alternative
                 of the default "+" for the first pickle of an horizontal
                 line.
endchar=    : Same as startchar however for the character within the final
                 pickle of the horizonal lines.
sepchar=    : Instructs protocol to utilize the provided character as an alternative
                 of the default "|" for the field separator character.

The next plan shows the character modifiers described above.

Bit counts                                                     sepchar(|)
 ^   ^                                                              |
 |   |                                                              |
 |   |                                                              |
 0   |               1                   2                   3      |
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   |
|             Offer            |      TTL      |    Reserved   | |
						   bits(32)

0x04.3 Sing-line Alternate ideas

As opposed to per-protocol structure specifiers, Protocol would possibly possibly well well even be configured
the utilize of snarl-line parameter. The next list presents an clarify of
every possibility readily available.

Utilization: protocol { or } [OPTIONS]
PARAMETERS:
           : Title of an present protocol
               : Discipline by field specification of non-present protocol
OPTIONS:
 -b, --bits       : Preference of bits per line
 -f, --file          : Study specs from a textual say material file
 -h, --wait on          : Displays this wait on records
 -n, --no-numbers    : Assassinate no longer print bit numbers on high of the header
 -V, --model       : Displays present model
 --evenchar    : Character for the even positions of horizontal lines
 --oddchar     : Character for the queer positions of horizontal lines
 --startchar   : Character that begins horizontal lines
 --endchar     : Character that ends horizontal lines
 --sepchar     : Character that separates protocol fields

0x05 Examples

This share items additional examples on guidelines on how to traipse protocol.

$ protocol tcp
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Offer Port          |        Proceed verbalize Port       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Acknowledgment Number                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Offset|  Res. |     Flags     |             Window            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Checksum           |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Alternate ideas                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


$ protocol "Offer Port: 16,Proceed verbalize Port: 16,Sequence Number: 32,
  Acknowledgment Number: 32,Offset:4,Res.:4,Flags:8,Window: 16,Checksum: 16,
  Urgent Pointer: 16,Alternate ideas: 24,Padding:8"
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Offer Port          |        Proceed verbalize Port       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Acknowledgment Number                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Offset|  Res. |     Flags     |             Window            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Checksum           |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Alternate ideas                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


$ protocol "Field4:4,Field4:4,Field8:8,Discipline16: 16,Discipline32: 32,Discipline64: 64?
  bits=16,numbers=y,startchar=*,endchar=*,evenchar=-,oddchar=-,sepchar=|"
 0                   1
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
*-------------------------------| Field4| Field4|     Field8    |
*-------------------------------|            Discipline16            |
*-------------------------------|                               |
Discipline32            |                               |
*-------------------------------|                               |
|                               |
Discipline64            |                               |
|                               |
*-------------------------------$ protocol ip --bits 16
 0                   1
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Model|  IHL  |Form of Provider|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Flags|     Fragment Offset     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Dwell |    Protocol   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        Header Checksum        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+         Offer Address        +
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+      Proceed verbalize Address      +
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Alternate ideas            |
+               +-+-+-+-+-+-+-+-+
|               |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


$ protocol udp --oddchar "-" --startchar "-" --endchar "-"
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-----------------------------------------------------------------
|          Offer Port          |        Proceed verbalize Port       |
-----------------------------------------------------------------
|             Length            |            Checksum           |
-----------------------------------------------------------------


$ protocol ipv6 --no-numbers
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Model| Web site visitors Class |               Drift Designate              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length        |  Subsequent Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Offer Address                        +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                       Proceed verbalize Address                     +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


$ protocol udp icmp
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Offer Port          |        Proceed verbalize Port       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Length            |            Checksum           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      Form     |      Code     |            Checksum           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                          Message Physique                         +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

0x06 Contact, Strengthen and Trojan horse Reporting

For any questions, bug reports, bug fixes, characteristic requests, code
contributions, and tons others, please contact me the utilize of the electronic mail cope with displayed
beneath. Please point to that Protocol’s enhance is simply love
IP transport: finest-effort. I will enact my finest to house your enquiries however
no guarantees. Particular enhance packages are readily available for these inviting to
send me exact $$$ by job of Paypal 😉

Study More

Share your love