Expand description
Net crypto module allows to send data between two friends and provides encryption, ordered delivery, and perfect forward secrecy.
It can use both UDP and TCP (over relays) transport protocols to send data and can switch between them without the peers needing to disconnect and reconnect. For example two Tox friends might first connect over TCP and a few seconds later switch to UDP when a direct UDP connection becomes possible. Direct UDP is preferred over TCP because it is direct and isn’t limited by possibly congested TCP relays.
Modules§
- errors
- Module for errors of NetCrypto.
Structs§
- Connection
Addr - UDP address of a connection with the time when last UDP packet was received
- Crypto
Connection - Secure connection to send data between two friends that provides encryption, ordered delivery, and perfect forward secrecy.
- NetCrypto
- Struct that manages crypto connections to friends and handles net crypto packets from both UDP and TCP connections.
- NetCrypto
NewArgs - Arguments for creating new
NetCrypto
. - Recv
Packet - Received but not handled data packet that is stored in
PacketsArray
- Sent
Packet - Sent but not confirmed data packet that is stored in
PacketsArray
- Status
Packet With Time - Packet that should be sent to the peer every second together with info how many times it was sent and when it was sent last time
Enums§
- Connection
Status - Status of crypto connection.
- Status
Packet - Packet that should be sent every second. Depending on
ConnectionStatus
it can beCookieRequest
orCryptoHandshake
Constants§
- CONGESTION_
EVENT_ TIMEOUT - Timeout for increasing speed after congestion event.
- CONGESTION_
LAST_ SENT_ ARRAY_ SIZE - How many numbers of sent lossless packets should be recorded for congestion
control. It should be bigger than
CONGESTION_QUEUE_ARRAY_SIZE
due to rtt. - CONGESTION_
QUEUE_ ARRAY_ SIZE - How many last sizes of
send_array
should be recorded for congestion control. - CRYPTO_
MIN_ QUEUE_ LENGTH - Minimum packets in the send queue to reduce send rate.
- CRYPTO_
PACKET_ MIN_ RATE - Minimum packets rate per second.
- CRYPTO_
SEND_ PACKET_ INTERVAL - Interval between sending cookie request/handshake packets.
- CRYPTO_
SEND_ PACKET_ INTERVAL_ MS - Interval in ms between sending cookie request/handshake packets.
- DEFAULT_
RTT - Default RTT (round trip time)
- MAX_
NUM_ SENDPACKET_ TRIES - The maximum number of times we try to send the cookie request and handshake before giving up
- PACKET_
COUNTER_ AVERAGE_ INTERVAL - The dT for the average packet receiving rate calculations.
- PACKET_
COUNTER_ AVERAGE_ INTERVAL_ MS - The dT for the average packet receiving rate calculations (in ms).
- REQUEST_
PACKETS_ COMPARE_ CONSTANT - Ratio of recv queue size / recv packet rate (in seconds) times the number of ms between request packets to send at that ratio.
- SEND_
QUEUE_ CLEARANCE_ TIME - If the send queue grows so that it will take more than 2 seconds to send all its packet we will reduce send rate.
- TCP_RTT
- RTT (round trip time) for TCP connections
- UDP_
DIRECT_ TIMEOUT - If we don’t receive UDP packets for this amount of time the direct UDP connection is considered dead