Chapter 2 outline 2 1 principles of network

  • Slides: 33
Download presentation
Chapter 2: outline 2. 1 principles of network applications § app architectures § app

Chapter 2: outline 2. 1 principles of network applications § app architectures § app requirements 2. 6 P 2 P applications 2. 7 socket programming with UDP and TCP 2. 2 Web and HTTP 2. 3 FTP 2. 4 electronic mail § SMTP, POP 3, IMAP 2. 5 DNS Application Layer 2 -2

FTP: the file transfer protocol FTP user interface file transfer FTP client user at

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

FTP: separate control, data connections v v v FTP client contacts FTP server at

FTP: separate control, data connections v v v FTP client contacts FTP server at port 21, using TCP client authorized over control connection client browses remote directory, sends commands over control connection when server receives file transfer command, server opens 2 nd TCP data connection (for file) to client after transferring one file, server closes data connection TCP control connection, server port 21 FTP client v v v TCP data connection, server port 20 FTP server opens another TCP data connection to transfer another file control connection: “out of band” FTP server maintains “state”: current directory, earlier authentication Application Layer 2 -4

FTP commands, responses sample commands: v v v sent as ASCII text over control

FTP commands, responses sample commands: v v v 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 v v v status code and phrase (as in HTTP) 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file Application Layer 2 -5

Chapter 2: outline 2. 1 principles of network applications § app architectures § app

Chapter 2: outline 2. 1 principles of network applications § app architectures § app requirements 2. 6 P 2 P applications 2. 7 socket programming with UDP and TCP 2. 2 Web and HTTP 2. 3 FTP 2. 4 electronic mail § SMTP, POP 3, IMAP 2. 5 DNS Application Layer 2 -6

Electronic mail outgoing message queue Three major components: v v v user agents mail

Electronic mail outgoing message queue Three major components: v v v user agents mail servers simple mail transfer protocol: SMTP user agent mail server v v v a. k. a. “mail reader” composing, editing, reading mail messages e. g. , Outlook, Thunderbird, i. Phone mail client outgoing, incoming user agent SMTP mail server user agent SMTP User Agent v user mailbox SMTP mail server user agent Application Layer 2 -7

Electronic mail: mail servers: v v v mailbox contains incoming messages for user message

Electronic mail: mail servers: v v v mailbox contains incoming messages for user message queue of outgoing (to be sent) mail messages SMTP protocol between mail servers to send email messages § client: sending mail server § “server”: receiving mail server user agent outgoing message queue user mailbox mail server user agent SMTP mail server user agent Application Layer 2 -8

Electronic Mail: SMTP [RFC 2821] v v v uses TCP to reliably transfer email

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

Scenario: Alice sends message to Bob 1) Alice uses UA to compose message “to”

Scenario: Alice sends message to Bob 1) Alice uses UA to compose message “to” bob@someschool. edu 2) Alice’s UA sends message to her mail server; message placed in message queue 3) Alice’s mail server opens TCP connection with Bob’s mail server (acting as a client of SMTP) 1 user agent 2 mail server 3 Alice’s mail server 4) Alice’s mail server sends Alice’s message over the TCP connection 5) Bob’s mail server places the message in Bob’s mailbox 6) Bob invokes his user agent to read message user agent mail server 6 4 5 Bob’s mail server Application Layer 2 -10

Sample SMTP interaction S: C: S: C: C: C: S: 220 hamburger. edu HELO

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

Try SMTP interaction for yourself: v v v telnet servername 25 see 220 reply

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

SMTP: final words v v v SMTP uses persistent connections SMTP requires message (header

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

Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text

Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text message format: v header lines, e. g. , § To: § From: § Subject: header blank line body different from SMTP MAIL FROM, RCPT TO: commands! v Body: the “message” § ASCII characters only Application Layer 2 -14

Mail access protocols user agent SMTP mail access protocol user agent (e. g. ,

Mail access protocols user agent SMTP mail access protocol user agent (e. g. , POP, IMAP) sender’s mail server v v receiver’s mail server SMTP: delivery/storage to receiver’s server mail access protocol: retrieval from server § POP: Post Office Protocol [RFC 1939]: authorization, download § IMAP: Internet Mail Access Protocol [RFC 1730]: more features, including manipulation of stored msgs on server § HTTP: gmail, Hotmail, Yahoo! Mail, etc. Application Layer 2 -15

POP 3 protocol authorization phase v v client commands: § user: declare username §

POP 3 protocol authorization phase v v client commands: § user: declare username § pass: password server responses § +OK § -ERR transaction phase, client: v v list: list message numbers retr: retrieve message by number dele: delete quit S: C: S: +OK POP 3 server ready user bob +OK pass hungry +OK user successfully logged C: S: S: S: C: C: S: list 1 498 2 912. retr 1 <message 1 contents>. dele 1 retr 2 <message 1 contents>. dele 2 quit +OK POP 3 server signing off on Application Layer 2 -16

POP 3 (more) and IMAP more about POP 3 v v v previous example

POP 3 (more) and IMAP more about POP 3 v v v previous example uses POP 3 “download and delete” mode § Bob cannot re-read e -mail if he changes client POP 3 “download-andkeep”: copies of messages on different clients POP 3 is stateless across sessions IMAP v v v keeps all messages in one place: at server allows user to organize messages in folders keeps user state across sessions: § names of folders and mappings between message IDs and folder name Application Layer 2 -17

Chapter 2: outline 2. 1 principles of network applications § app architectures § app

Chapter 2: outline 2. 1 principles of network applications § app architectures § app requirements 2. 6 P 2 P applications 2. 7 socket programming with UDP and TCP 2. 2 Web and HTTP 2. 3 FTP 2. 4 electronic mail § SMTP, POP 3, IMAP 2. 5 DNS Application Layer 2 -18

DNS: domain name system people: many identifiers: § SSN, name, passport # Internet hosts,

DNS: domain name system people: many identifiers: § SSN, name, passport # Internet hosts, routers: § IP address (32 bit) used for addressing datagrams § “name”, e. g. , www. yahoo. com used by humans Q: how to map between IP address and name, and vice versa ? Domain Name System: v v distributed database implemented in hierarchy of many name servers application-layer protocol: hosts, name servers communicate to resolve names (address/name translation) § note: core Internet function, implemented as application-layer protocol § complexity at network’s “edge” Application Layer 2 -19

Hostname to IP address translation v v v Example: www. chalmers. se 129. 16.

Hostname to IP address translation v v v Example: www. chalmers. se 129. 16. 71. 10 File may be edited on the system Unix: /etc/hosts Windows: c: windowssystem 32driversetchosts Example of an entry manually entered in the file: “ 129. 16. 20. 245 fibula. ce. chalmers. se fibula” Does not scale Hard to change All hosts need one copy of the file Impossible on the Internet Alternative: DNS, a large distributed database DNS – Domain Name System 2: Application Layer 20

DNS: services, structure DNS services v v hostname to IP address translation host aliasing

DNS: services, structure DNS services v v hostname to IP address translation host aliasing why not centralize DNS? v v v § canonical, alias names v v mail server aliasing load distribution § replicated Web servers: many IP addresses correspond to one name v single point of failure traffic volume distant centralized database maintenance A: doesn’t scale! Application Layer 2 -21

DNS: a distributed, hierarchical database Top Level Domains Root DNS Servers … com DNS

DNS: a distributed, hierarchical database Top Level Domains Root DNS Servers … com DNS servers yahoo. com amazon. com DNS servers … org DNS servers pbs. org DNS servers edu DNS servers poly. edu umass. edu DNS servers client wants IP for www. amazon. com; 1 st approx: v v v client queries root server to find com DNS server client queries. com DNS server to get amazon. com DNS server client queries amazon. com DNS server to get IP address for www. amazon. com Application Layer 2 -22

DNS: Root name servers (2009) a Verisign, Dulles, VA c Cogent, Herndon, VA (also

DNS: Root name servers (2009) a Verisign, Dulles, VA c Cogent, Herndon, VA (also LA) d U Maryland College Park, MD g US Do. D Vienna, VA h ARL Aberdeen, MD j Verisign, k RIPE London i Netnod, Stockholm e NASA Mt View, CA f Internet Sys. consortium, Palo Alto, CA m WIDE Tokyo b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA 13 root name servers worldwide + replicas (http: //www. root-servers. org) 2: Application Layer 23

TLD, authoritative servers top-level domain (TLD) servers: § responsible for com, org, net, edu,

TLD, authoritative servers top-level domain (TLD) servers: § responsible for com, org, net, edu, aero, jobs, museums, and all top-level country domains, e. g. : uk, fr, ca, jp § Network Solutions maintains servers for. com TLD § Educause for. edu TLD authoritative DNS servers: § organization’s own DNS server(s), providing authoritative hostname to IP mappings for organization’s named hosts § can be maintained by organization or service provider Application Layer 2 -24

Local Cache-only DNS server v v does not strictly belong to hierarchy each ISP

Local Cache-only DNS server v v does not strictly belong to hierarchy each ISP (residential ISP, company, university) has one § also called “default name server” v when host makes DNS query, query is sent to its local DNS server § has local cache of recent name-to-address translation pairs (but may be out of date!) § acts as proxy, forwards query into hierarchy Application Layer 2 -25

DNS name resolution example v v host at cis. poly. edu wants IP address

DNS name resolution example v v host at cis. poly. edu wants IP address for gaia. cs. umass. edu Local name server § acts as proxy for clients § Sends queries to DNS hierarchy root DNS server 2 3 4 TLD DNS server 5 local DNS server dns. poly. edu 1 8 requesting host 7 6 authoritative DNS server dns. cs. umass. edu cis. poly. edu gaia. cs. umass. edu Application Layer 2 -26

DNS Queries and Answers root DNS server 2 iterated query: v v v contacted

DNS Queries and Answers root DNS server 2 iterated query: v v v contacted server replies with name of server to contact “I don’t know this name, but ask this server” root server always does this recursive query: v v 3 iterative answer 4 TLD DNS server 7 local DNS server dns. poly. edu 1 recursive answer 6 5 8 authoritative DNS server dns. cs. umass. edu puts burden of name requesting host resolution on contacted cis. poly. edu name server gaia. cs. umass. edu heavy load at upper levels (normal way as above, iterative + recursive) of hierarchy? Application Layer 2 -27

DNS: caching, updating records v once (any) name server learns mapping, it caches mapping

DNS: caching, updating records v once (any) name server learns mapping, it caches mapping § cache entries timeout (disappear) after some time (TTL) § TLD servers typically cached in local name servers • thus root name servers not often visited v cached entries may be out-of-date (best effort name-to-address translation!) § if name host changes IP address, may not be known Internet-wide until all TTLs expire v update/notify mechanisms proposed IETF standard § RFC 2136 Application Layer 2 -28

DNS records DNS: distributed db storing resource records (RR) RR format: (name, value, type,

DNS records DNS: distributed db storing resource records (RR) RR format: (name, value, type, ttl) type=A § name is hostname type=CNAME § name is alias name for some § value is IP address type=NS § name is domain (e. g. , foo. com) § value is hostname of authoritative name server for this domain § “canonical” (the real) name www. ibm. com is really servereast. backup 2. ibm. com § value is canonical name type=MX § value is name of mailserver associated with name Application Layer 2 -29

DNS protocol, messages v query and reply messages, both with same message format 2

DNS protocol, messages v query and reply messages, both with same message format 2 bytes msg header v v identification: 16 bit # for query, reply to query uses same # flags: § query or reply § recursion desired § recursion available § reply is authoritative identification flags # questions # answer RRs # authority RRs # additional RRs questions (variable # of questions) answers (variable # of RRs) authority (variable # of RRs) additional info (variable # of RRs) Application Layer 2 -30

DNS protocol, messages 2 bytes identification flags # questions # answer RRs # authority

DNS protocol, messages 2 bytes identification flags # questions # answer RRs # authority RRs # additional RRs name, type fields for a query questions (variable # of questions) RRs in response to query answers (variable # of RRs) records for authoritative servers authority (variable # of RRs) additional “helpful” info that may be used additional info (variable # of RRs) Application Layer 2 -31

Inserting records into DNS v v example: new startup “Network Utopia” register name networkuptopia.

Inserting records into DNS v v example: new startup “Network Utopia” register name networkuptopia. com at DNS registrar (e. g. , Network Solutions) § provide names, IP addresses of authoritative name server (primary and secondary) § registrar inserts two RRs into. com TLD server: (networkutopia. com, dns 1. networkutopia. com, NS) (dns 1. networkutopia. com, 212. 1, A) v Adding a new host/service to domain: § Add to authoritative name server • type A record for www. networkuptopia. com • type MX record for networkutopia. com (mail) Application Layer 2 -32

Attacking DNS DDo. S attacks v Bombard root servers with traffic § Not successful

Attacking DNS DDo. S attacks v Bombard root servers with traffic § Not successful to date § Traffic Filtering § Local DNS servers cache IPs of TLD servers, allowing root server bypass v Bombard TLD servers § Potentially more dangerous Redirect attacks v Man-in-middle § Intercept queries v DNS poisoning § Send bogus relies to DNS server, which caches Exploit DNS for DDo. S v Send queries with spoofed source address: target IP v Requires amplification Application Layer 2 -33

Summary v v application architectures § client-server specific protocols: § FTP § SMTP, POP,

Summary v v application architectures § client-server specific protocols: § FTP § SMTP, POP, IMAP § DNS Application Layer 2 -34