390 likes | 403 Views
This course covers advanced topics in computer networks, including P2P systems, multimedia communication, network security, and wireless sensor networks. It focuses on TCP/IP architecture and hands-on TCP/IP programming.
E N D
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. 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 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. 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. COSC 4213 - S.Datta
Major differences with 3213 • More algorithmic (less math!) • More hands-on – TCP/IP programming. COSC 4213 - S.Datta
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 providers interconnect (peer) privately Internet structure: network of networks Tier 1 ISP Tier 1 ISP Tier 1 ISP COSC 4213 - S.Datta
Tier-1 ISP: e.g., Sprint Sprint US backbone network COSC 4213 - S.Datta
“Tier-2” ISPs: smaller (often regional) ISPs Connect to one or more tier-1 ISPs, possibly other tier-2 ISPs NAP Tier-2 ISPs also peer privately with each other, interconnect at NAP • Tier-2 ISP pays tier-1 ISP for connectivity to rest of Internet • tier-2 ISP is customer of tier-1 provider Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Internet structure: network of networks Tier 1 ISP Tier 1 ISP Tier 1 ISP COSC 4213 - S.Datta
“Tier-3” ISPs and local ISPs last hop (“access”) network (closest to end systems) Tier 3 ISP local ISP local ISP local ISP local ISP local ISP local ISP local ISP local ISP NAP Local and tier- 3 ISPs are customers of higher tier ISPs connecting them to rest of Internet Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Internet structure: network of networks Tier 1 ISP Tier 1 ISP Tier 1 ISP COSC 4213 - S.Datta
a packet passes through many networks! Tier 3 ISP local ISP local ISP local ISP local ISP local ISP local ISP local ISP local ISP NAP Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Tier-2 ISP Internet structure: network of networks Tier 1 ISP Tier 1 ISP Tier 1 ISP COSC 4213 - S.Datta
network edge: applications and hosts A closer look at network structure: • access networks, physical media: wired, wireless communication links • network core: • interconnected routers • network of networks COSC 4213 - S.Datta
end systems (hosts): run application programs e.g. Web, email at “edge of network” peer-peer client/server The network edge: • 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 COSC 4213 - S.Datta
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 Network edge: reliable data transfer service COSC 4213 - S.Datta
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 Network edge: best effort (unreliable) data transfer service 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? COSC 4213 - S.Datta
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? Protocol “Layers” COSC 4213 - S.Datta
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 Internet protocol “stack” COSC 4213 - S.Datta
network link physical link physical M M Ht Ht M M Hn Hn Hn Hn Ht Ht Ht Ht M M M M Hl Hl Hl Hl Hl Hl Hn Hn Hn Hn Hn Hn Ht Ht Ht Ht Ht Ht M M M M M M Encapsulation source message application transport network link physical segment datagram frame switch destination application transport network link physical router COSC 4213 - S.Datta
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 1972: ARPAnet demonstrated publicly NCP (Network Control Protocol) first host-host protocol first e-mail program ARPAnet has 15 nodes Internet History 1961-1972: Early packet-switching principles COSC 4213 - S.Datta
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 Internet History 1972-1980: Internetworking, new and proprietary nets COSC 4213 - S.Datta
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 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 Internet History 1990, 2000’s: commercialization, the Web, new apps COSC 4213 - S.Datta
Next: the programming API • Reading: Ch 2.7-2.8. • TCP vs UDP COSC 4213 - S.Datta
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 Socket programming 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 COSC 4213 - S.Datta
process process TCP with buffers, variables TCP with buffers, variables socket socket Socket-programming using TCP Socket: a door between application process and end-end-transport protocol (UCP or TCP) TCP service: reliable transfer of bytesfrom one process to another controlled by application developer controlled by application developer controlled by operating system controlled by operating system internet host or server host or server COSC 4213 - S.Datta
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 Socket programming with TCP COSC 4213 - S.Datta
create socket, connect to hostid, port=x create socket, port=x, for incoming request: clientSocket = Socket() welcomeSocket = ServerSocket() TCP connection setup wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to connectionSocket read reply from clientSocket close connectionSocket close clientSocket Client/server socket interaction: TCP Server (running on hostid) Client COSC 4213 - S.Datta
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. Stream jargon Client process client TCP socket COSC 4213 - S.Datta
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) Socket programming with TCP 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 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 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 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 COSC 4213 - S.Datta
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 UDP provides unreliable transfer of groups of bytes (“datagrams”) between client and server application viewpoint Socket programming with UDP COSC 4213 - S.Datta
Client create socket, port=x, for incoming request: serverSocket = DatagramSocket() create socket, clientSocket = DatagramSocket() Create, address (hostid, port=x, send datagram request using clientSocket read request from serverSocket write reply to serverSocket specifying client host address, port number read reply from clientSocket close clientSocket Client/server socket interaction: UDP Server (running on hostid) COSC 4213 - S.Datta
Example: Java client (UDP) Client process Input: receives packet (recall thatTCP received “byte stream”) Output: sends packet (recall that TCP sent “byte stream”) client UDP socket 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 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 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 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 COSC 4213 - S.Datta