A pattern where both parties communicate in real-time with minimal delay.
Parties do not need to be available at the same time; messages can be stored and retrieved later.
A model where one device (the client) requests resources or services from another device (the server).
A model where each device (peer) can act as both a client and a server, sharing resources directly.
Assuming the server has some data that the client needs, there are four main patterns for how the client can get that data:
| Pattern | Initiator | Connection Type | Timing | Use Cases |
|---|---|---|---|---|
| Active Connection | Both | Persistent | Sync/Async | Chat, streaming, online gaming |
| Push | Server | Persistent/On-demand | Async | Push notifications, live updates |
| Pull | Client | On-demand | Async | Web browsing, API requests |
| Polling | Client | Repeated | Async | Email checking, software updates |
A connection that remains open for the duration of the communication, allowing data to be exchanged at any time.
The server sends (pushes) data to the client as soon as it becomes available, without the client needing to request it each time.
The client requests (pulls) data from the server whenever it needs information.
The client repeatedly requests (polls) the server at regular intervals to check if new data is available.
Protocols are standardized rules for communication.
In each of the above patterns, the client / server may send messages back and forth to coordinate the transfer of the payload (the actual data being transferred).
The TCP header format specifies how the computer should interpret the information. Each field has a set length, position, and purpose.
If the standard was not followed exactly, the data would be misinterpreted.
Paper Airplane Protocol
You have developed a paper airplane mode of communication, that you would like to use to serve song lyrics to your friends.
The server, a computer, is very literal. It uses an algorithm to understand the message that was sent, and responds using the same format.
Packet Number
Sender Address
Receiver Address
Action
Payload (text data to be transferred)
Data Length (character count of the payload)
Checksum (md5 hash of the payload)
Diagram
Paper Airplane Protocol - DrawIO
Client
Request
1
Desk 4
Desk 11
Get Lyrics
Beatles;Yellow Submarine;Yellow Submarine
41
666180b3e449222c2241b2afe32bfca3
Server
Response
1
Desk 11
Desk 4
Data Transfer
In the time that I
18
9eceaa495884413082c94280d965738e
2
Desk 11
Desk 4
Data Transfer
was born, lived a man
21
690c8054749a1cb7fb448c5804613dc3
3
Desk 11
Desk 4
Data Transfer
in a submarine. ^ENDMESSAGE^
28
0582957562b0492f8ad2aa0807ea1154
Each layer of the model encapsulates information from the layer beneath it, and adds information relevant to the layer above it.
This makes a "sandwich" of information, with the outermost layer being the application layer, and the innermost layer being the physical layer.