15-441: Computer NetworkingLecture OverviewApplications and Application-Layer ProtocolsClient-Server ParadigmFtp: The File Transfer ProtocolFtp: Separate Control, Data ConnectionsFtp Commands, ResponsesWhat Transport Service Does an Application Need?Transport Service Requirements of Common AppsSlide 10Server and ClientUser Datagram Protocol(UDP): An AnalogyTransmission Control Protocol (TCP): An AnalogyNetwork Addressing AnalogyConcept of Port NumbersNames and AddressesInternet Addressing Data StructureByte OrderingByte Ordering FunctionsSlide 20What is a Socket?PowerPoint PresentationSlide 23Slide 24Socket I/O: listen()Socket I/O: accept()Socket I/O: accept() continued...Socket I/O: read()TCP ClientDealing with IP AddressesTranslating Names to AddressesSocket I/O: connect()Socket I/O: write()Review: TCP Client-Server InteractionUDP Server ExampleSocket I/O: socket()Socket I/O: bind()Socket I/O: recvfrom()Socket I/O: recvfrom() continued...UDP Client ExampleSocket I/O: sendto()Review: UDP Client-Server InteractionThe UDP ServerUDP Server: Servicing Two PortsSocket I/O: select()Slide 46Slide 47Slide 48Slide 49A Few Programming Notes: Representing PacketsA Few Programming Notes: Building a Packet in a BufferSocket Programming References15-441: Computer NetworkingLecture 3: Application Layer and Socket ProgrammingLecture 3: 9-4-01 2Lecture Overview•Application layer•Client-server•Application requirements•Background•TCP vs. UDP•Byte ordering •Socket I/O•TCP/UDP server and client•I/O multiplexingLecture 3: 9-4-01 3Applications and Application-Layer Protocols•Application: communicating, distributed processes•Running in network hosts in “user space”•Exchange messages to implement app•e.g., email, file transfer, the Web•Application-layer protocols•One “piece” of an app•Define messages exchanged by apps and actions taken•User services provided by lower layer protocolsapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalLecture 3: 9-4-01 4Client-Server ParadigmTypical network app has two pieces: client and serverapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalClient:•Initiates contact with server (“speaks first”)•Typically requests service from server, •For Web, client is implemented in browser; for e-mail, in mail readerServer:•Provides requested service to client•e.g., Web server sends requested Web page, mail server delivers e-mailrequestreplyLecture 3: 9-4-01 5Ftp: The File Transfer Protocol•Transfer file to/from remote host•Client/server model•Client: side that initiates transfer (either to/from remote)•Server: remote host•ftp: RFC 959•ftp server: port 21file transferFTPserverFTPuserinterfaceFTPclientlocal filesystemremote filesystemuser at hostLecture 3: 9-4-01 6Ftp: Separate Control, Data Connections•Ftp client contacts ftp server at port 21, specifying TCP as transport protocol•Two parallel TCP connections opened:•Control: exchange commands, responses between client, server.“out of band control”•Data: file data to/from server•Ftp server maintains “state”: current directory, earlier authenticationFTPclientFTPserverTCP control connectionport 21TCP data connectionport 20Lecture 3: 9-4-01 7Ftp Commands, ResponsesSample Commands:•sent as ASCII text over control channel•USER username•PASS password•LIST return list of files in current directory•RETR filename retrieves (gets) file•STOR filename stores (puts) file onto remote hostSample Return Codes•status code and phrase•331 Username OK, password required•125 data connection already open; transfer starting•425 Can’t open data connection•452 Error writing fileLecture 3: 9-4-01 8What Transport Service Does an Application Need?Data loss•Some apps (e.g., audio) can tolerate some loss•Other apps (e.g., file transfer, telnet) require 100% reliable data transfer Timing•Some apps (e.g., Internet telephony, interactive games) require low delay to be “effective”Bandwidth•Some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”•Other apps (“elastic apps”) make use of whatever bandwidth they getLecture 3: 9-4-01 9Transport Service Requirements of Common Appsno lossno lossno lossloss-tolerantloss-tolerantloss-tolerantno losselasticelasticelasticaudio: 5Kb-1Mbvideo:10Kb-5Mbsame as above few Kbpselasticnononoyes, 100’s msecyes, few secsyes, 100’s msecyes and nofile transfere-mailweb documentsreal-time audio/videostored audio/videointeractive gamesfinancial appsApplicationData lossBandwidthTime SensitiveLecture 3: 9-4-01 10Lecture Overview•Application layer•Client-server•Application requirements•Background•TCP vs. UDP•Byte ordering •Socket I/O•TCP/UDP server and client•I/O multiplexingLecture 3: 9-4-01 11Server and ClientTCP/UDPIPEthernet AdapterServerTCP/UDPIPEthernet AdapterClientsServer and Client exchange messages over the network through a common Socket APISocket APIhardwarekernel spaceuser spaceportsLecture 3: 9-4-01 12User Datagram Protocol(UDP): An AnalogyPostal Mail•Single mailbox to receive messages•Unreliable •Not necessarily in-order delivery•Each letter is independent•Must address each replyExample UDP applicationsMultimedia, voice over IPUDP•Single socket to receive messages•No guarantee of delivery•Not necessarily in-order delivery•Datagram – independent packets•Must address each packetPostal Mail•Single mailbox to receive letters•Unreliable •Not necessarily in-order delivery•Letters sent independently •Must address each replyLecture 3: 9-4-01 13Transmission Control Protocol (TCP): An Analogy TCP•Reliable – guarantee delivery•Byte stream – in-order delivery•Connection-oriented – single socket per connection•Setup connection followed by data transferTelephone Call•Guaranteed delivery•In-order delivery•Connection-oriented •Setup connection followed by conversationExample TCP applicationsWeb, Email, TelnetLecture 3: 9-4-01 14Network Addressing Analogy412-268-8000 ext.123Central NumberApplications/ServersWebPort 80MailPort 25ExchangeArea Code412-268-8000 ext.654IP AddressNetwork No.Host NumberTelephone No15-441 Students ClientsProfessors at CMUNetwork ProgrammingTelephone CallPort No.ExtensionLecture 3: 9-4-01 15Concept of Port Numbers•Port numbers are used to identify “entities”
View Full Document