← Back to kitOffline reference
Experiment 9 — TCP, UDP and TCP Delay Simulation
Manual pages: 82–88 | Tools: Python + Wireshark
AIM
To compare TCP/UDP communication and simulate port-based communication/congestion-related behavior using Python socket programming.
PART A — TCP SERVER/CLIENT
- Create/open Terminal 1 in this directory. Run
python tcp_server.pyfirst; server waits on127.0.0.1:5000. - Create Terminal 2; run
python tcp_client.py. - Server prints message received; client prints server response. Files: tcp_server.py, tcp_client.py.
PART B — UDP SERVER/CLIENT
- Terminal 1:
python udp_server.py(port 6000). - Terminal 2:
python udp_client.py. - Server receives a datagram; client receives UDP response. Files: udp_server.py, udp_client.py.
PART C — TCP TRANSMISSION DELAY SIMULATION
- Terminal 1:
python congestion_server.py(port 5001). - Terminal 2:
python congestion_client.py; sends 20,480 bytes in 4096-byte chunks with short artificial delays. - Server sums received bytes and displays total. Speed adjustment: to match the manual exactly, change message length to
1_000_000bytes, client sleep to0.2and server sleep to0.5— this will take much longer. - Artificial
sleepdelays illustrate slow application transfer; they do not guarantee genuine network congestion, retransmissions or congestion-window changes.
WIRESHARK STEPS
- Start capture on the loopback interface for
127.0.0.1traffic (Windows: Npcap loopback adapter), not ordinary Ethernet. - TCP display filter
tcp.port == 5000, UDPudp.port == 6000, delayed TCPtcp.port == 5001. - Observe TCP SYN / SYN-ACK / ACK; UDP has no connection setup handshake.
EXPECTED OUTPUT
TCP Server: Received: Hello Server (TCP)
TCP Client: Server: Message received via TCP
UDP Server: Received: Hello Server (UDP)
UDP Client: Server: Message received via UDP
Delay server: Total bytes: 20480
See EXPECTED_OUTPUT.txt.
RESULT
Thus, TCP and UDP client–server exchanges were simulated using Python; traffic was inspected in Wireshark and delayed TCP transmission was demonstrated.
VIVA
- TCP is connection-oriented and reliable, UDP is connectionless and does not guarantee delivery.
- TCP:
SOCK_STREAM, bind/listen/accept/connect; UDP:SOCK_DGRAM, sendto/recvfrom. 127.0.0.1is the loopback IP; ports identify individual services.