Hello everybody!
In the last video we saw how the Internet is organized in layers
In this video, we are going to talk about the first layer : the application layer
This layer contains the applications you use every day directly
in the 70s emails and file transfer applications were created
Then Internet became very popular in the 90s with the apparition of the Web
And from the year 2000 a lot of very different applications made their apparition
like VoIP, movie streaming, online games and more recently social networks
All these applications are so diverse that we can't say much about how they work in general
However we can divide them in 2 categories : client-server and peer-to-peer
In a client-server application, all hosts are divided in 2 types : the clients and the servers
The clients are the computers and smartphones that you use directly
The servers are computers constantly online 24/7 365 days per year and providing information to the clients
So the clients never communicate directly between them
they always do it via a server
On the other hand, in a peer-to-peer application all hosts are of a same type : peers
So your computer is both a client and a server
all hosts communicate directly between them without going through a server
each of these architectures has pros and cons
some applications work better with a client-server architecture
and others better with a peer-to-peer architecture
we are now going to see 2 examples of client-server applications and 1 example of a peer-to-peer application
Let's start with the most famous application : the web
This application allows clients to retrieve information from servers by using HTTP
The server sends file in different formats to the client
HTML for the structure and text of a web page
CSS for the style of the page
and javascript for the code that will be executed on your computer
According to HTTP, a client wishing to connect to a Web server must send a well-defined request
for example, if he wants to read the page welcome.html on a website called www.unsite.com
He will have to send the following request : GET www.unsite.com/welcome.html
the keyword 'GET' means the client asks the server for information
on the other hand, if the client wants to send information to the server (login for example)
he will use the keyword 'POST'
This way HTTP defines several keywords for the communications
between the client and the server
HTTP also defines many status codes that the server will send to the client
in order to inform him on how did the request go
If everything went fine it will send a 200 Ok status code
If the page requested by the client doesn't exist it will send a 404 not found
that you have probably already seen, there are many HTTP status codes
if you see sometimes a 500, it means you made the server crash
To deal with these HTTP commands we created several applicatons
on the client side, that's what we call 'browsers'
like chrome, firefox, safari or internet explorer
and on the server side the most famous ones are Apache, Nginx and more recently Node js
Let's move on to another very famous application : the email
Consider 2 users Didier and Oscar who want to communicate with emails
If Didier wants to send an email to Oscar but Oscar's computer is turned off
He can't do it directly, so he will use the protocol SMTP
Didier will use SMTP to send his email to his server, this server will then transfer the email
using SMTP to the server of Oscar, that is constantly turned on
once Oscar turns on his computer, he will connect to his server using another protocol
So either POP, IMAP or HTTP to ask his email to his server
SMTP uses very precise rules for communications between clients and servers
We will now see a very concrete example of how to send an email with the command line
So we start by connecting to our mail server, me I am using the mail server from epfl
with telnet on port 25, I will explain later what is a port number
We start with the command HELO to introduce oneself, me I use HELO informateur
Once it is done, we must say with which source mail address we want to send this email
We use the command MAIL FROM and enter our mail address
Once it is done the server answers with a 250 Ok
And now we must say to whom we want to send this email, we use the command RCPT TO
Once it is done, the server again responds with a 250 Ok
Now we use the command DATA to say the content of the email
It answers with a 354 go ahead
and we send the content of the email, me I just enter "hi"
When we are done we put a dot and use the command QUIT
After this concrete example, if you were vigilant you will have noticed a security flaw in SMTP
but I will tell you more in the security module
Let's now move on to a peer-to-peer application : distributed file sharing with BitTorrent
You probably all know this protocol and I am sure you use it completely legally
This application allows to share a file between users without the need of a server
The protocol BitTorrent is very complex, with several different mechanisms
So I will present it here in a very superficial way
When you download a torrent file from a website, you start by registering to a computer called "tracker"
It will send you a list of all peers who want to share this file
The file is split in different chunks
Every user possess different chunks at different moments in time
As a user you will connect to each of these peers and ask them which chunks they have
Once you know which peer has which chunks,
you will choose a chunk you don't have and ask for it to a peer who has it
As a peer you will also receive requests from other peers who ask you for chunks
According to protocol BitTorrent, you will send chunks only to those who send you the most data
And from time to time, you will send a chunk to a random peer even if he doesn't send you anything
I will now introduce a somewhat special protocol : DNS
It is not an application like the others because you don't use it directly, even if you use it every day
DNS is responsible to translate websites' names into IP addresses
For now you don't need to know exactly what is an IP address, I will tell you more in the network layer video
For now, you just need to know that it is a sequence of digits that identify each location of the network
Since it is not very convenient for humans to remember sequences of numbers we invented names for websites
For example when you send a HTTP request to www.google.ch
You first have to know the IP address of this website
So you send a DNS request to a DNS system, asking it what is the IP address of www.google.ch
And the DNS servers answers you that www.google.ch's IP address is : 187.152.11.2
Then you will use this IP address to connect to the google server
How can we build such a DNS system?
We can imagine the naive case : one big computer to store all names and their corresponding IP addresses
But it would have enormous problems as you can imagine, every user will connect to this same computer
It would be overloaded, second : it cannot be close to everyone since it has to be somewhere on the planet
and third : if this computer crashes, all the Internet is unavailable for everyone
We can imagine duplicating that computer across the globe
This users are close to the system wherever they are
And if one computer crashes, there are still other computers to provide the service
But now if there is a change in one computer we must replicate this change in all computers
Moreover, it is a waste to store all information in each computer
We can conceive to distribute the database across the different DNS servers
This way there is no need to replicate the changes, but this create new problems
If a DNS server doesn't know the IP address of a website, it must ask all the other DNS servers
who knows that IP address
The solution is to organize DNS in hierarchy
We have 3 kinds of DNS servers : root, TLD, authoritative
Currently we have 13 root DNS servers, most of them located in the United States
These root DNS servers know the IP addresses of the TLD DNS servers
who are each responsible for one domain name
So for example we have TLD servers for .com .net .org
and each of these TLD servers knows the IP addresses of some authoritative DNS servers
So for example if you want to connect to www.amazon.com
You start by contacting a root DNS server
You ask him what is the IP address of the TLD server responsible for the domain name .com
He will give you an IP address and now you can contact the TLD server for .com
You ask him what is the IP address of the DNS server responsible for amazon.com
He will give you the IP address of that DNS server
and now you can contact this DNS server
and ask him what is the IP address of the website www.amazon.com
he will answer you with an IP address and you can use that IP address to do your HTTP request
We will now see how to perform a DNS request in order to then access a website
So for example on Linux we can use the command 'nslookup'
Here I take the example of facebook, so I want to know the IP address of www.facebook.com
I contacted my DNS server who tells me the IP address of facebook is 31.13.91.36
I can now copy this IP address and paste it in my browser
and I access the facebook welcome page
There is one last aspect of the application layer i want to talk to you about : proxys and caches
A proxy server is a relay to which you send your requests, then it performs your requests for you
The point is to store in memory the requests already executed, that's what we call a cache
So for example if Oscar wants to send a HTTP request to the server www.google.ch
He first send his request to his proxy server, then the proxy sends the request to the google server
When it receives the response, it keeps it in memory and send it to Oscar
Now if Didier wants to see the same website www.google.ch
He also send his request to the proxy server, but the proxy server already knows the response kept in memory
So it doesn't need to contact the google server and sends directly the response to Didier
in this presentation of the application layer, we assumed that each request arrives magically every time at destination
That's because we abstracted the next layer, the transport layer, who solves all these questions
That will be the topic of our next video
It is now the end of this video! I hope you understood and enjoyed this introduction to the application layer
Of course I had to select between the applications, so feel free to ask in the comments
if you would like a complement about an application that was not presented
or more information about an application that was presented
Otherwise see you soon for another video about the transport layer!
Không có nhận xét nào:
Đăng nhận xét