UDP and TCP

I'm trying to verify my understanding of how the ports work here for both UDP and TCP (I think I know how TCP works, but definately not UDP). Assume this is the TCP session. Client ip = 1.1.1.1, Web Server ip = 8.8.8.8.

Client initiates connection to the web server

Client sends SYN to Server. src IP=1.1.1.1:src_port_X dst IP=2.2.2.2:dst_port_80

Server sends SYN ACK to Client. src IP=2.2.2.2:src_port_80 dst IP=1.1.1.1dst_port_X

Client sends ACK to Server. src IP=1.1.1.1:src_port_X dst IP=2.2.2.2:dst_port_80

 

I believe the above is correct. But now, I would like someone to explain this exact process for UDP (I appreciate there is not a 3 way handshake), but how do the src/dst port's work with UDP. Is it simply this?

Client sends DNS query to server

Client's connection  =  src IP=1.1.1.1:src_port_X dst IP=2.2.2.2:dst_port_53

Server's connection =  src IP=2.2.2:src_port_53 dst IP=2.2.2.2:dst_port_X

Comments

  • That is correct.

    Just to add something. TCP connection has 2 endpoints. When TCP server starts (For example) it has one endpoint with localIP=serverIP, localport=serverport, remoteIP=*,remoteport=*. When client connects to server, server creates new endpoint with local IP address as server IP and local port as server port and remote IP as client IP and remote port as client port. This is done for each new client connecting to this server IP:port.

    But in case of UDP, when client sends data to server, server does not create new endpoint. It uses its started endpoint with localIP=serverIP, localport=serverport, remoteIP=*, remotePort=*.

Sign In or Register to comment.