Vous êtes sur la page 1sur 27

Introduction aux rseaux

Prsentation de TCP/IP et de la programmation


Julien OLIVAIN <julien.olivain@lsv.ens-cachan.fr> LSV - ENS de Cachan

Plan
Introduction gnrale. Protocoles de communication. Organisation en couches. Cas pratique d et .
  "! " %& #$         

quipements et composants dun rseau. Programmation systme rseau: - Interface de programmation . - Modles client-serveur. - Ralisation dune messagerie temps-rel.
 (  '

Protocoles de communication rseau


Un protocole est un ensemble de rgles et de codes conus pour lchange de donnes entre deux quipements relis par une ligne de communication. ( langage). Les protocoles fournissent gnralement des services particuliers, en plus de lchange de donnes: Recherche dun chemin vers un rseau (routage) Recherche dune adresse Gestion de ot de donnes Vrication dintgrit Correction derreurs Scurit (chiffrement) ...
 1 0  

Couches ISO/OSI
International Standard Organizations Open System Interconnect
7 Application 6 Presentation 5 Session 4 Transport 3 Network 2 Data Link 1 Physical
Application protocols: ftp, telnet, ssh, htt, smtp, etc... Data translation: Bit order, Byte order, Character set, etc... Provide control of session between hosts : establishment, transfer, release (session identifier, socket) Provide transmission control service, error recovery and segmentation: TCP, SX, NetBEUI, etc... (Data unit: segment) Send data through multiple systems between two hosts: IP, IPX, DDP, etc... (Data unit: Packet) Lowlevel communication protocol: Ethernet, TokenRing, FDDI, Kermit, ZModem, etc... (Data unit: Frame) Twisted Pair Cables, Fiber Optic, Radio Frequency Links, etc... (Data unit: Signals, modulations, etc...)

Cas pratique d
     

et

45

est un protocole couche lien (2), ), de couche rseau (3), ), de couche (4).
8 " & & & '& 8  " &  & & !  &' %@ &   8

IP (



TCP (

9



Encapsulation des protocoles TCP/IP


user data

application header

user data

TCP header

application data

TCP segment IP header TCP header application data

IP datagram Ethernet header IP header TCP header application data Ethernet trailer
 B

Ethernet frame

Hirarchie des protocoles


HTTP SMTP FTP SSH ... TCP UDP DNS SNMP TFTP NFS ... Application layer

Transport layer

ICMP

IP

IGMP

Network layer

ARP

Data Link Media

RARP

Link layer

Physical layer

En-tte
0

45

3
15 16

31

48 bits destination MAC address 48 bits source MAC address

16 bits type

data

En-tte IP
0 4 bits version 4 bits hdr len 8 bits type of service (TOS) 3 bits flags 15 16 16 bits total length (bytes)
standard IP header = 20 bytes

31

16 bits identification 8 bits time to live 8 bits protocol

13bits fragment offset 16 bits checksum

32 bits source ip address 32 bits destination ip address options (if any)

data

En-tte UDP
0 16 bits source port 16 bits length 15 16 16 bits destination port 16 bits checksum 31

data

F

En-tte TCP
0 16 bits source port 32 bits sequence number 32 bits acknowledgement number 4 bits hdr len URG ACK SYN 6 bits reserved 16 bits window size 16 bits urgent pointer options (if any) PSH RST FIN 15 16 16 bits destination port
standard TCP header = 20 bytes

31

16 bits checksum

data



Protocole TCP (couche 4)


TCP connection establishment Client Server
socket() bind() listen() accept() (accept blocks)

socket() connect() (connect blocks)

SYN j SYN k, ACK j+ 1

(connect returns)

ACK k+1
(accept returns)

ACK j+1 ACK k+1

)

Cas pratique d


et

45

Exemple dune connexion HTTP. Exemple dun envoi de mail.

1

quipements composant un rseau

Internet Router Switch Hub

Host A B C

Principaux quipements

2

Conguration rseau minimale


De quels paramtres a-t-on besoin pour faire fonctionner le rseau ? Adresse IP (192.168.0.123) Masque de sous-rseau (255.255.255.0) Passerelle par dfaut (192.168.0.1) Nom de machine (myhost) Serveur de noms (DNS 192.168.0.2)
    

A

Exemple complet dune connexion


www.google.com 8 12

Internet
13 11 7 5 9

14

10

6 2

host2
1 3

host1

DNS

B

Outils de diagnostic rseau


Outil de conguration des interfaces rseau. Outil de conguration du cache dadresses IP/ARP. Afche le nom de la machine locale. Test de connectivit (message ICMP ECHO/REPLY). Outil de requte dun serveur de noms (DNS). (obsolte). Outils de requte dun serveur de noms (DNS). Outil de diagnostic des connexions rseau courantes. Afche la route utilise entre la machine locale et une destination. Connexion dun terminal via un rseau. scuris.
p qih rr PIGH QY `R W ` QY V` I U Vb eQ Y R Y X W` H ` b RPc b ` b ` U` b `Y ` GS gf X Q Q eWPd R Y c S GR X aU RQ b VWU TSG H

Transfert de chiers.

Programmation systme et
 (  %& '

v st u 4 s 3

Une (en: prise, embout) reprsente un point dattache vers un canal de communication rseaux. permet de faire abstraction des Linterface des protocoles de communication bas-niveau qui seront grs automatiquement par le systme dexploitation.
 (  %& ' %

D

Y Y ` g f d GR ` I RQ Y U QS d c Y I Q V Ug a V Y I Q Rb Ug V  E Rb c ` g d c V Ug R g gd e VI ` ` ee ` Qg G H Y b `I eQ ` G R Y Qg G ee H Q V V eQ ` I Q Rb ` d c g Ug c Rb V Vb V Y Ug e Ug Y I Q Ug Q Y Ug g dg g Y G b `I dg e gH Y Y VI ` ` Y I ` V Ie ` GR I Q Rb Ug c Rb ` g I RQ Y VI ` ` V Y ` GR W ` b W` Q I` Q c ` d c Y I Q ` dgH aQ GR GR U GR Y GR ` dgH gH g y `g GR qhg d GR ` Y I GR Q ` y xy y x ` GR GR ` `w b y G GR ` GR GR Y

wi GR `

Y G b `

Appels systme pour les

st u 4 s 3 v

yo i m ` `I a Y S RQ S VUS c V a Y S Y I Q ` US Y c H V aQ Rb c GR Rb ` d c H Y US g X ` V aQ b ` Rb ` c H US Y GR c G V Ug H ee GR e dg Y Q Qg G H Y b ` Rb ` c H ` Y US c H GR GR c G ee Y I VI ` Qg G H Y a Y S V a Y S g X gH Y ` Y Y GR ` e ` ` Y I RQ Y Y ` Y I V` eI ` V Q Ug dg e ` GR GR GR GR VI ` Y RQ Y Y ` VI ` ` Y I RQ ` Qg G a Y S ` Q Y I Q Rb ` c Rb Q ` d c Y ` I GR m x xl Y I RQ ` Qg G a Y S Y ` GR ny d o

` lw lw d d `

GR ny `w ny GR

` `w GR

GR ` `w GR y gH Y b kbI W b Y VI ` e ` Y ` R Y ` gH b ` V bg UH g Y gH Y b j V ` Y US c H US GR ` c H Y GR aG b eQ ` ` Y ` G b gH Y G b ` c Rb Y G b ` c Rb ` aG b U c ` ` gH GR `w i GR

Appels systme avances

GR GR

ag

pour
st u

les

 )F

4 s

Modles de serveurs
Communication simple:
Les deux programmes communiquent et terminent.
   

Serveur itratif:
Le serveur attend, traite la requte dun client lorsquil se connecte, puis recommence.

Serveur concurrentiel:
Le serveur attend, cre un nouveau processus pour traiter les requtes des clients sparment et en parallle.

Serveur multiplex:
Le serveur attend, et traite les clients les uns aprs les autres.

)

Exemple de programme rseau client


Recherche et conguration de ladresse du serveur connecter. Cration dune . . Connexion de la
 (  %& '  (  %& '    

...utilisation de la connexion...

))

j V S V` Rb a Y S U` Q VU S {p V V Ug g q by G W ` b V Ug s z V Ug X s z X Rb S ` V V Y Ug g Y G b QH c X X g by X g X v s z VUS vp q c Y RQ by X V b Y ` X Ug g aU b X V u c s GR R Rb ` tV s Y GR Ug a ` `u G ` e xY dg ` f b aU QY d VQ V X QY Q X Q W H Y I ` VUI S I VU VUS pq r X ` GR Y b Y |} Y s V` ~ eI ` Y I Q dg s Ug V w Y b Y g x ` Y g I w s GR s GR ` ` Y ` x b S GR I U G x R xY xY W e e RQ ` Yg a u ub abI VI ` VI ` f V V X Yg Y a GR ` Y Y Y

GR

Exemple de programme rseau client

 )1

Exemple de programme rseau serveur


Cration dune . une adresse dcoute.
 (  %& ' %& 

Association de la

Activation de lcoute. Attente de lacceptation dune connexion. ...utilisation de la connexion...

 (  '

)2

V bg UI x I f cY b QH I Ug V s b GR wI c c G Rb G QH Y ` GR Y Y w Ug VQ Y V c gG dg W ~ QH b Q Y Y I RQ s G I Ug c gG GR Y ` GR X |} Y ` ~ u Rb GR s tV c tV s G b QH ee H Vb wI Ug c gG GR V H Ug dg I Q Y ` V ` c G RQ R I b RQ Y I Q b ` d f b ` ` G I Q d f Rb Y ` `u G c Ug Ug G dg dg Y VQ aU GY GR I c d Y b ` |} VI ` e s Q Q W b `I f f VUI S I VU VUS pq r X ` UI u TYc Q W H Y I I GR Y Y w TYc s Rb Rb Y I s GR s GR ` ` ` Y cY Rb b c GR c d U ` xY xY G Y e e Q `I ` a u c GY u ab gGR GR GR f e VI ` VI ` Y c TYc I GR GR ` x Y x ee H H Y Y VI ` e Vb Y a Y Y Y Y

GR

Exemple de programme rseau serveur

 )A

Bibliographie
RFC790 (UDP) User Datagram Protocol RFC791 (IP) Internet Protocol RFC792 (ICMP) Internet Control Message Protocol RFC793 (TCP) Transport Control Protocol W.R. Stevens, W.R. Stevens, A. Tanenbaum, G. Pujolle,
 % "! $ 88 ( & 8 " #$ %  9 8    " &   % % 9  % 9  &  & 9        

)B

Introduction aux rseaux


Prsentation de TCP/IP et de la programmation
Julien OLIVAIN <julien.olivain@lsv.ens-cachan.fr> LSV - ENS de Cachan

)C

Vous aimerez peut-être aussi