In this project, we will learn the basics of Transmission Control Protocol (TCP) and how to communicate to a webserver over TCP. We will request and receive packets from the Google web server using the above communication protocol. The 4Duino display is used to print the status of the connection and the received information for debugging purposes.
Transfer of Data over Internet
The 2 most common ways to transfer chunks of data (also known as packets) over the internet are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). This is built on top of the IP layer. This means whether you are sending a packet via TCP or UDP, that packet is sent to an IP address.
An Internet Protocol address (IP address) is a numerical label assigned to each device in a network. IP addresses are usually written and displayed in human-readable notation, such as 184.108.40.206. When you type the name of the website (www.google.com) you are actually referring to the IP address of the server associated with that website name.
When a service is initially started it is required to bind to a designated port number. This is requested by the client. Higher level application that uses TCP/IP such as Web protocol, Hypertext Transfer Protocol, have ports preassigned numbers. These are called “well-known ports”. For the HTTP service, port 80 is defined as default.
More on TCP
TCP is the most commonly used protocol on the Internet and it is connection oriented. It guarantees the recipient will receive the data in order by numbering them. Upon receiving the packets, the receiver must send a message back to the sender to acknowledge it received the message. If the sender doesn’t receive this acknowledge message it will assume the data was lost and resend the packets to ensure the recipient received them. This is one of the ways TCP ensures reliability of the communication. TCP is all about reliability – information sent with TCP are tracked so no data is lost or corrupt in transfer. However, this has a negative impact on the speed of data transfer.
HOW IT WORKS
When you type a website on the browser, your computer sends packets to the server’s IP address over TCP requesting for the web page. Your computer simultaneously requests the service to bind to a designated port, i.e. 80 for HTTP. The web server in return sends a stream of TCP packets, which your web browser puts together as a web page and display it for you.
In this project we are going to request and receive time stamp from the Google web server over TCP and print it on the 4Dunino display.
Read more: Time Stamp from Web Server