Actually @emph{HALT} packet does not have any body, only the header
with the type. It is also used in the first payload for padding to
the maximum size.
+
@verbatim
+------+
| HALT |
+------+
@end verbatim
+@item PING
+ Dummy packet only used for determining workability of the connection.
+
+@verbatim
++------+
+| PING |
++------+
+@end verbatim
+
@item INFO
Information about the file we have for transmission.
+
@verbatim
+------+--------------------+
| INFO | NICE | SIZE | HASH |
+------+--------------------+
@end verbatim
+
@multitable @columnfractions 0.2 0.3 0.5
@headitem @tab XDR type @tab Value
@item Niceness @tab
@item FREQ
File transmission request. Ask remote side to queue the file for
transmission.
+
@verbatim
+------+---------------+
| FREQ | HASH | OFFSET |
+------+---------------+
@end verbatim
+
@multitable @columnfractions 0.2 0.3 0.5
@headitem @tab XDR type @tab Value
@item Hash @tab
@item FILE
Chunk of file.
+
@verbatim
+------+-------------------------+
| FILE | HASH | OFFSET | PAYLOAD |
+------+-------------------------+
@end verbatim
+
@multitable @columnfractions 0.2 0.3 0.5
@headitem @tab XDR type @tab Value
@item Hash @tab
@item DONE
Signal remote side that we have successfully downloaded the file.
+
@verbatim
+------+------+
| DONE | HASH |
+------+------+
@end verbatim
+
@multitable @columnfractions 0.2 0.3 0.5
@headitem @tab XDR type @tab Value
@item Hash @tab
Typical peer's behaviour is following:
-@verbatiminclude sp.utxt
+@verbatiminclude sp.plantuml.txt
@enumerate
@item Perform @emph{Noise-IK} handshake:
corresponding offset.
@end itemize
-@item When @emph{FREQ} packet received, append it to current sending
-queue. Sending queue contains files with offsets that are needed to be
+@item When @emph{FREQ} packet received, insert it to current sending
+queue with niceness level sort: higher priority packets will be sent
+first. Sending queue contains files with offsets that are needed to be
sent.
@item While sending queue is not empty, send @emph{FILE} packets.
delete @file{.part} suffix from file's name and send @emph{DONE} packet.
@item When @emph{DONE} packet received, delete corresponding file.
+
@item When @emph{HALT} packet received, empty file sending queue.
@item Each second, node checks: are there any new @emph{tx} packets
appeared and queues corresponding @emph{INFO} packets.
-@item If no packets are sent and received during @ref{CfgOnlineDeadline,
-onlinedeadline} duration, then close the connection. There is no
-explicit indication that session is over.
+@item Each minute, if no packets were sent, node sends @emph{PING}
+packet.
+
+@item If no non-PING packets are sent and received during
+@ref{CfgOnlineDeadline, onlinedeadline} duration, then close the
+connection. There is no explicit indication that session is over.
+
+@item If no packets are received during two minutes (two PING timeouts),
+then close the connection.
@end enumerate