Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdTCPServer - Reading TCP option values from Header packet
#1
We have a requirement to read TCP option header values from TIdTCPServer component on any new TCP client connection to extract the client IP address from the header value (packet 1) originally inserted by the load balancer. How can we read this value from the header on any client connection?
Reply
#2
You need to be more specific. There are two different approaches that I know of, which one are you asking about, exactly?

In the 1st approach, a proxy/LB injects the client info directly into the headers of the final ACK of the TCP handshake, and the 1st data packet. I don't know any way to access this data with standard socket APIs.

In the 2nd approach, a proxy/LB uses the
PROXY protocol to send the client info after the TCP handshake and before the 1st data packet. This is very easy to implement with standard socket APIs, but requires prior knowledge that such info is going to be sent (unless you peek the socket to discover the protocol dynamically).

Reply
#3
Thank you Remi for your quick reply. Exactly the first approach we are trying here. If this is not possible, will leave this option. In the second approach, can you give some guidance on how to read this data from TdTCPServer events? In our current scenario, we use Windows LB and want to move to an another LB like Citrix. Your valuable suggestions will be very helpful.
Reply
#4
(11-22-2024, 04:14 AM)philip.joseph Wrote: Exactly the first approach we are trying here.

Then I can't help you with that. I cant find any information on any implementation that doesn't involve writing a custom socket stack that has direct access to the raw TCP header.

(11-22-2024, 04:14 AM)philip.joseph Wrote: In the second approach, can you give some guidance on how to read this data from TdTCPServer events?

Did you read the documentation I linked to earlier? Provided the LB actually implements this protocol, you would simply read the initial PROXY header message inside the server's OnConnect event, or in the 1st invokation of the OnExecute event, before reading anything else from the socket. It is the first data to arrive at the server after the TCP connection is fully established, before any of the client's tunneled data then arrives.

Reply
#5
Video 
(11-28-2024, 11:06 AM)rlebeau Wrote:
(11-22-2024, 04:14 AM)philip.joseph Wrote: Exactly the first approach we are trying here.

Then I can't help you with that. I cant find any information on any implementation that doesn't involve writing a custom socket stack that has direct access to the raw TCP header.

(11-22-2024, 04:14 AM)philip.joseph Wrote: In the second approach, can you give some guidance on how to read this data from TdTCPServer events?

Did you read the documentation I linked to earlier? Provided the LB actually implements this protocol, you would simply read the initial PROXY header message inside the server's OnConnect event, or in the 1st invokation of the OnExecute event, before reading anything else from the socket.  It is the first data to arrive at the server after the TCP connection is fully established, before any of the client's tunneled data then arrives.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)