Skip to content

tcp proxy

Kirill Scherba edited this page May 24, 2018 · 2 revisions

TCP Proxy conception

Module: tcp_proxy.c

The basic Teonet transport is UDP. There is some network where UDP connections is impossible. In this case Teonet uses TCP connection to r-host with TCP Proxy module enable. TCP Proxy module controls client connections, and starts and manages UDP connection inside the ksnMulti module for all connected client.

TCP Proxy conception structure scheme:

.

Scheme sources: https://drive.draw.io/#G0B11kd5eSht0oV0xIRUhHZ3N0R1U

Description of TCP Proxy algorithm:

If Client (A, B) can't connect by UDP it:

  • connect to R-Host by TCP
  • resend all UDP and TR-UDP datagrams to R-Hosts TCP Server
  • got TCP packets from server and process it like UDP packets

In Server :

  • TCP Server create connections between client and TCP Proxy module
  • TCP Proxy module open separate Event manager through Multi module for all connection and resend packet between Event managers and it TCP clients

TCP Proxy message structure:

  • Whole checksum: Check sum of this TCP package
  • Version: Version of the TCP Proxy protocol
  • Command: TCP Proxy command
  • Port number: UDP peers port number
  • Package length: UDP package length
  • Address string length: UDP peers address string length included trailing zero
  • Header checksum: Check sum of this TCP package header
  • Address string + Package: The address string included trailing zero and UDP package followed

Scheme sources: https://drive.draw.io/#G0B11kd5eSht0oSDBud2xEclFqams