05 - Web-технологии. Сетевые протоколы

  • Published on
    13-Apr-2017

  • View
    40

  • Download
    4

Embed Size (px)

Transcript

  • HTTP ?

  • HTTP ?

    URL

    DNS, ip

    TCP web-

    https, TLS TCP

    HTTP , , HTTP

    ( HTTP/1.0)

    ...

    2

  • 3

  • DNS

  • Domain Name System

    DNS - ,

    , IP

    ,

    5

  • 6

  • DNS .

    .

    .

    .

    7

  • 8

  • 9

  • DNS ?

    A - IPv4 ()

    AAAA - IPv6 ()

    NS - (a) DNS

    MX - ()

    10

  • TCP

  • TCP ?

    TCP - ,

    . , TCP ,

    / .

    -

    12

  • TCP

    TCP -

    . TCP

    .

    - , 65535. 1024

    .

    13

  • TCP

    20,21 - FTP

    22 - SSH

    25 - SMTP

    80 - HTTP

    443 - HTTPS

    14

  • TCP

    15

  • TCP

    import socket req = "Hello tcp!" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', 1234)) s.send(req) rsp = s.recv(1024) s.close()

    16

  • TCP

    import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('127.0.0.1', 1234)) s.listen(10) while True: conn, addr = s.accept() while True: data = conn.recv(1024) if not data: break conn.send(data) conn.close()

    17

  • ?

    def myreceive(sock, msglen): msg = '' while len(msg) < msglen: chunk = sock.recv(msglen-len(msg)) if chunk == '': raise RuntimeError("broken") msg = msg + chunk return msg

    18

  • ?

    def mysend(sock, msg): totalsent = 0 while totalsent < len(msg): sent = sock.send(msg[totalsent:]) if sent == 0: raise RuntimeError("broken") totalsent = totalsent + sent

    19

  • TLS

  • TLS - Transport Layer Security

    TLS ( SSL) - ,

    Internet.

    ( )

    21

  • TLS

    22

  • ClientHello -

    ServerHello -

    Certificate -

    .

    ClientKeyExchange -

    ( )

    Finished -

    23

  • TCP TLS

    . 1 RTT TCP 1-2 RTT TLS

    .

    RTT Round Trip Time - ,

    IP .

    24

Recommended

View more >