Académique Documents
Professionnel Documents
Culture Documents
1: Introduction 2
1
Paradigme client-serveur
Les réseaux typiques ont deux
application
parties : le client et le serveur transport
network
data link
Client: physical
Protocole applicatif
1: Introduction 4
2
Quel est le service de transport nécessaire
à une application?
Pertes de données
? Certaines applis (e.g., audio)
peuvent tolérer des pertes
? D’autres applis (e.g., ftp,
telnet) nécessitent une Timing
fiabilité à 100%
? Certaines applis (e.g., voix
sur IP, jeux interactifs)
Bande passante nécessite un délai faible
? Certaines applis (e.g.,
multimedia) requiert une
bande passante minimale
? D’autre applis (“applis
elastique”) utilisent la
bande passante disponible
1: Introduction 5
1: Introduction 6
3
Services proposés dans Internet
Protocole de
Application Protocol applicatif transport
1: Introduction 8
4
Le Web: jargon
? L’Agent Utilisateur
? Page Web:
pour le Web est le
? Contient des “objects”
browser:
? Adressé par une URL
? MS Internet Explorer
? La plupart des pages Web ? Netscape Communicator
pages contiennent :
? Le serveur Web:
? Page HTML de base
? Apache (domaine public)
? Objets référencé
? MS Internet
? L’URL a deux composants: Information Server
nom d’hôte et chemin
d’accès
www.someSchool.edu/someDept/pic.gif
1: Introduction 9
HTTP: hypertext
transfer protocol htt
p re
que
? Couche applicative Web PC exécutant htt st
p re
Explorer spo
? Modèle client/serveur nse
?client: browser qui
demande, reçoit,
est
affiche les objets Web requ Server
p se
? serveur: serveur Web htt spon exécutant
e
pr Apache
envoit les réponses aux htt
server
requêtes
? http1.0: RFC 1945 Mac exécutant
? http1.1: RFC 2068 Netscape
1: Introduction 10
5
Le protocole HTTP
HTTP: service de HTTP est « sans état »
transport TCP : ? Le serveur ne maintient
aucunes informations au
? Le client initie un connexion sujets des requêtes
TCP (crée une socket) au précédentes des clients
serveur, port 80
? Le serveur accepte la Les protocoles gardant un
connexionTCP du client “état” sont complexe!
? Les messages HTTP ? L’histoire passée doit être
(protocole applicatif) sont gardée
échangés entre le browser ? Si le serveur ou le client se
(client HTTP) et le serveur crashe les états peuvent
Web être inconsistent
? La connexion TCP est close
1: Introduction 11
Exemple HTTP
Si un utilisateur entre l’URL
www.someSchool.edu/someDepartment/home.index
6
http example (cont.)
4. Le serveur HTTP ferme la
connexion TCP
5. Le client HTTP reçoit la
réponse contenant le fichier
HTML file, l’affiche. En
décodant le fichier le browser
trouve les URLs référés
6. Les étapes 1-5 sont répétés
pour chaque URLs référencés
time
1: Introduction 13
Non-persistante Persistante
? HTTP/1.0 ? Par défaut dans HTTP/1.1
7
Format de message http : requête
Ligne de requête
(commandes GET /somedir/page.html HTTP/1.0
GET, POST, HEAD) User-agent: Mozilla/4.0
Accept: text/html, image/gif,image/jpeg
Lignes Accept-language:fr
d’entête
Le retour chariot,
indique la fin
du message
1: Introduction 15
1: Introduction 16
8
Format de message http : réponse
Ligne de status
(protocole
Code de status HTTP/1.0 200 OK
Etat) Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
Lignes
Content-Length: 6821
d’entêtes
Content-Type: text/html
1: Introduction 17
1: Introduction 18
9
Essayer le serveur http
1: Introduction 19
1: Introduction 20
10
GET conditionel
Caches Web
Goal: satisfaire la requête du client sans utiliser le
serveur initial
origin
? L’utilisateur pointe son server
navigateur vers le
cache : htt
Proxy
t
p re server eques
? Le client envoit toutes qu est r se
client http p
ses requête http vers res htt espon
pon pr
se
le cache web htt
t
ues htt
? Si l’objet est dans le
p req se p re
que
htt o n htt st
cache, on le retourne p
p res p re
sp
? Sinon on demande au htt on se
serveur initial et on
répond ensuite à la client
origin
requête server
1: Introduction 22
11
Pourquoi le Cache Web?
origin
servers
Hypothèse: le cache est
proche du client public
Internet
? Réduction du temps de
réponse
? Réduction du débit 1.5 Mbps
vers les serveurs access link
distant institutional
network
10 Mbps LAN
institutional
cache
1: Introduction 23
12
DNS name servers
Pourquoi pas de DNS ? Aucun serveur n’a tout les
centralisé? relations nom-vers-@IP
? Tolérance aux pannes serveurs de noms local:
single point of failure ? Chaque ISP, entreprise a
son propre (default) name
? Volume de trafic
server
? maintenance ? Les requêtes DNS vont en
premier au serveur de nom
local
Ne passe pas à l’échelle !
Serveur de nom autorisé
? Effectue les translations
nom/adresse d’un domaine
1: Introduction 25
1: Introduction 26
13
Simple DNS example root name server
host surf.eurecom.fr
2 4
wants IP address of 3
gaia.cs.umass.edu 5
1: Introduction 27
gaia.cs.umass.edu
1: Introduction 28
14
DNS: iterated queries root name server
recursive query: 2
iterated query
? puts burden of name 3
resolution on 4
contacted name
server 7
? heavy load? local name server intermediate name server
dns.eurecom.fr dns.umass.edu
iterated query: 5 6
1
? contacted server
8
replies with name of
authoritative name server
server to contact dns.cs.umass.edu
? “I don’t know this requesting host
name, but ask this surf.eurecom.fr
server”
gaia.cs.umass.edu
1: Introduction 29
1: Introduction 30
15
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type,ttl)
? Type=A ? Type=CNAME
? name is hostname ? name is an alias name
? value is IP address for some “cannonical”
(the real) name
? Type=NS
? value is cannonical
? name is domain (e.g.
foo.com) name
value is IP address of
?
authoritative name server
? Type=MX
for this domain ? value is hostname of
mailserver associated with
name
1: Introduction 31
msg header
? identification: 16 bit # for
query, repy to query uses
same #
? flags:
? query or reply
? recursion desired
? recursion available
? reply is authoritative
1: Introduction 32
16
DNS protocol, messages
RRs in reponse
to query
records for
authoritative servers
additional “helpful”
info that may be used
1: Introduction 33
Socket programming
Goal: learn how to build client/server application that
communicate using sockets
1: Introduction 34
17
Socket-programming using TCP
Socket: a door between application process and end-
end-transport protocol (UCP or TCP)
TCP service: reliable transfer of bytes from one
process to another
controlled by
controlled by process application
application process
developer
developer socket socket
TCP with TCP with controlled by
controlled by
buffers, operating
operating buffers, internet system
system variables variables
host or host or
server server
1: Introduction 35
1: Introduction 36
18
Socket programming with TCP
iinFromServer
outToServer
? server reads line from socket
? server converts line to
uppercase, sends back to
client
inFromUser
? client reads, prints modified
line from socket
(inFromServer stream) client socket
1: Introduction 37
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
1: Introduction 38
19
Example: Java client (TCP)
import java.io.*;
import java.net.*;
class TCPClient {
sentence = inFromUser.readLine();
Send line
to server outToServer.writeBytes(sentence + '\n');
clientSocket.close();
}
}
1: Introduction 40
20
Example: Java server (TCP)
import java.io.*;
import java.net.*;
class TCPServer {
1: Introduction 41
Create output
stream, attached DataOutputStream outToClient =
to socket new DataOutputStream(connectionSocket.getOutputStream());
Read in line
from socket clientSentence = inFromClient.readLine();
1: Introduction 42
21
Socket programming with UDP
1: Introduction 43
write reply to
serverSocket
read reply from
specifying client
host address, clientSocket
port umber close
clientSocket
1: Introduction 44
22
Example: Java client (UDP)
import java.io.*;
import java.net.*;
class UDPClient {
public static void main(String args[]) throws Exception
{
Create
input stream BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
Create
client socket DatagramSocket clientSocket = new DatagramSocket();
Translate
hostname to IP InetAddress IPAddress = InetAddress.getByName("hostname");
address using DNS byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
1: Introduction 46
23
Example: Java server (UDP)
import java.io.*;
import java.net.*;
class UDPServer {
public static void main(String args[]) throws Exception
Create {
datagram socket
DatagramSocket serverSocket = new DatagramSocket(9876);
at port 9876
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];
while(true)
{
Create space for
received datagram DatagramPacket receivePacket =
new DatagramPacket(receiveData, receiveData.length);
Receive serverSocket.receive(receivePacket);
datagram
1: Introduction 47
sendData = capitalizedSentence.getBytes();
Create datagram
DatagramPacket sendPacket =
to send to client new DatagramPacket(sendData, sendData.length, IPAddress,
port);
Write out
datagram serverSocket.send(sendPacket);
to socket }
}
} End of while loop,
loop back and wait for
another datagram
1: Introduction 48
24