Unverified Commit 543bb97e authored by Cøbra's avatar Cøbra Committed by GitHub
Browse files

Merge pull request #99 from vasild/bip155

Document addrv2 and sendaddrv2 messages
parents b9d1d1cb 22014c57
......@@ -13,10 +13,12 @@ graph [ penwidth = 1.75, fontname="Sans" ]
version -> verack;
ping -> pong;
getaddr -> addr;
getaddr -> addrv2
filterload -> filteradd;
filterload -> filterclear;
alert;
sendaddrv2;
sendheaders;
ERROR [ style = "invis" ];
......
img/dev/en-p2p-control-messages.png

4.75 KB | W: | H:

img/dev/en-p2p-control-messages.png

9.26 KB | W: | H:

img/dev/en-p2p-control-messages.png
img/dev/en-p2p-control-messages.png
img/dev/en-p2p-control-messages.png
img/dev/en-p2p-control-messages.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
<!-- Generated by graphviz version 2.42.2 ()
-->
<!-- Title: %3 Pages: 1 -->
<svg width="450pt" height="97pt"
viewBox="0.00 0.00 450.00 96.70" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(0.690714 0.690714) rotate(0) translate(4 136)">
<title>%3</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-136 647.5,-136 647.5,4 -4,4"/>
<text text-anchor="middle" x="321.75" y="-22.8" font-family="Sans" font-size="14.00"> </text>
<text text-anchor="middle" x="321.75" y="-7.8" font-family="Sans" font-size="14.00">Overview Of P2P Protocol Control And Advisory Messages</text>
<!-- Pages: 1 -->
<svg width="450pt" height="79pt"
viewBox="0.00 0.00 450.00 78.60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(0.56 0.56) rotate(0) translate(4 136)">
<polygon fill="white" stroke="transparent" points="-4,4 -4,-136 797.5,-136 797.5,4 -4,4"/>
<text text-anchor="middle" x="396.75" y="-22.8" font-family="Sans" font-size="14.00"> </text>
<text text-anchor="middle" x="396.75" y="-7.8" font-family="Sans" font-size="14.00">Overview Of P2P Protocol Control And Advisory Messages</text>
<!-- version -->
<g id="node1" class="node"><title>version</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="71,-132 0,-132 0,-96 71,-96 71,-132"/>
<text text-anchor="middle" x="35.5" y="-110.3" font-family="Sans" font-size="14.00">version</text>
<g id="node1" class="node">
<title>version</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="69,-132 0,-132 0,-96 69,-96 69,-132"/>
<text text-anchor="middle" x="34.5" y="-110.3" font-family="Sans" font-size="14.00">version</text>
</g>
<!-- verack -->
<g id="node2" class="node"><title>verack</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="68,-74 3,-74 3,-38 68,-38 68,-74"/>
<text text-anchor="middle" x="35.5" y="-52.3" font-family="Sans" font-size="14.00">verack</text>
<g id="node2" class="node">
<title>verack</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="67,-74 2,-74 2,-38 67,-38 67,-74"/>
<text text-anchor="middle" x="34.5" y="-52.3" font-family="Sans" font-size="14.00">verack</text>
</g>
<!-- version&#45;&gt;verack -->
<g id="edge1" class="edge"><title>version&#45;&gt;verack</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M35.5,-95.8939C35.5,-88.9462 35.5,-80.9383 35.5,-74.0014"/>
<g id="edge1" class="edge">
<title>version&#45;&gt;verack</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M34.5,-95.89C34.5,-88.95 34.5,-80.94 34.5,-74"/>
</g>
<!-- ping -->
<g id="node3" class="node"><title>ping</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="139.5,-132 85.5,-132 85.5,-96 139.5,-96 139.5,-132"/>
<text text-anchor="middle" x="112.5" y="-110.3" font-family="Sans" font-size="14.00">ping</text>
<g id="node3" class="node">
<title>ping</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="137.5,-132 83.5,-132 83.5,-96 137.5,-96 137.5,-132"/>
<text text-anchor="middle" x="110.5" y="-110.3" font-family="Sans" font-size="14.00">ping</text>
</g>
<!-- pong -->
<g id="node4" class="node"><title>pong</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="139.5,-74 85.5,-74 85.5,-38 139.5,-38 139.5,-74"/>
<text text-anchor="middle" x="112.5" y="-52.3" font-family="Sans" font-size="14.00">pong</text>
<g id="node4" class="node">
<title>pong</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="137.5,-74 83.5,-74 83.5,-38 137.5,-38 137.5,-74"/>
<text text-anchor="middle" x="110.5" y="-52.3" font-family="Sans" font-size="14.00">pong</text>
</g>
<!-- ping&#45;&gt;pong -->
<g id="edge2" class="edge"><title>ping&#45;&gt;pong</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M112.5,-95.8939C112.5,-88.9462 112.5,-80.9383 112.5,-74.0014"/>
<g id="edge2" class="edge">
<title>ping&#45;&gt;pong</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M110.5,-95.89C110.5,-88.95 110.5,-80.94 110.5,-74"/>
</g>
<!-- getaddr -->
<g id="node5" class="node"><title>getaddr</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="227.5,-132 153.5,-132 153.5,-96 227.5,-96 227.5,-132"/>
<text text-anchor="middle" x="190.5" y="-110.3" font-family="Sans" font-size="14.00">getaddr</text>
<g id="node5" class="node">
<title>getaddr</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="281,-132 208,-132 208,-96 281,-96 281,-132"/>
<text text-anchor="middle" x="244.5" y="-110.3" font-family="Sans" font-size="14.00">getaddr</text>
</g>
<!-- addr -->
<g id="node6" class="node"><title>addr</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="217.5,-74 163.5,-74 163.5,-38 217.5,-38 217.5,-74"/>
<text text-anchor="middle" x="190.5" y="-52.3" font-family="Sans" font-size="14.00">addr</text>
<g id="node6" class="node">
<title>addr</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="205.5,-74 151.5,-74 151.5,-38 205.5,-38 205.5,-74"/>
<text text-anchor="middle" x="178.5" y="-52.3" font-family="Sans" font-size="14.00">addr</text>
</g>
<!-- getaddr&#45;&gt;addr -->
<g id="edge3" class="edge"><title>getaddr&#45;&gt;addr</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M190.5,-95.8939C190.5,-88.9462 190.5,-80.9383 190.5,-74.0014"/>
<g id="edge3" class="edge">
<title>getaddr&#45;&gt;addr</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M224.34,-95.89C216.15,-88.95 206.71,-80.94 198.54,-74"/>
</g>
<!-- addrv2 -->
<g id="node7" class="node">
<title>addrv2</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="287,-74 220,-74 220,-38 287,-38 287,-74"/>
<text text-anchor="middle" x="253.5" y="-52.3" font-family="Sans" font-size="14.00">addrv2</text>
</g>
<!-- getaddr&#45;&gt;addrv2 -->
<g id="edge4" class="edge">
<title>getaddr&#45;&gt;addrv2</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M247.25,-95.89C248.37,-88.95 249.65,-80.94 250.77,-74"/>
</g>
<!-- filterload -->
<g id="node7" class="node"><title>filterload</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="371,-132 288,-132 288,-96 371,-96 371,-132"/>
<text text-anchor="middle" x="329.5" y="-110.3" font-family="Sans" font-size="14.00">filterload</text>
<g id="node8" class="node">
<title>filterload</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="405.5,-132 325.5,-132 325.5,-96 405.5,-96 405.5,-132"/>
<text text-anchor="middle" x="365.5" y="-110.3" font-family="Sans" font-size="14.00">filterload</text>
</g>
<!-- filteradd -->
<g id="node8" class="node"><title>filteradd</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="317,-74 238,-74 238,-38 317,-38 317,-74"/>
<text text-anchor="middle" x="277.5" y="-52.3" font-family="Sans" font-size="14.00">filteradd</text>
<g id="node9" class="node">
<title>filteradd</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="395,-74 318,-74 318,-38 395,-38 395,-74"/>
<text text-anchor="middle" x="356.5" y="-52.3" font-family="Sans" font-size="14.00">filteradd</text>
</g>
<!-- filterload&#45;&gt;filteradd -->
<g id="edge4" class="edge"><title>filterload&#45;&gt;filteradd</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M313.616,-95.8939C307.164,-88.9462 299.728,-80.9383 293.287,-74.0014"/>
<g id="edge5" class="edge">
<title>filterload&#45;&gt;filteradd</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M362.75,-95.89C361.63,-88.95 360.35,-80.94 359.23,-74"/>
</g>
<!-- filterclear -->
<g id="node9" class="node"><title>filterclear</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="420,-74 331,-74 331,-38 420,-38 420,-74"/>
<text text-anchor="middle" x="375.5" y="-52.3" font-family="Sans" font-size="14.00">filterclear</text>
<g id="node10" class="node">
<title>filterclear</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="494,-74 409,-74 409,-38 494,-38 494,-74"/>
<text text-anchor="middle" x="451.5" y="-52.3" font-family="Sans" font-size="14.00">filterclear</text>
</g>
<!-- filterload&#45;&gt;filterclear -->
<g id="edge5" class="edge"><title>filterload&#45;&gt;filterclear</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M343.551,-95.8939C349.258,-88.9462 355.836,-80.9383 361.535,-74.0014"/>
<g id="edge6" class="edge">
<title>filterload&#45;&gt;filterclear</title>
<path fill="none" stroke="black" stroke-width="1.75" d="M391.77,-95.89C402.44,-88.95 414.74,-80.94 425.39,-74"/>
</g>
<!-- alert -->
<g id="node10" class="node"><title>alert</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="439.5,-132 385.5,-132 385.5,-96 439.5,-96 439.5,-132"/>
<text text-anchor="middle" x="412.5" y="-110.3" font-family="Sans" font-size="14.00">alert</text>
<g id="node11" class="node">
<title>alert</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="473.5,-132 419.5,-132 419.5,-96 473.5,-96 473.5,-132"/>
<text text-anchor="middle" x="446.5" y="-110.3" font-family="Sans" font-size="14.00">alert</text>
</g>
<!-- sendaddrv2 -->
<g id="node12" class="node">
<title>sendaddrv2</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="589,-132 488,-132 488,-96 589,-96 589,-132"/>
<text text-anchor="middle" x="538.5" y="-110.3" font-family="Sans" font-size="14.00">sendaddrv2</text>
</g>
<!-- sendheaders -->
<g id="node11" class="node"><title>sendheaders</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="563.5,-132 453.5,-132 453.5,-96 563.5,-96 563.5,-132"/>
<text text-anchor="middle" x="508.5" y="-110.3" font-family="Sans" font-size="14.00">sendheaders</text>
<g id="node13" class="node">
<title>sendheaders</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="713.5,-132 603.5,-132 603.5,-96 713.5,-96 713.5,-132"/>
<text text-anchor="middle" x="658.5" y="-110.3" font-family="Sans" font-size="14.00">sendheaders</text>
</g>
<!-- ERROR -->
<!-- reject -->
<g id="node13" class="node"><title>reject</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="640,-74 581,-74 581,-38 640,-38 640,-74"/>
<text text-anchor="middle" x="610.5" y="-52.3" font-family="Sans" font-size="14.00">reject</text>
<g id="node15" class="node">
<title>reject</title>
<polygon fill="none" stroke="black" stroke-width="1.75" points="789,-74 732,-74 732,-38 789,-38 789,-74"/>
<text text-anchor="middle" x="760.5" y="-52.3" font-family="Sans" font-size="14.00">reject</text>
</g>
<!-- ERROR&#45;&gt;reject -->
</g>
......
......@@ -598,7 +598,7 @@ Note that almost none of the control messages are authenticated in any way, mean
Addr
^^^^
The ``addr`` (IP address) message relays connection information for peers on the `network <../devguide/p2p_network.html>`__. Each peer which wants to accept incoming connections creates an `“addr” message <../reference/p2p_networking.html#addr>`__ providing its connection information and then sends that message to its peers unsolicited. Some of its peers send that information to their peers (also unsolicited), some of which further distribute it, allowing decentralized peer discovery for any program already on the `network <../devguide/p2p_network.html>`__.
The ``addr`` (IP address) message relays connection information for peers on the `network <../devguide/p2p_network.html>`__. Each peer which wants to accept incoming connections creates an `“addr” <../reference/p2p_networking.html#addr>`__ or `“addrv2” <../reference/p2p_networking.html#addrv2>`__ message providing its connection information and then sends that message to its peers unsolicited. Some of its peers send that information to their peers (also unsolicited), some of which further distribute it, allowing decentralized peer discovery for any program already on the `network <../devguide/p2p_network.html>`__.
An `“addr” message <../reference/p2p_networking.html#addr>`__ may also be sent in response to a `“getaddr” message <../reference/p2p_networking.html#getaddr>`__.
......@@ -639,6 +639,54 @@ The following annotated hexdump shows part of an `“addr” message <../referen
[...] .............................. (999 more addresses omitted)
Addrv2
^^^^^^
The ``addrv2`` (address version two) message relays connection information for peers on the `network <../devguide/p2p_network.html>`__ in a similar way to the `“addr“ message <../reference/p2p_networking.html#addr>`__ except that it uses a different encoding which supports addresses longer than 16 bytes.
+----------+------------------+-------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
| Bytes | Name | Data Type | Description |
+==========+==================+=======================================================+============================================================================================================================+
| *Varies* | address count | compactSize uint | The number of address entries up to a maximum of 1,000. |
+----------+------------------+-------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
| *Varies* | addresses | `network <../devguide/p2p_network.html>`__ address | Address entries. See the table below for the format of a Bitcoin `network <../devguide/p2p_network.html>`__ addrv2 address.|
+----------+------------------+-------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
Each encapsulated address uses the following structure (``addrv2`` encoding):
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| Bytes | Name | Data Type | Description |
+==========+================+==================+===================================================================================================================================================+
| 4 | time | uint32 | Same as in the `“addr” message <../reference/p2p_networking.html#addr>`__. |
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| *Varies* | services | compactSize uint | Same as in the `“addr” message <../reference/p2p_networking.html#addr>`__, but encoded as compactSize. |
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | network id | uint8_t | The id of the network to which the address belongs to, as defined in `BIP155 <https://github.com/bitcoin/bips/blob/master/bip-0155.mediawiki>`__. |
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| *Varies* | address length | compactSize uint | The size of the address in the following field (in bytes). |
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| *Varies* | address | byte[] | The network address. The interpretation depends on the network id. |
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| 2 | port | uint16_t | Same as in the `“addr” message <../reference/p2p_networking.html#addr>`__. |
+----------+----------------+------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
The following annotated hexdump shows part of an `“addrv2” message <../reference/p2p_networking.html#addrv2>`__ (the message header has been omitted).
.. highlight:: text
::
fde803 ............................. Address count: 1000
d91f4854 ........................... [Epoch time][unix epoch time]: 1414012889
fd4804 ............................. Service bits: compactSize(NODE_WITNESS | NODE_COMPACT_FILTERS | NODE_NETWORK_LIMITED)
01 ................................. BIP155 network id: IPv4
04 ................................. Address length: compactSize(4)
c0000233 ........................... Address: 192.0.2.51
208d ............................... Port: 8333
[...] .............................. (999 more addresses omitted)
Alert
^^^^^
......@@ -879,7 +927,7 @@ In addition, because the filter size stays the same even though additional eleme
GetAddr
^^^^^^^
The `“getaddr” message <../reference/p2p_networking.html#getaddr>`__ requests an `“addr” message <../reference/p2p_networking.html#addr>`__ from the receiving node, preferably one with lots of IP addresses of other receiving nodes. The transmitting node can use those IP addresses to quickly update its database of available nodes rather than waiting for unsolicited `“addr” messages <../reference/p2p_networking.html#addr>`__ to arrive over time.
The `“getaddr” message <../reference/p2p_networking.html#getaddr>`__ requests an `“addr” <../reference/p2p_networking.html#addr>`__ or `“addrv2” <../reference/p2p_networking.html#addrv2>`__ message from the receiving node, preferably one with lots of addresses of other receiving nodes. The transmitting node can use those addresses to quickly update its database of available nodes rather than waiting for unsolicited `“addr” <../reference/p2p_networking.html#addr>`__ or `“addrv2” <../reference/p2p_networking.html#addrv2>`__ messages to arrive over time.
There is no payload in a `“getaddr” message <../reference/p2p_networking.html#getaddr>`__. See the `message header section <../reference/p2p_networking.html#message-headers>`__ for an example of a message without a payload.
......@@ -990,6 +1038,13 @@ The `“sendheaders” message <../reference/p2p_networking.html#sendheaders>`__
There is no payload in a `“sendheaders” message <../reference/p2p_networking.html#sendheaders>`__. See the `message header section <../reference/p2p_networking.html#message-headers>`__ for an example of a message without a payload.
SendAddrv2
^^^^^^^^^^^
The `“sendaddrv2” message <../reference/p2p_networking.html#sendaddrv2>`__ tells the receiving peer that the sender can understand `“addrv2” messages <../reference/p2p_networking.html#addrv2>`__ and prefers to receive them instead of `“addr” messages <../reference/p2p_networking.html#addr>`__.
There is no payload in a `“sendaddrv2” message <../reference/p2p_networking.html#sendaddrv2>`__. See the `message header section <../reference/p2p_networking.html#message-headers>`__ for an example of a message without a payload.
VerAck
^^^^^^
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment