">

La présentation est en train de télécharger. S'il vous plaît, attendez

La présentation est en train de télécharger. S'il vous plaît, attendez

2: Application Layer1 Protocoles… r compléments php r FTP r Courrier: smtp pop imap… r DNS r P2P.

Présentations similaires


Présentation au sujet: "2: Application Layer1 Protocoles… r compléments php r FTP r Courrier: smtp pop imap… r DNS r P2P."— Transcription de la présentation:

1 2: Application Layer1 Protocoles… r compléments php r FTP r Courrier: smtp pop imap… r DNS r P2P

2 2: Application Layer2 Compléments: php r php est un langage de script pour les serveurs webs r de nombreuses fonctions permettent de traiter les requêtes http r ici on est du côté du serveur…

3 2: Application Layer3 Exemple simplesimple Exemple très simple Exemple le

4 2: Application Layer4 Résultat Exemple le 8/11/2006 à 15:54:29 Client :Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;.NET CLR ; InfoPath.1) Adresse IP client: Server: localhost

5 2: Application Layer5 Reçu par le client Exemple très simple Exemple le 8/11/2006 à 15:54:29 Client :Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;.NET CLR ; InfoPath.1) Adresse IP client: Server: localhost

6 2: Application Layer6 Php r On est ici côté serveur: les balises sont interprétées par le serveur (apache par exemple) et servent à générer la page html reçu par le client r Mais surtout php permet d'accéder aux variables d'environnement d'utiliser de nombreuses fonctionsalités sessions, paramètres etc. r Php sert souvent d'interface pour MySql serveur simple de bases de données

7 2: Application Layer7 Php r pas de typage ni de déclaration des variables r $v est remplacé par la valeur de v (et permet aussi l'affectation) r echo "$v"; r constantes define("PI", ); r types des variables numériques $i=1; $v=3.14; chaînes de caractères (expressions régulières) $nom="Hugues"; ',",{}

8 2: Application Layer8 php r tableaux indicés $tab[0]="un"; $tab=array("un","deux","trois"); associatifs $m=array("un"=>"one", "deux"=>"two"); $m["trois"]="three"; next() prev() key() current() do {echo "Clé=key($m).Valeur= current($m)"} while(next($mes)); foreach($m as $cle =>$val) {echo "Clé=$cle.Valeur=$val";}

9 2: Application Layer9 Php r structures de contrôles if if else while do while for foreach break, continue

10 2: Application Layer10 fonctions function Nom([$arg1, $arg2,...]) { corps } passage par valeur (et pas références &) exemples function Add($i,$j){ $somme= $i + $j; return $somme; } function Add($i,$j,&$somme){ $somme= $i + $j; }

11 2: Application Layer11 divers r variables automatiques (locales) statiques (comme en C) globales r classes et objets

12 2: Application Layer12 Pour le serveur… r tableaux associatifs prédéfinis $_SERVER: environnement serveur REQUEST_METHOD QUERY_STRING CONTENT_LENGTH SERVER_NAME PATH_INFO HTTP_USER_AGENT REMOTE_ADDR REMOTE_HOST REMOTE_USER REMOTE_PASSWORD

13 2: Application Layer13 Suite r Autres tableaux $_ENV: environnement système $_COOKIE $_GET $_POST $_FILES $_REQUEST (variables des 4 précédents $_SESSION $GLOBALS les variables globales du scritp

14 2: Application Layer14 Cookies et php

15 2: Application Layer15 Cookies et php (fin) Les cookies Un compteur d'accès au site avec cookie

16 2: Application Layer16 En utilisant les sessions Les cookies Un compteur d'accès au site avec Session

17 2: Application Layer17 Fin 10){ echo "on vous a trop vu"." "; session_destroy(); } ?>

18 2: Application Layer18 session r session_start() r session_destroy() r session_id() on peut associer des variables à la session par le tableau associatif $_SESSION elle sera accessible à chaque session_start() jusqu'au session_destroy() pour toute connexion qui fournit le session_id().

19 2: Application Layer19 FTP: the file transfer protocol r transfer file to/from remote host r client/server model client: side that initiates transfer (either to/from remote) server: remote host r ftp: RFC 959 r ftp server: port 21 file transfer FTP server FTP user interface FTP client local file system remote file system user at host

20 2: Application Layer20 FTP: separate control, data connections r FTP client contacts FTP server at port 21, specifying TCP as transport protocol r Client obtains authorization over control connection r Client browses remote directory by sending commands over control connection. r When server receives a command for a file transfer, the server opens a TCP data connection to client r After transferring one file, server closes connection. FTP client FTP server TCP control connection port 21 TCP data connection port 20 r Server opens a second TCP data connection to transfer another file. r Control connection: out of band r FTP server maintains state: current directory, earlier authentication

21 2: Application Layer21 FTP commands, responses Sample commands: r sent as ASCII text over control channel USER username PASS password LIST return list of file in current directory RETR filename retrieves (gets) file STOR filename stores (puts) file onto remote host Sample return codes r status code and phrase (as in HTTP) r 331 Username OK, password required r 125 data connection already open; transfer starting r 425 Cant open data connection r 452 Error writing file

22 2: Application Layer22 Electronic Mail Three major components: r user agents r mail servers r simple mail transfer protocol: SMTP User Agent r a.k.a. mail reader r composing, editing, reading mail messages r e.g., Eudora, Outlook, elm, Netscape Messenger r outgoing, incoming messages stored on server user mailbox outgoing message queue mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP

23 2: Application Layer23 Electronic Mail: mail servers Mail Servers r mailbox contains incoming messages for user r message queue of outgoing (to be sent) mail messages r SMTP protocol between mail servers to send messages client: sending mail server server: receiving mail server mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP

24 2: Application Layer24 Electronic Mail: SMTP [RFC 2821] r uses TCP to reliably transfer message from client to server, port 25 r direct transfer: sending server to receiving server r three phases of transfer handshaking (greeting) transfer of messages closure r command/response interaction commands: ASCII text response: status code and phrase r messages must be in 7-bit ASCII

25 2: Application Layer25 Scenario: Alice sends message to Bob 1) Alice uses UA to compose message and to 2) Alices UA sends message to her mail server; message placed in message queue 3) Client side of SMTP opens TCP connection with Bobs mail server 4) SMTP client sends Alices message over the TCP connection 5) Bobs mail server places the message in Bobs mailbox 6) Bob invokes his user agent to read message user agent mail server mail server user agent

26 2: Application Layer26 Sample SMTP interaction S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: S: 250 Sender ok C: RCPT TO: S: 250 Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles? C:. S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection

27 2: Application Layer27 Try SMTP interaction for yourself: telnet servername 25 r see 220 reply from server r enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send without using client (reader)

28 2: Application Layer28 SMTP: final words r SMTP uses persistent connections r SMTP requires message (header & body) to be in 7- bit ASCII SMTP server uses CRLF.CRLF to determine end of message Comparison with HTTP: r HTTP: pull r SMTP: push r both have ASCII command/response interaction, status codes r HTTP: each object encapsulated in its own response msg r SMTP: multiple objects sent in multipart msg

29 2: Application Layer29 Mail message format SMTP: protocol for exchanging msgs RFC 822: standard for text message format: r header lines, e.g., To: From: Subject: different from SMTP commands! r body the message, ASCII characters only header body blank line

30 2: Application Layer30 Message format: multimedia extensions r MIME: multimedia mail extension, RFC 2045, 2056 r additional lines in msg header declare MIME content type From: To: Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data base64 encoded data multimedia data type, subtype, parameter declaration method used to encode data MIME version encoded data

31 2: Application Layer31 MIME r Multipurpose Internet Mail Extensions texte en caractères non US ASCII attachements messages en plusieurs parties défini dans l'entête du mail à l'origine pour le mail uniquement mais utilisé de plus en plus fréquemment (exemple HTTP) r SMTP ne considère que des caractères ASCII 7 bits d'où la nécessité de codage décodage

32 2: Application Layer32 MIME r Un message peut être en plusieurs parties (multipart) définies par l'entête "Content- Type" exemple Content-Type: text/plain L'entête d'un message peut contenir autre chose que du US ASCII (par exemple dans le champ SUBJECT: "=?charset?encoding?encoded text?=". Subject: =?utf-8?Q?=C2=A1Hola,_se=C3=B1or!?= (Subject: ¡Hola, señor!)

33 2: Application Layer33 MIME r Exemple de multipart Message: Content-type: multipart/mixed; boundary="frontier" MIME-version: 1.0 This is a multi-part message in MIME format. --frontier Content-type: text/plain This is the body of the message. --frontier Content-type: application/octet-stream Content-transfer-encoding: base64 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5Pgo gICAgAVGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWVzc2FnZ S48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg== --frontier--

34 2: Application Layer34 Mail access protocols r SMTP: delivery/storage to receivers server r Mail access protocol: retrieval from server POP: Post Office Protocol [RFC 1939] authorization (agent server) and download IMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex) manipulation of stored msgs on server HTTP: Hotmail, Yahoo! Mail, etc. user agent senders mail server user agent SMTP access protocol receivers mail server

35 2: Application Layer35 POP3 protocol authorization phase r client commands: user: declare username pass: password r server responses +OK -ERR transaction phase, client: list: list message numbers retr: retrieve message by number dele: delete r quit C: list S: S: S:. C: retr 1 S: S:. C: dele 1 C: retr 2 S: S:. C: dele 2 C: quit S: +OK POP3 server signing off S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on

36 2: Application Layer36 POP3 (more) and IMAP More about POP3 r Previous example uses download and delete mode. r Bob cannot re-read e- mail if he changes client r Download-and-keep: copies of messages on different clients r POP3 is stateless across sessions IMAP r Keep all messages in one place: the server r Allows user to organize messages in folders r IMAP keeps user state across sessions: names of folders and mappings between message IDs and folder name

37 2: Application Layer37 DNS: Domain Name System People: many identifiers: SSN, name, passport # Internet hosts, routers: IP address (32 bit) - used for addressing datagrams name, e.g., ww.yahoo.com - used by humans Q: map between IP addresses and name ? Domain Name System: r distributed database implemented in hierarchy of many name servers r application-layer protocol host, routers, name servers to communicate to resolve names (address/name translation) note: core Internet function, implemented as application-layer protocol complexity at networks edge

38 2: Application Layer38 DNS Why not centralize DNS? r single point of failure r traffic volume r distant centralized database r maintenance doesnt scale! DNS services r Hostname to IP address translation r Host aliasing Canonical and alias names r Mail server aliasing r Load distribution Replicated Web servers: set of IP addresses for one canonical name

39 2: Application Layer39 Root DNS Servers com DNS servers org DNS serversedu DNS servers poly.edu DNS servers umass.edu DNS servers yahoo.com DNS servers amazon.com DNS servers pbs.org DNS servers Distributed, Hierarchical Database Client wants IP for 1 st approx: r Client queries a root server to find com DNS server r Client queries com DNS server to get amazon.com DNS server r Client queries amazon.com DNS server to get IP address for

40 2: Application Layer40 DNS: Root name servers r contacted by local name server that can not resolve name r root name server: contacts authoritative name server if name mapping not known gets mapping returns mapping to local name server 13 root name servers worldwide b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA e NASA Mt View, CA f Internet Software C. Palo Alto, CA (and 17 other locations) i Autonomica, Stockholm (plus 3 other locations) k RIPE London (also Amsterdam, Frankfurt) m WIDE Tokyo a Verisign, Dulles, VA c Cogent, Herndon, VA (also Los Angeles) d U Maryland College Park, MD g US DoD Vienna, VA h ARL Aberdeen, MD j Verisign, ( 11 locations)

41 2: Application Layer41 TLD and Authoritative Servers r Top-level domain (TLD) servers: responsible for com, org, net, edu, etc, and all top-level country domains uk, fr, ca, jp. Network solutions maintains servers for com TLD Educause for edu TLD r Authoritative DNS servers: organizations DNS servers, providing authoritative hostname to IP mappings for organizations servers (e.g., Web and mail). Can be maintained by organization or service provider

42 2: Application Layer42 Local Name Server r Does not strictly belong to hierarchy r Each ISP (residential ISP, company, university) has one. Also called default name server r When a host makes a DNS query, query is sent to its local DNS server Acts as a proxy, forwards query into hierarchy.

43 2: Application Layer43 requesting host cis.poly.edu gaia.cs.umass.edu root DNS server local DNS server dns.poly.edu authoritative DNS server dns.cs.umass.edu 7 8 TLD DNS server Example r Host at cis.poly.edu wants IP address for gaia.cs.umass.edu

44 2: Application Layer44 requesting host cis.poly.edu gaia.cs.umass.edu root DNS server local DNS server dns.poly.edu authoritative DNS server dns.cs.umass.edu 7 8 TLD DNS server 3 Recursive queries recursive query: r puts burden of name resolution on contacted name server r heavy load? iterated query: r contacted server replies with name of server to contact r I dont know this name, but ask this server

45 2: Application Layer45 DNS: caching and updating records r once (any) name server learns mapping, it caches mapping cache entries timeout (disappear) after some time TLD servers typically cached in local name servers Thus root name servers not often visited r update/notify mechanisms under design by IETF RFC 2136

46 2: Application Layer46 DNS records DNS: distributed db storing resource records (RR) r Type=NS name is domain (e.g. foo.com) value is hostname of authoritative name server for this domain RR format: (name, value, type, ttl) r Type=A name is hostname value is IP address r Type=CNAME name is alias name for some canonical (the real) name is really servereast.backup2.ibm.com value is canonical name r Type=MX value is name of mailserver associated with name

47 2: Application Layer47 DNS protocol, messages DNS protocol : query and reply messages, both with same message format msg header r identification: 16 bit # for query, reply to query uses same # r flags: query or reply recursion desired recursion available reply is authoritative

48 2: Application Layer48 DNS protocol, messages Name, type fields for a query RRs in response to query records for authoritative servers additional helpful info that may be used

49 2: Application Layer49 Inserting records into DNS r Example: just created startup Network Utopia r Register name networkuptopia.com at a registrar (e.g., Network Solutions) Need to provide registrar with names and IP addresses of your authoritative name server (primary and secondary) Registrar inserts two RRs into the com TLD server: (networkutopia.com, dns1.networkutopia.com, NS) (dns1.networkutopia.com, , A) r Put in authoritative server Type A record for and Type MX record for networkutopia.com r How do people get the IP address of your Web site?

50 2: Application Layer50 P2P file sharing Example r Alice runs P2P client application on her notebook computer r Intermittently connects to Internet; gets new IP address for each connection r Asks for Hey Jude r Application displays other peers that have copy of Hey Jude. r Alice chooses one of the peers, Bob. r File is copied from Bobs PC to Alices notebook: HTTP r While Alice downloads, other users uploading from Alice. r Alices peer is both a Web client and a transient Web server. All peers are servers = highly scalable!

51 2: Application Layer51 Pair à pair r quelques principes les nœuds offrent des fonctionnalités identiques (pair) volatilité importante (apparition/disparition) grande échelle et dispersion géographique dynamicité importante r applications partage de fichiers messagerie téléphone (Skype) … différent du client-serveur

52 2: Application Layer52 Partage de fichiers r Communication basée sur deux types de protocoles différents découverte et localisation des fichiers recherche des données mettre en contact deux (ou plusieurs) utilisateurs parmi des millions téléchargement des fichiers

53 2: Application Layer53 Découverte-localisation r Base publication des fichiers partagés avec des méta-données découverte des fichiers disponibles localisation des sources à télécharger (En plus identification des doublons détection des fichiers corrompus forums)

54 2: Application Layer54 Architecture du réseau r Centralisée: un serveur ou un cluster sur lequel les clients se connectent (Napster) r Décentralisée: il n'y a que des clients (Gnutella) r Faiblement centralisée: des clients et des serveurs (Edonkey) r Hybride: les clients peuvent devenir des serveurs

55 2: Application Layer55 P2P: centralized directory original Napster design 1) when peer connects, it informs central server: IP address content 2) Alice queries for Hey Jude 3) Alice requests file from Bob centralized directory server peers Alice Bob

56 2: Application Layer56 P2P: problems with centralized directory r Single point of failure r Performance bottleneck r Copyright infringement file transfer is decentralized, but locating content is highly centralized

57 2: Application Layer57 Query flooding: Gnutella r fully distributed no central server r public domain protocol r many Gnutella clients implementing protocol overlay network: graph r edge between peer X and Y if theres a TCP connection r all active peers and edges is overlay net r Edge is not a physical link r Given peer will typically be connected with < 10 overlay neighbors

58 2: Application Layer58 Gnutella: protocol Query QueryHit Query QueryHit Query QueryHit File transfer: HTTP r Query message sent over existing TCP connections r peers forward Query message r QueryHit sent over reverse path Scalability: limited scope flooding

59 2: Application Layer59 Gnutella: Peer joining 1. Joining peer X must find some other peer in Gnutella network: use list of candidate peers 2. X sequentially attempts to make TCP with peers on list until connection setup with Y 3. X sends Ping message to Y; Y forwards Ping message. 4. All peers receiving Ping message respond with Pong message 5. X receives many Pong messages. It can then setup additional TCP connections Peer leaving: see homework problem!

60 2: Application Layer60 Exploiting heterogeneity: KaZaA r Each peer is either a group leader or assigned to a group leader. TCP connection between peer and its group leader. TCP connections between some pairs of group leaders. r Group leader tracks the content in all its children.

61 2: Application Layer61 KaZaA: Querying r Each file has a hash and a descriptor r Client sends keyword query to its group leader r Group leader responds with matches: For each match: metadata, hash, IP address r If group leader forwards query to other group leaders, they respond with matches r Client then selects files for downloading HTTP requests using hash as identifier sent to peers holding desired file

62 2: Application Layer62 KaZaA tricks r Limitations on simultaneous uploads r Request queuing r Incentive priorities r Parallel downloading

63 2: Application Layer63 Recherche par diffusion simple r les clients ne publient rien et ne font que des requêtes une requête est diffusée à tous les clients: avec une limite de portée (TTL) en évitant les cycles (identification unique de la requête, la requête contient le son chemin …) recherche en profondeur ou en largeur un client répond par le chemin emprunté par la requête

64 2: Application Layer64 Filtres de Bloom r Principe: un ensemble E de n éléments une fonction de hachage de E sur {1,m} un vecteur de m bits (le filtre) tester si x appartient à E si le bit h(x)=0 non si le bit h(x)=1 oui (mais peut être faux-positif) on peut diminuer les faux positifs en utilisant plusieurs fonctions de hachage r Si le client possède le document les bits des mot- clés correspondant sont à 1 r Les clients s'échangent les filtres r Les requêtes ne sont propagées que vers les clients qui ont le bon filtre

65 2: Application Layer65 Recherche par indexation r Les clients publient les fichiers qu'ils partagent sur les serveurs sur lesquels ils sont connectés r Les serveurs indexent les descriptions des fichiers r Les clients envoient des requêtes aux serveurs pour trouver les fichiers et les localiser

66 2: Application Layer66 Recherche par DHT r Distributed hash table: On associe à chaque document (ou mot-clé) un identificateur unique On associe à chaque client un identificateur unique de même taille On définit une métrique pour définir la distance entre les identificateurs On place un document sur les k clients qui ont l'identificateur le plus proche de celui du client exemple Chord: points sur un cercle la distance est la longueur de l'arc orienté. L'espace des clés est décomposé en segments. Si i et j sont des nœuds adjacents, i a toutes les clés comprises entre i et j notion d'overlay: chaque nœud maintient des liens vers d'autres nœuds, on obtient ainsi un overlay. Comment obtenir un routage efficace?

67 2: Application Layer67 Téléchargement r protocole ad-hoc (Edonkey, Bittorrent) ou http r swarming: téléchargement d'un fichier en téléchargeant différentes parties en parallèle depuis plusieurs clients r téléchargement multiple le fichier est décomposé en n blocs calcule du hachage de chaque bloc fichier est identifié par le hachage des blocs

68 2: Application Layer68 Succès… June 19, :00 Network Users eDonkey2K 4,379,883 FastTrack 2,482,130 Gnutella 1,598,329 Overnet 745,472 DirectConnect 294,255 MP2P 251,137 Filetopia 3,455

69 2: Application Layer69 Quelques réseaux r Napster (historique) Protocole: architecture centralisée recherche par indexation r Fasttrack clients: Kazaa Mldonkey architecture hybride recherche par indexation et diffusion entre ultrapeers identification faible des fichiers (MD5 sur 300ko puis hachage sur 32 bits) http (+ swarming)

70 2: Application Layer70 Quelques réseaux r Edonkey Clients: Edonkeys, Emule protocole faiblement centralisée recherche par indexation TCP recherche multi-serveurs par UDP téléchargement en duplex avec bitmaps, streaming et swarming (Bittorrent dans les dernières versions) système de crédits pour inciter au partage r Overnet/Kad télécharement Edonkey décentralisé DHT (Kademlia)

71 2: Application Layer71 Quelques réseaux r Gnutella architecture hybride Recherche par diffusion courte (TTL <8) avec filtres de Bloom Gnutella et Gnutella2 téléchargement par http avec possibilité de swarming r Bittorrent pas de découverte, un fichier.torrent contient les infos sur le fichier localisation centralisée pour chaque fichier (tracker) téléchargementavec bitmaps le client commence à forunir du contenu à ses voisins au bout d'un certain temps il bloque les voisins qui ne répondent pas et conserve les quatre meilleurs

72 2: Application Layer72 Quelques réseaux r Freenet complètement distribué publication par copie recherche par diffusion en profondeur protocole et contenu cryptés documents signés par signature digitale axé sur l'anonymat


Télécharger ppt "2: Application Layer1 Protocoles… r compléments php r FTP r Courrier: smtp pop imap… r DNS r P2P."

Présentations similaires


Annonces Google