2

If a sock proxy can have multiple clients connected to it, all of them sending and receiving data simultaneously, how does the proxy keep track of each individual request?

Since they are all connected to the same ip address on the same port, how can the proxy know who asked for what and who to send the reply to ?

1 Answer 1

3

Socks operates at OSI Layer 5 (The session layer), so it can add additional information about the flow, including the destination information. This is known as a Circuit level gateway.

For proxying TCP connections, When a socks connection is requested by a client, between the socks proxy and the destination, the client sends a CONNECT command, with the destination information. At this time the server notes the client address/port, so it knows which client requested it.

The proxy server then establishes a TCP connection with the destination server, which involves negotiating a Sequence number. This number can be used to tie all packets in the connection together and to the initial client request.

On subsequent connections to the proxy, the client uses the BIND verb, which allows the server to distinguish the clients first flow from its second, third, ... nth. All it has to remember is the client information and the sequence numbers.

For proxying UDP flows, the initial client -> proxy communication is handled in TCP, calling the UDP ASSOCIATE verb, which allows the proxy to tie the UDP connection to the client and give it an identity by which it can send UDP streams on to the client.

See spec details here: http://www.faqs.org/rfcs/rfc1928.html

1
  • +1 for describing it at the session layer - the layer almost nobody understands! I shall trust your explanation!
    – barlop
    Nov 24, 2014 at 21:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .