Data Communication & Networks · 2025–26

DCN Practical Exam Kit

Ten selected experiments · aim, procedure, runnable code, illustrated output and result

← 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

  1. Create/open Terminal 1 in this directory. Run python tcp_server.py first; server waits on 127.0.0.1:5000.
  2. Create Terminal 2; run python tcp_client.py.
  3. Server prints message received; client prints server response. Files: tcp_server.py, tcp_client.py.

PART B — UDP SERVER/CLIENT

  1. Terminal 1: python udp_server.py (port 6000).
  2. Terminal 2: python udp_client.py.
  3. Server receives a datagram; client receives UDP response. Files: udp_server.py, udp_client.py.

PART C — TCP TRANSMISSION DELAY SIMULATION

  1. Terminal 1: python congestion_server.py (port 5001).
  2. Terminal 2: python congestion_client.py; sends 20,480 bytes in 4096-byte chunks with short artificial delays.
  3. Server sums received bytes and displays total. Speed adjustment: to match the manual exactly, change message length to 1_000_000 bytes, client sleep to 0.2 and server sleep to 0.5 — this will take much longer.
  4. Artificial sleep delays illustrate slow application transfer; they do not guarantee genuine network congestion, retransmissions or congestion-window changes.

WIRESHARK STEPS

  1. Start capture on the loopback interface for 127.0.0.1 traffic (Windows: Npcap loopback adapter), not ordinary Ethernet.
  2. TCP display filter tcp.port == 5000, UDP udp.port == 6000, delayed TCP tcp.port == 5001.
  3. 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