The most famous communication model on the Internet is the bidirectional byte stream model. Some of the applications that use bidirectional byte stream model are: HTTP, Bittorrent and Skype. We explore the three of them in this blog post.
Local applications vs networked applications
We must distinguish between networked applications vs local applications. Local applications manipulate data on the local computers. Networked applications manipulate data that we can share across an IP network.
Describing the Byte Stream model
The following points describe the byte stream model:
- Two nodes A and B want to communicate with each other. First a connection is established. Then, if A wants to communicate with B, it writes date to the connection. B reads data from the connection.
- A or B can tear down the connection. For example, “connection reset by peer” in HTTP means that the web server closed the connection.
Let’s review three famous applications that use the bidirectional byte stream communication model.
- client/server model
- a connection is established between the client and the server first
- Whether it is the client or the server, if it wants to send data, it writes to the connection. If it wants to receive data, it reads from the connection
- HTTP uses what is called methods to request or send data to the server. The most popular methods are GET (to request data) and POST (to send data such as after filling an online form)
- With each HTTP response there’s an associated code. Probably the most famous status codes are 200 OK and 404 Not Found.
- Uses a peer-to-peer model
- used to transfer big files
- clients request files from other clients and not from servers
- client uses the torrent file to get a description of the file to be downloaded and to find the Tracker
- client downloads “pieces” from other clients
- clients form what is known as swarms
- Tracker: a server that keeps track of which clients are part of the swarm
- if a client completes downloading a file it becomes a seeder which means it has the complete file and it can be the source for other downloading clients
For more information on Bittorrent, please read this post.
- was bought by Microsoft in May 2011
- Is a proprietary system
- uses both models (in different scenarios) client/server model and peer-to-peer model
- in the simple client/server model, both clients send requests and responses to each other
- In the simplest scenario, if client A (on the internet) wants to communicate with client B, it opens a connection with it. Similarly, if client B wants to communicate with client A, it opens a connection with it.
If there is a NAT server (client A is on the Internet; client B is behind NAT):
- client B can open a connection to client A and establish communication. However, client A can not initiate a connection to client B because of the NAT server. So in order to allow an external device to establish a Skype communication with an internal host sitting behind a NAT server, We need to introduce a Rendezvous server
- if client A wants to open a connection to client B, it opens a connection with Rendezvous server instead of client B. Then Rendezvous server opens a connection with client B. Client A sends data to the connection it has made with Rendezvous server, and Rendezvous server sends the data to the connection it made with client B.
If both clients A and B are behind NAT servers then both clients A and B can not open a connection to each other
→ The solution is to introduce a new type of servers: the Relay server. Both clients A and B open a connection with to Relay server. If any client wants to communicate with the other, it sends data to the connection with Relay server. The Relay server sends data to the connection with the opposite client.