UDP and TCP client

Description

  • Michal Ondrejka

  • GitHub

  • march, 2023

This project was implemented to understand how packets are moved through network. It improved my understanding of addressing and routing. I only implemented clients and used simple server for testing
First I handeled command line arguments, where user can specify mode (TCP/UDP), host port and host ip. I created socket based on the mode argument. Then I created necessary structs for addressing the host when sending and receiving the packets. There is main while loop which based on the type of communication (receive or send data) handles and expects certain packets. In TCP a three way handshake is executed first. At the end all of the structs in memory is freed to ensure correct usage of available resources.
In TCP each packets is acknowledged with ACK packet (2nd picture) from the receiver to ensure no packets have been lost in network. UDP (1st picture) is used for video and audio streams for example, where one missing package won't have a big impact. The packets are not acknowledged. To verify the corectness of the packets Wireshark (3rd picture) was used to check every bit of packet.

Technology