CSE 4213: Computer Networks II Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/4213 Some slides are adapted from Jim Kurose’s slides. 11/19/2018 COSC 4213 - S.Datta
Administrivia Course webpage: http://www.cs.yorku.ca/course/4213 Lectures: Tue-Thu 2:30-4:00 pm (VH 3005) Exams: midterm (25%), final (40%) Homework (35%): divided between lab assignments (20%) and project (15%). Slides: should be available the morning of the class Office hours: Tuesday 4-6 pm, Th 12 noon -2 pm or by appointment at CSB3043 Textbook: Computer Networking: A Top Down Approach Featuring the Internet, 4th edition. Jim Kurose, Keith Ross; Addison-Wesley, 2008. ISBN: 0-321-49770-8 11/19/2018 COSC 4213 - S.Datta
Administrivia – contd. Cheating will not be tolerated. Visit the webpage for more details on policies etc. Be careful not to misuse packet sniffing software. I would like to have a 2-hour midterm. Your cooperation is greatly appreciated. TA: none. There will be some non-credit homework to help you study. I may have an extra-credit assignment. This will be announced beforehand. 11/19/2018 COSC 4213 - S.Datta
Course objectives Understand the full TCP/IP architecture. Become familiar with “advanced topics” - P2P systems, multimedia communication (including VoIP), network security, wireless sensor networks. Learn about active research areas. 11/19/2018 COSC 4213 - S.Datta
Major differences with 3213 More algorithmic (less math!) More hands-on – TCP/IP programming. 11/19/2018 COSC 4213 - S.Datta
Internet structure: network of networks roughly hierarchical at center: “tier-1” ISPs (e.g., UUNet, BBN/Genuity, Sprint, AT&T), national/international coverage treat each other as equals NAP Tier-1 providers also interconnect at public network access points (NAPs) Tier 1 ISP Tier-1 providers interconnect (peer) privately Tier 1 ISP Tier 1 ISP 11/19/2018 COSC 4213 - S.Datta
Tier-1 ISP: e.g., Sprint Sprint US backbone network 11/19/2018 COSC 4213 - S.Datta
Internet structure: network of networks “Tier-2” ISPs: smaller (often regional) ISPs Connect to one or more tier-1 ISPs, possibly other tier-2 ISPs Tier-2 ISPs also peer privately with each other, interconnect at NAP Tier-2 ISP Tier-2 ISP pays tier-1 ISP for connectivity to rest of Internet tier-2 ISP is customer of tier-1 provider Tier 1 ISP NAP Tier 1 ISP Tier 1 ISP 11/19/2018 COSC 4213 - S.Datta
Internet structure: network of networks “Tier-3” ISPs and local ISPs last hop (“access”) network (closest to end systems) local ISP Tier 3 Local and tier- 3 ISPs are customers of higher tier ISPs connecting them to rest of Internet Tier-2 ISP Tier 1 ISP NAP Tier 1 ISP Tier 1 ISP 11/19/2018 COSC 4213 - S.Datta
Internet structure: network of networks a packet passes through many networks! local ISP Tier 3 ISP local ISP local ISP local ISP Tier-2 ISP Tier 1 ISP NAP Tier 1 ISP Tier 1 ISP local ISP local ISP local ISP local ISP 11/19/2018 COSC 4213 - S.Datta
A closer look at network structure: network edge: applications and hosts access networks, physical media: wired, wireless communication links network core: interconnected routers network of networks 11/19/2018 COSC 4213 - S.Datta
The network edge: end systems (hosts): client/server model run application programs e.g. Web, email at “edge of network” peer-peer client/server client/server model client host requests, receives service from always-on server e.g. Web browser/server; email client/server peer-peer model: minimal (or no) use of dedicated servers e.g. Skype, BitTorrent 11/19/2018 COSC 4213 - S.Datta
Network edge: reliable data transfer service Goal: data transfer between end systems handshaking: setup (prepare for) data transfer ahead of time Hello, hello back human protocol set up “state” in two communicating hosts TCP - Transmission Control Protocol Internet’s reliable data transfer service TCP service [RFC 793] reliable, in-order byte-stream data transfer loss: acknowledgements and retransmissions flow control: sender won’t overwhelm receiver congestion control: senders “slow down sending rate” when network congested 11/19/2018 COSC 4213 - S.Datta
Network edge: best effort (unreliable) data transfer service Goal: data transfer between end systems same as before! UDP - User Datagram Protocol [RFC 768]: connectionless unreliable data transfer no flow control no congestion control App’s using TCP: HTTP (Web), FTP (file transfer), Telnet (remote login), SMTP (email) App’s using UDP: streaming media, teleconferencing, DNS, Internet telephony 11/19/2018 COSC 4213 - S.Datta
Internet Design Philosophy Simple core, complex edge Best effort service Great support for heterogeneity Dynamic by design One network for many, many purposes Designed primarily for non-real-time text traffic with no QoS requirements other than reliable delivery. Q: Does this explain why the internet does not work well for many applications? 11/19/2018 COSC 4213 - S.Datta
Pros and cons of layering: Protocol “Layers” Networks are complex! many “pieces”: hosts routers links of various media applications protocols hardware, software Pros and cons of layering: explicit structure allows identification, relationship of complex system’s pieces modularization eases maintenance, updating of system change of implementation of layer’s service transparent to rest of system Inefficient? 11/19/2018 COSC 4213 - S.Datta
Internet protocol “stack” application: supporting network applications FTP, SMTP, STTP transport: host-host data transfer TCP, UDP network: routing of datagrams from source to destination IP, routing protocols link: data transfer between neighboring network elements PPP, Ethernet physical: bits “on the wire” application transport network link physical 11/19/2018 COSC 4213 - S.Datta
Encapsulation source destination application transport network link message M application transport network link physical segment Ht M datagram Ht Hn M frame Ht Hn Hl M link physical Ht Hn Hl M Ht Hn Hl M switch destination network link physical Ht Hn M Ht Hn M application transport network link physical Ht Hn Hl M M Ht Hn Hl M Ht M Ht Hn M router Ht Hn Hl M 11/19/2018 COSC 4213 - S.Datta
1961-1972: Early packet-switching principles Internet History 1961-1972: Early packet-switching principles 1972: ARPAnet demonstrated publicly NCP (Network Control Protocol) first host-host protocol first e-mail program ARPAnet has 15 nodes 1961: Kleinrock - queueing theory shows effectiveness of packet-switching 1964: Baran - packet-switching in military nets 1967: ARPAnet conceived by Advanced Research Projects Agency 1969: first ARPAnet node operational 11/19/2018 COSC 4213 - S.Datta
1972-1980: Internetworking, new and proprietary nets Internet History 1972-1980: Internetworking, new and proprietary nets 1970: ALOHAnet satellite network in Hawaii 1973: Metcalfe’s PhD thesis proposes Ethernet 1974: Cerf and Kahn - architecture for interconnecting networks late70’s: proprietary architectures: DECnet, SNA, XNA late 70’s: switching fixed length packets (ATM precursor) 1979: ARPAnet has 200 nodes Cerf and Kahn’s internetworking principles: minimalism, autonomy - no internal changes required to interconnect networks best effort service model stateless routers decentralized control define today’s Internet architecture 11/19/2018 COSC 4213 - S.Datta
1990, 2000’s: commercialization, the Web, new apps Internet History 1990, 2000’s: commercialization, the Web, new apps Late 1990’s – 2000’s: more killer apps: instant messaging, P2P file sharing network security to forefront est. 50 million host, 100 million+ users backbone links running at Gbps Early 1990’s: ARPAnet decommissioned 1991: NSF lifts restrictions on commercial use of NSFnet (decommissioned, 1995) early 1990s: Web hypertext [Bush 1945, Nelson 1960’s] HTML, HTTP: Berners-Lee 1994: Mosaic, later Netscape late 1990’s: commercialization of the Web 11/19/2018 COSC 4213 - S.Datta
Next: the programming API Reading: Ch 2.7-2.8. TCP vs UDP 11/19/2018 COSC 4213 - S.Datta
Socket programming Socket API socket Goal: learn how to build client/server application that communicate using sockets Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm two types of transport service via socket API: unreliable datagram reliable, byte stream-oriented a host-local, application-created, OS-controlled interface (a “door”) into which application process can both send and receive messages to/from another application process socket 11/19/2018 COSC 4213 - S.Datta
Socket-programming using TCP Socket: a door between application process and end-end-transport protocol (UCP or TCP) TCP service: reliable transfer of bytes from one process to another controlled by application developer controlled by application developer process TCP with buffers, variables socket process TCP with buffers, variables socket controlled by operating system controlled by operating system internet host or server host or server 11/19/2018 COSC 4213 - S.Datta
Socket programming with TCP Client must contact server server process must first be running server must have created socket (door) that welcomes client’s contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process When client creates socket: client TCP establishes connection to server TCP When contacted by client, server TCP creates new socket for server process to communicate with client allows server to talk with multiple clients source port numbers used to distinguish clients (more in Chap 3) TCP provides reliable, in-order transfer of bytes (“pipe”) between client and server application viewpoint 11/19/2018 COSC 4213 - S.Datta
Client/server socket interaction: TCP Server (running on hostid) Client create socket, port=x, for incoming request: welcomeSocket = ServerSocket() TCP connection setup close connectionSocket read reply from clientSocket create socket, connect to hostid, port=x clientSocket = Socket() wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to 11/19/2018 COSC 4213 - S.Datta
Stream jargon A stream is a sequence of characters that flow into or out of a process. An input stream is attached to some input source for the process, e.g., keyboard or socket. An output stream is attached to an output source, e.g., monitor or socket. Client process client TCP socket 11/19/2018 COSC 4213 - S.Datta
Socket programming with TCP Example client-server app: 1) client reads line from standard input (inFromUser stream) , sends to server via socket (outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints modified line from socket (inFromServer stream) 11/19/2018 COSC 4213 - S.Datta
Example: Java client (TCP) import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("hostname", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); Create input stream Create client socket, connect to server Create output stream attached to socket 11/19/2018 COSC 4213 - S.Datta
Example: Java client (TCP), cont. Create input stream attached to socket BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); } Send line to server Read line from server 11/19/2018 COSC 4213 - S.Datta
Example: Java server (TCP) import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); Create welcoming socket at port 6789 Wait, on welcoming socket for contact by client Create input stream, attached to socket 11/19/2018 COSC 4213 - S.Datta
Example: Java server (TCP), cont DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } Create output stream, attached to socket Read in line from socket Write out line to socket End of while loop, loop back and wait for another client connection 11/19/2018 COSC 4213 - S.Datta
Socket programming with UDP UDP: no “connection” between client and server no handshaking sender explicitly attaches IP address and port of destination to each packet server must extract IP address, port of sender from received packet UDP: transmitted data may be received out of order, or lost application viewpoint UDP provides unreliable transfer of groups of bytes (“datagrams”) between client and server 11/19/2018 COSC 4213 - S.Datta
Client/server socket interaction: UDP Server (running on hostid) create socket, clientSocket = DatagramSocket() Client Create, address (hostid, port=x, send datagram request using clientSocket create socket, port=x, for incoming request: serverSocket = DatagramSocket() read request from serverSocket close clientSocket read reply from clientSocket write reply to serverSocket specifying client host address, port number 11/19/2018 COSC 4213 - S.Datta
Example: Java client (UDP) process Input: receives packet (recall thatTCP received “byte stream”) Output: sends packet (recall that TCP sent “byte stream”) client UDP socket 11/19/2018 COSC 4213 - S.Datta
Example: Java client (UDP) import java.io.*; import java.net.*; class UDPClient { public static void main(String args[]) throws Exception { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientSocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("hostname"); byte[ ] sendData = new byte[1024]; byte[ ] receiveData = new byte[1024]; String sentence = inFromUser.readLine(); sendData = sentence.getBytes(); Create input stream Create client socket Translate hostname to IP address using DNS 11/19/2018 COSC 4213 - S.Datta
Example: Java client (UDP), cont. Create datagram with data-to-send, length, IP addr, port DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876); clientSocket.send(sendPacket); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); clientSocket.receive(receivePacket); String modifiedSentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } Send datagram to server Read datagram from server 11/19/2018 COSC 4213 - S.Datta
Example: Java server (UDP) import java.io.*; import java.net.*; class UDPServer { public static void main(String args[]) throws Exception { DatagramSocket serverSocket = new DatagramSocket(9876); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; while(true) DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivePacket); Create datagram socket at port 9876 Create space for received datagram Receive datagram 11/19/2018 COSC 4213 - S.Datta
Example: Java server (UDP), cont String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); String capitalizedSentence = sentence.toUpperCase(); sendData = capitalizedSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } Get IP addr port #, of sender Create datagram to send to client Write out datagram to socket End of while loop, loop back and wait for another datagram 11/19/2018 COSC 4213 - S.Datta