Thanks for your detail answer。
1, My steps to complete the handshake as follow, but hash the hex maybe wrong. Is the checksum hash256 the payload twice?
You have to sha256 hash the sha256 hash (so two hashes) of the payload. This is all done as binary data, not as a hex string.
step me node
1 version -->
2 <-- version
3 <-- verack
4 verack -->
if the node send ping, I reply pong, the payload is the same as ping.
but some nodes don't care your reply, they only send "version", "verack", "ping", "addr" message orderly. I am sure when i connect these node, i follow the steps to complete the handshake.
Interesting. Can you provide the user agent strings of those boxes? If you don't send a version message, then verack should not be sent. If you haven't sent a verack, ping and addr should not be sent.
2, In the version message, there are three sections of services, “services", "addr_recv services", and "addr_trans services". which is the services you refer to?
Thanks a lot.
"services". It refers to the services that the sending node is advertising, which is what you want to know.
my version message:
sendMsg len:131
0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0,
0x6b, 0x0, 0x0, 0x0, 0xd9, 0x9c, 0xe5, 0x9, 0x7c, 0x11, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x57, 0xa6, 0xe0, 0xe6, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff,
0xd1, 0x7e, 0x69, 0x7, 0x8d, 0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xff, 0xff, 0x3a, 0x20, 0x40, 0x9, 0x5, 0xb5,
0x25, 0x8, 0x55, 0xca, 0x19, 0xa0, 0x39, 0x5, 0x15, 0x2f, 0x62, 0x69, 0x74, 0x63, 0x6f, 0x69,
0x6e, 0x2d, 0x73, 0x65, 0x65, 0x64, 0x65, 0x72, 0x3a, 0x30, 0x2e, 0x30, 0x31, 0x2f, 0x0, 0x0,
0x0, 0x0, 0x1, send success, len:131
node version message
payload msg:
0x7c 0x11 0x1 0x0 0x5 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xd3 0xe0 0xa6 0x57
0x0 0x0 0x0 0x0 0x1 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xff 0xff 0x3d 0xab 0x74 0x1e 0x93 0xfe
0x5 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
0x0 0x0 0x0 0xff 0xff 0xd1 0x7e 0x69 0x7 0x20 0x8d 0x1b 0x8b 0x29 0x4c
0x18 0x6c 0xaa 0xdb 0x10 0x2f 0x53 0x61 0x74 0x6f 0x73 0x68 0x69 0x3a 0x30
0x2e 0x31 0x32 0x2e 0x30 0x2f 0x9a 0x78 0x6 0x0 0x1
Start Decode:version:70012
mVersion:70012
services:0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
timeStamp:1470554323
recv services:0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
recvIp:0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0x3d,0xab,0x74,:0x1e,0x93,0xfe,
recv services:0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
recvIp:0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xd1,0x7e,0x69,:0x7,0x20,0x8d,
nonce:0x1b,0x8b,0x29,0x4c,0x18,0x6c,0xaa,0xdb,
user_agent:0x2f,0x53,0x61,0x74,0x6f,0x73,0x68,0x69,0x3a,0x30,0x2e,0x31,0x32,0x2e,0x30,0x2f,strUserAgent:/Satoshi:0.12.0/|
Peer Block Height:424090
node verack message:
strCommand:verack
verack msg:msgLen:24
0xf9,0xbe,0xb4,0xd9,0x76,0x65,0x72,0x61,0x63,0x6b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5d,0xf6,0xe0,0xe2,
node ping message:
strCommand:ping
ping msg len:32
0xf9,0xbe,0xb4,0xd9,0x70,0x69,0x6e,0x67,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x8,0x0,0x0,0x0,0x88,0xda,0x1c,0xf5,0x9b,0x13,0x28,0x99,0xf5,0x46,0x15,0x60,
node addr message:
msgCommand:addr
addr msg:msgLen:55
0xf9,0xbe,0xb4,0xd9,
0x61,0x64,0x64,0x72,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x1f,0x0,0x0,0x0,
0xc4,0x9c,0x92,0x9a,
0x1,0xd3,0xe0,0xa6,0x57,0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xd1,0x7e,0x69,0x7,0x20,0x8d,
First , after i connected, I sent "version" message, and i didn't do anything more. then, I received four messages, in this stage, i didn't send any messages.
so, it is very strange.