Application Layer: FTP & DNS

Transcription

Computer NetworksInstructor: Niklas CarlssonEmail: niklas.carlsson@liu.seNotes derived from “Computer Networking: A TopDown Approach”, by Jim Kurose and Keith Ross,Addison-Wesley.The slides are adapted and modified based on slides fromthe book’s companion Web site, as well as modified slidesby Anirban Mahanti and Carey Williamson.1

FTP2

File Transfer Protocol (FTP)TCP control connectionport 21 FTP client contacts FTP server at port 21, specifyingTCP as transport protocolClient obtains authorizationover control connectionClient browses remotedirectory by sendingcommands over controlconnection.When server receives acommand for a file transfer,the server opens a TCP dataconnection to clientAfter transferring one file,server closes connection.FTPclientTCP data connectionport 20FTPserver Server opens a second TCPdata connection to transferanother file. Control connection: “out ofband” FTP server maintains “state”:current directory, earlierauthentication3

FTP commands, responsesSample commands:Sample return codes sent as ASCII text over status code and phrase (ascontrol channel USER username PASS password LIST return list of file in current directory RETR filename retrieves STOR filename stores (gets) file(puts) file onto remotehostin HTTP)331 Username OK,password required125 data connectionalready open;transfer starting425 Can’t open dataconnection452 Error writingfile4

Mail5

Electronic Mailoutgoingmessage queueuser mailboxThree majorcomponents: user agents e.g., Eudora, Outlook,Pine, NetscapeMessenger mail servers Incoming, ver Simple Mail TransferProtocol: gentuseragent6

Electronic Mail: SMTP [RFC 2821] Client’s SMTP mail server establishes a TCPconnection to the recipients SMTP server usingPort 25 three phases in messg. transfer handshaking (greeting) transfer of messages closure command/response interaction commands: ASCII text response: status code and phrase messages must be in 7-bit ASCII7

Sample SMTP interactionS:C:S:C:S:C:S:C:S:C:C:C:S:C:S:220 hamburger.eduHELO crepes.fr250 Hello crepes.fr, pleased to meet youMAIL FROM: alice@crepes.fr 250 alice@crepes.fr. Sender okRCPT TO: bob@hamburger.edu 250 bob@hamburger.edu . Recipient okDATA354 Enter mail, end with "." on a line by itselfDo you like ketchup?How about pickles?.250 Message accepted for deliveryQUIT221 hamburger.edu closing connection8

Try SMTP interaction for yourself: telnet servername 25 see 220 reply from server enter HELO, MAIL FROM, RCPT TO, DATA, QUITcommandsabove lets you send email without using email client(reader)9

SMTP: final words SMTP uses persistentconnections SMTP requires message(header & body) to be in 7bit ASCII SMTP server usesCRLF.CRLF to determineend of message SMPT is a “chatty”protocolComparison with HTTP: HTTP: pull SMTP: push both have ASCIIcommand/responseinteraction, status codes HTTP: each objectencapsulated in its ownresponse msg SMTP: multiple objectssent in multipart msg10

Mail message formatSMTP: protocol forexchanging email msgsRFC 822: standard for textmessage format: header lines, e.g., To:From:Subject:headerblanklinebodydifferent from SMTPcommands! body the “message”, ASCIIcharacters only11

Message format: multimedia extensions MIME: multimedia mail extension, RFC 2045, 2056 additional lines in msg header declare MIME content typeMIME versionmethod usedto encode datamultimedia datatype, subtype,parameter declarationencoded dataFrom: alice@crepes.frTo: bob@hamburger.eduSubject: Picture of yummy crepe.MIME-Version: 1.0Content-Transfer-Encoding: base64Content-Type: image/jpegbase64 encoded data .base64 encoded data12

Mail access protocolsuseragentSMTPSMTPsender’s mailserveruseragentreceiver’s mailserver SMTP is a push protocol. How will a user access emails?13

Mail access protocolsuseragentSMTPSMTPsender’s mailserveraccessprotocoluseragentreceiver’s mailserver SMTP is a push protocol. How will a user access emails? Mail access protocol: retrieval from server POP: Post Office Protocol [RFC 1939] Users can’t create folders on mail serverIMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex) manipulation of stored msgs on serverHTTP: Gmail, Hotmail, Yahoo! Mail, etc.14

DNS15

DNS: Domain Name SystemInternet hosts:IP address (32 bit) - used for addressingdatagrams “name”, e.g., www.yahoo.com - used by humans DNS: provides translation between hostname and IP addressdistributed database implemented in hierarchyof many name servers distributed for scalability & reliability 16

Distributed, Hierarchical DatabaseRoot DNS Serverscom DNS serversca DNS serversTLDedu DNS serversServersusask.capoly.eduumass.eduyahoo.com amazon.com ucalgary.caDNS servers DNS servers DNS servers DNS servers DNS servers DNS servers Root servers and TLD servers typically do notcontain hostname to IP mappings; they containmappings for locating authoritative servers.17

DNS Services Hostname to IP address translation Host aliasing Canonical and alias names Mail server aliasing Load distribution Replicated Web servers: set of IP addressesfor one canonical name18

DNS Infrastructure2 Host at liu.se wantsIP address forgaia.cs.umass.edu Infrastructure: Client resolverLocal DNS serverAuthoritative DNSServerRoot DNS ServerTop-Level DomainDNS Server Transport protocol?root DNS server3TLD DNS server45local DNS serverdns.liu.se18requesting host76authoritative DNS edu19

DNS Infrastructure2 Host at liu.se wantsIP address forgaia.cs.umass.edu Infrastructure: Client resolverLocal DNS serverAuthoritative DNSServerRoot DNS ServerTop-Level DomainDNS Server Transport protocol? UDP (port 53)root DNS server3TLD DNS server45local DNS serverdns.liu.se18requesting host76authoritative DNS edu20

DNS: caching and updating records once (any) name server learns mapping, itcachesmapping cache entries timeout (disappear) after some timecalled the “Time To Live” (TTL) TLD servers typically cached in local name servers Thus root name servers not often visited21

DNS recordsDNS: distributed db storing resource records (RR)RR format: (name, Type A name is hostname value is IP addressvalue, type, ttl) Type CNAME name is alias name for some“canonical” (the real) namewww.ibm.com is really Type NSservereast.backup2.ibm.com name is domain (e.g. value is canonical namefoo.com) value is the name of the Type MXauthoritative name value is name of mail serverserver for this domainassociated with name22

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

24

Socket programming25

Sockets (recall) process sends/receivesmessages to/from itssockethost orserverhost orservercontrolled byapp developerprocessprocesssocketsocketTCP withbuffers,variablesInternetcontrolledby OSTCP withbuffers,variables26

Socket programmingGoal: learn how to build client/server application thatcommunicate using socketsSocket API explicitly created, used,released by apps client/server paradigm two types of transportservice via socket API: unreliable datagram reliable, byte streamorientedsocketa host-local,application-created,OS-controlled interface(a “door”) into whichapplication process canboth send andreceive messages to/fromanother applicationprocess27

Socket-programming using TCPSocket: a door between application process and endend-transport protocol (UDP or TCP)TCP service: reliable transfer of bytes from oneprocess to anothercontrolled byapplicationdevelopercontrolled byoperatingsystemprocessprocesssocketTCP withbuffers,variablessocketTCP withbuffers,variableshost orserverinternetcontrolled byapplicationdevelopercontrolled byoperatingsystemhost orserver28

Client/server socket interaction: TCPServer (running on hostid)Clientcreate socket,port x, forincoming request:welcomeSocket ServerSocket()TCPwait for incomingconnection request connectionconnectionSocket welcomeSocket.accept()read request fromconnectionSocketwrite reply toconnectionSocketcloseconnectionSocketsetupcreate socket,connect to hostid, port xclientSocket Socket()send request usingclientSocketread reply fromclientSocketcloseclientSocket29

Stream characters that flow intoor out of a process. input stream is attached tosome input source for theprocess, e.g., keyboard orsocket. output stream is attachedto an output source, e.g.,monitor or socket.inputstreamoutToServer stream is a sequence entSocketsocketto networkTCPsocketfrom network30

Socket programming with UDPUDP: no “connection” betweenclient and server no handshaking sender explicitly attaches IPaddress and port ofdestination to each packet server must extract IPaddress, port of sender fromreceived packetapplication viewpoint:UDP provides unreliable transferof groups of bytes (“datagrams”)between client and serverUDP: transmitted data may bereceived out of order, or lost31

Client/server socket interaction: UDPServer (running on hostid)create socket,port x.serverSocket DatagramSocket()read datagram fromserverSocketwrite reply toserverSocketspecifyingclient address,port numberClientcreate socket,clientSocket DatagramSocket()Create datagram with server IP andport x; send datagram viaclientSocketread datagram fromclientSocketcloseclientSocket32

Example: client oardInput: receivesprocesspacket (recallthatTCP received“byte stream”)UDPpacketreceivePacketpacket (recallthat TCP sent “bytestream”)sendPacketOutput: sendsUDPpacketclientUDPclientSocketsocketto networkUDPsocketfrom network33

34

Chapter 2: Summary application architectures client-server P2P hybrid application servicerequirements: reliability, bandwidth,delayspecific protocols: HTTPFTPSMTP, POP, IMAPDNSP2P: BitTorrent, Skypesocket programming Internet transportservice model connection-oriented,reliable: TCPunreliable, datagrams: UDP35

Chapter 2: Summarysome important lessons about protocols typical request/replymessage exchange: client requests info orserviceserver responds withdata, status code message formats: headers: fields givinginfo about data data: info beingcommunicatedImportant themes: control vs. data msgs in-band, out-of-bandcentralized vs.decentralizedstateless vs. statefulreliable vs. unreliablemsg transfer“complexity at networkedge”36

37

More slides 38

DNS: Root name servers contacted by local name server that cannotresolve name directly root name server:contacts authoritative name server if name mappingis not known gets mapping returns mapping to local name server 39

TLD and Authoritative Servers Top-level domain (TLD) servers: responsiblefor .com, .org, .net, .edu, .gov, .mil, and all toplevel country domains (e.g., .uk, .fr, .ca, .jp)Network Solutions maintains servers for .com TLD Educause for .edu TLD Authoritative DNS servers: organization’sDNS servers, providing authoritativehostname to IP mappings for organization’sservers (e.g., Web and mail). Can be maintained by organization or serviceprovider40

Local Name Server Each ISP (residential ISP, company,university) has one. Also called “default name server” When a host makes a DNS query, query issent to its local DNS server Actsas a proxy, forwards query into hierarchy. Reduces lookup latency for commonly searchedhostnames41

Recursive queriesroot DNS serverrecursive query: puts burden of nameresolution oncontacted nameserver heavy load?iterated query: contacted server2376TLD DNS serverlocal DNS serverdns.liu.se1548replies with name ofserver to contact “I don’t know thisrequesting hostname, but ask this example.liu.seserver”authoritative DNS serverdns.cs.umass.edugaia.cs.umass.edu42

DNS protocol, messagesDNS protocol : query and reply messages, both withsame message formatmsg header identification: 16 bit #for query, reply to queryuses same # flags: query or reply recursion desired recursion available reply is authoritative43

DNS protocol, messagesName, type fieldsfor a queryRRs in responseto queryrecords forauthoritative serversadditional “helpful”info that may be usedDNS messages are carried using UDP on port 5344

SMTP requires message (header & body) to be in 7-bit ASCII SMTP server uses CRLF.CRLFto determine end of message SMPT is a "chatty" protocol Comparison with HTTP: HTTP: pull SMTP: push both have ASCII command/response interaction, status codes HTTP: each object encapsulated in its own response msg SMTP: multiple objects