1CMSC 132: Object-Oriented Programming IINetworkingDepartment of Computer ScienceUniversity of Maryland, College Park2Advanced Programming ConceptsObjected-oriented support in Java forException handlingStreamsThreadsGraphics user interfaces (GUIs)NetworkingLook at networking as example of OO design3OverviewNetworkingBackgroundConcepts & termsJava’s objected-oriented viewJava’s networking API (Application Program Interface)Network applicationsThis lectureNext lecture4Networking BackgroundDefinitionSet of computers using common protocols to communicate over connecting mediaHistory1969 ARPANET1986 NSFnet1995 Internet5Networking ConceptsProtocolsNetwork modelInternet addressesPortsSocketsURLsConnection (TCP) vs. packet oriented (UDP)Reliability6ProtocolsDefinitionFormal description of formats and rulesUsed forMessage formatsSequence & order of actionsNeeded by computers to exchange informationVital for networking7Protocols – Email Delivery8Protocol – HTTP GET (Web Page)Client connects to server on port 80GET /~pugh/index.html HTTP/1.0<blank line>Server responses with HTTP headersHTTP/1.1 200 OKDate: Mon, 20 Feb 2006 03:47:44 GMTServer: ApacheLast-Modified: Wed, 15 Feb 2006 01:17:09 GMTETag: "9b2b1c-948-1222af40"Accept-Ranges: bytesContent-Length: 2376Connection: closeContent-Type: text/html; charset=ISO-8859-1Followed by blank line, then contents of response9Network ModelOpen Systems Interconnection (OSI) modelMultiple layers (7)One function each Each layer relies on previous layerDesigned to reduce complexity using abstraction10Network Model – LayersPhysical layerTransmit data as 0’s and 1’s over connectionData-link layerBetween two physically connected computersNetwork layerBetween any two computers connected to network Transport layerDeliver network data to applicationApplication layerBetween two applications using network11Network Model – VOIP ExampleVoice over IP (VOIP)PhysicalNetworkData-linkTransportApplication12Internet (IP) AddressUnique address for machine on internetGet from ISP when connecting to internetAllows network to find your machineFormat32-bit unsigned integer⇒⇒⇒⇒128.8.128.8Domain name⇒⇒⇒⇒cs.umd.eduName and address for local machine Localhost127.0.0.1Machine can have multiple IP addressesVirtual machines13Internet (IP) AddressProblemRunning out of 32-bit IP addressesCaused by initial address allocationStanford & MIT given more IP addresses than ChinaSwitching to 128-bit IP addresses in IPv61+ million addresses per square meter on Earth14IP Address – DNSDomain Name System (DNS)Protocol for translating domain names to IP addressesExample: cs.umd.edu→128.8.128.44Multiple DNS servers on internet DNS server may need to query other DNS serversedu DNS server queries umd.edu server to find cs.umd.edu15IP Address – DHCPDynamic Host Configuration Protocol (DHCP) Protocol used by networked computers to obtainUnique IP addressesDefault router, subnet maskIP addresses for DNS servers DHCP server on local networkUsed when computers first connect to networkSettings (leases) periodically refreshed16IP Address – NATNetwork Address Translation (NAT)Rewriting source / destination IP addresses As data passes through router Permits sharing of single IP address among multiple computersUsed in home networking (NAT box)17IP Address – NATNAT approachNAT box connects to both internet & private networkObtains single public IP address from ISPAssigns local IP address to computers on private network For data traveling to / from internetNAT box merges and translates IP addressesLocal IP addresses ↔ public IP addressFrom InternetAll private computers appear to have same IP address18PortsAbstraction to identify (refine) destinationProvide multiple destinations at single IP addressFormatUnsigned 16-bit integer (0 to 65,535)Ports 0 to 4096 often reserved & restrictedMany ports pre-assigned to important services21 ftp (file transfer)23 telnet (remote terminal)25 SMTP (email)80 http (web)…19SocketsApplication-level abstractionRepresents network connectionImplemented in softwareSupports both UDP and TCP protocolsHistoryIntroduced in Berkley UNIX in 1980sNetworking API20SocketsSocket is bound to port numberReceives data packetRelays to specific portportportport port portTCP or UDPport #, dataPacketapp app app app appTransport Layer21Uniform Resource Locators (URLs)Represent web resourcesWeb pagesArbitrary files…Exampleshttp://www.cs.umd.edu/index.htmlftp://www.cs.umd.edu/pub/doc/csd_policies.pdfhttps://login.yahoo.com/file://dir/my.txt22Uniform Resource Locators (URLs)Consists ofProtocolhttpftphttps (secure http)file…IP address (or domain name)Port (optional)http://www.cs.umd.edu:80/Reference to anchor (optional)23Internet ConnectionsTwo types of connections1.Connection-oriented (TCP)2.Packet-oriented (UDP)24Connection OrientedApproachReserve (single) communication channelSend stream of data along channelAlso called Circuit switchingStream orientedExampleTelephone call (current)25Connection OrientedProtocol26Connection OrientedAdvantagesSimpler schemeEasier to useHigher quality communicationLess likely to lose data (at network layer)27Packet OrientedApproachBreak message up into packets Transmit packets separately Assemble packets at destinationAlso calledPacket switchingConnectionlessExampleUS MailVOIP (Voice over IP)28Packet OrientedProtocol29Packet OrientedAdvantagesHigher utilization of channels Can share communication channelCan utilize multiple channels at onceCan reroute around failed channels30InternetNetwork layerInternet Protocol (IP)Transport layerUser Datagram Protocol (UDP)Transmission Control Protocol (TCP)31Internet32Internet Protocol (IP)Packet orientedPackets routed between computersUnreliable33User Datagram Protocol (UDP)Packet oriented Message split into datagramsSend datagrams as packets on network layerUnreliable but fastApplication must deal with lost packetsExamplesPingStreaming multimediaOnline games34Transmission Control Protocol (TCP)Connection orientedMessage split into datagramsSend datagrams as packets on network layerProvides illusion of reliable connectionExtra messages between sender / recipientResend packets if necessary Ensure all packets eventually arriveStore packets and process in orderProvides warning if packets are lost35Transmission Control Protocol (TCP)Reliable but slowerApplication can treat as reliable connectionDespite unreliability of underlying IP (network)Examplesftp (file transfer)telnet (remote
View Full Document