Protocols: TCP/IP and HTTP

Part of: Computer Systems & Networks

Layered Protocols The internet works because of protocols stacked in layers, where each layer trusts the one below it. The most important pairing is TCP/IP : - IP (Internet Protocol) handles addressing and routing : it gets packets to the right machine but does not guarantee they arrive or arrive in order. - TCP (Transmission Control Protocol) runs on top of IP and adds reliability : it numbers packets, acknowledges what arrived, retransmits losses, and reassembles the data in order. This separation is what makes it work: IP can stay simple and fast, while TCP handles the messy work of making delivery dependable. HTTP: The Web's Protocol On top of TCP sits HTTP (HyperText Transfer Protocol), the language of the web. A browser sends a request and the server returns a response . A request begins with a request line : That line has three parts: the method (what to do), the path (which resource), and the version . Common methods include GET (fetch a resource) and POST (send data). HTTPS is HTTP carried over an encrypted connection for security. Parsing a Request Line Why Layering Matters - Each layer has one job , so each can be improved independently. - HTTP does not worry about lost

Challenge: Parse an HTTP Request Line