PI

From Gnutella2
Jump to: navigation, search

Root Packets
CRAWLA - CRAWLR
HAW - LNI
KHL - KHLA - KHLR
PI - PO - PUSH
QKA - QKR
Q2 - QA - QH2 - QHT
UPROC - UPROD

/PI - Ping

The ping packet is used to verify the presence of the addressed node, testing that:

  • The destination node is online
  • The destination node can receive the transmission
  • The local node can receive the reply

Aside from performing a "keep-alive" function on TCP links, pings can be used to solicit inbound UDP datagrams to test the local node's ability to receive UDP. Many NAT systems will route UDP traffic from nodes with whom a persistent TCP stream has been established, so it is necessary to test inbound traffic from nodes with which there is no TCP connection. This is achieved by sending a ping with a /PI/UDP packet to a connected hub via TCP, which will forward the request to its neighbours who then reply to the originator via UDP.

Sending

On a TCP stream connection, if one end has not received a valid packet from the other after an internally determined period of time, it has the option of sending a keep-alive ping to verify the other end's presence. If a pong is not received in a timeout period it may close the connection.

If a node needs to verify that it is able to receive UDP datagrams from nodes with which it does not have a TCP stream connection, it may send a ping packet with a /PI/UDP child packet. If it then receives a /PO (pong) packet with a /PO/RELAY child tag and there is no TCP connection to the sender, it can assume it is able to receive UDP.

Receiving

Upon receiving a keep-alive ping, a node should respond with a keep-alive pong immediately.

If the ping was received by a hub from a TCP neighbour and contains a /PI/UDP child packet, but no /PI/RELAY tag, a /PI/RELAY tag should be added and the packet forwarded to all neighbouring hubs. If a /PI/RELAY tag was present, the node should send a /PO packet with a /PO/RELAY tag to the UDP address identified in the /PI/UDP child packet.

Note that leaf nodes should never be forwarded /PI packets with a /PI/UDP child: these need to be handled by hubs only.

Payload

This packet has no payload at the current time.

Children

The ping packet has two child packets defined at the current time:

  • /PI/RELAY
  • /PI/UDP

/PI/RELAY - Relayed Ping Marker

If a /PI packet contains a /PI/RELAY child marker, the ping has been relayed for a third party. The receiving node should reply to the original party rather than the sender. The original party should be contacted via UDP with the address contained in the /PI/UDP child. If the /PI/UDP child is absent, the packet is invalid.

Sending

The /PI/RELAY child should be added to a /PI packet when relaying a ping to hub neighbours at the request of a leaf.

Receiving

Upon receiving a /PI packet with a /PI/RELAY tag, a /PO (pong) packet should be sent via UDP to the node identified in the /PI/UDP child.

Payload

This packet has no payload at the current time.

Children

This packet has no known children at the current time.


/PI/UDP - Ping Response Address

The /PI/UDP child packet specifies the return address for a relay able or relayed ping.

Sending

Add a /PI/UDP child packet to a /PI packet to request a relayed "two hop" ping.

Receiving

The /PI/UDP child packet indicates that a /PI packet needs to be relayed.

Payload

The /PI/UDP packet contains an endpoint address.

Children

This packet has no known children at the current time.