IP, port, TCP/UDP
TCP stands for Transmission Control Protocol. It produces a continuous stream of bytes, with no internal boundaries. Interpreting this byte stream is the job of an application protocol — rules for making sense of the byte stream, including how to split it into messages.
Data serialisation Maps objects (contained in ‘message’) to bytes and Deserialisation (bytes to object). You can do this trivially via JSON or Protobuf libraries.
Layers of protocols
Abstract idea: Network protocols are divided into layers. A lower layer can contain a higher layer as payload, and the higher layer adds new functions.
Reality: Ethernet contains IP, IP contains UDP or TCP, UDP or TCP contains application protocols.
We can also divide the layers by function:
TCP/IP Model
Network protocols layered by function:
| Subject | Function | |
|---|---|---|
| Higher | TCP | Reliable & ordered bytes |
| ↕ | Port in TCP/UDP | Multiplex to programs |
| Lower | IP | Small, discrete messages |
What’s actually relevant to us The layers above IP are what we care about. Applications use TCP or UDP, either directly by rolling their own protocol, or indirectly by using an implementation of a well-known protocol. Both TCP and UDP are contained by IP. Everything is built on top of TCP or UDP.
Ethernet is below IP, it’s also packet-based but uses a different type of address (MAC)