Download presentation
Presentation is loading. Please wait.
1
Networking Overview February 2, 2004
2
2/2/2004 Assignments Due – Homework 0 Due – Reading and Warmup questions Work on Homework 1
3
2/2/2004 What’s the Internet: “nuts and bolts” view local ISP company network regional ISP router workstation server mobile
4
2/2/2004 What’s the Internet: “nuts and bolts” view connect hosts or end systems running network applications local ISP company network regional ISP router workstation server mobile
5
2/2/2004 What’s the Internet: “nuts and bolts” view connected via communication links physical media –fiber optics –coaxial cable –others? bandwidth how fast bits are transmitted –examples? local ISP company network regional ISP router workstation server mobile
6
2/2/2004 What’s the Internet: “nuts and bolts” view routers connect links forward packets along a path or route –what’s in a packet? packet switching local ISP company network regional ISP router workstation server mobile
7
2/2/2004 What’s the Internet: a service view communication infrastructure enables distributed applications: –games – what else? communication services provided to apps: –connection-oriented, reliable (TCP) example apps? –connectionless, unreliable (UDP) example apps?
8
2/2/2004 What’s a protocol? human protocols –define communication between two people network protocols –protocols define format, order of msgs sent and received among network entities, and actions taken on msg transmission, receipt Why are protocols so important?
9
2/2/2004 What’s a protocol? a human protocol and a computer network protocol: Hi Got the time? 2:00 TCP connection req TCP connection response Get http://www.awl.com/kurose-ross time
10
2/2/2004 Protocol Example – HTTP Request GET /index.html HTTP/1.1 Response HTTP/1.1 200 OK Connection close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data
11
2/2/2004 Layering How can we organize the structure of the network? –Why is this important?
12
2/2/2004 Organization of Air Travel ticket (purchase) baggage (check) gates (load) runway takeoff airplane routing ticket (complain) baggage (claim) gates (unload) runway landing airplane routing
13
2/2/2004 A Layered Approach Counter-to-counter delivery of person+bags baggage-claim-to-baggage-claim delivery people transfer: loading gate to arrival gate runway-to-runway delivery of plane airplane routing from source to destination
14
2/2/2004 Distributed Implementation ticket (purchase) baggage (check) gates (load) runway takeoff airplane routing ticket (complain) baggage (claim) gates (unload) runway landing airplane routing Departing airport Arriving airport intermediate air traffic sites airplane routing
15
2/2/2004 Why Layering? Makes a complex system easier to deal with Modularization eases maintenance, updating of system –change of implementation of layer’s service transparent to rest of system
16
2/2/2004 Internet Protocol Stack Application –supporting network applications Transport –host-host data transfer Network –routing of datagrams from source to destination Link –data transfer between neighboring network elements Physical –bits “on the wire” application transport network link physical
17
2/2/2004 Sockets Interface between app and transport layers Send/receive messages to/from socket API –choice of transport protocol –ability to fix a few parameters (buffer size, etc) process TCP with buffers, variables socket host or server process TCP with buffers, variables socket host or server Internet controlled by OS controlled by app developer
18
2/2/2004 Sockets Application Transport Network Link Physical Socket
19
2/2/2004 Addressing Need ID for receiving host –Unique 32-bit IP address 138.110.1.1
20
2/2/2004 Addressing Need ID for receiving host –Unique 32-bit IP address 138.110.1.1 Need to differentiate between processes –Port number (HTTP is typically port 80)
21
2/2/2004 Port Number Transport Web ServerMail Server IP = 138.110.1.1 Port = 25 Port = 80
22
2/2/2004 Socket Programming with TCP Client/Server 1.Server starts 2.Server creates a socket (specifying port number) 3.Client starts 4.Client creates a socket (what must be specified?) and initiates TCP connection 5. Server creates a new socket for the connection
23
2/2/2004 Stream Jargon Stream – a sequence of characters that flow into or out of a process. Input Stream – attached to some input source for the process –keyboard, socket, ??? Output Stream – attached to an output source –monitor, socket, ???
24
2/2/2004 TCP Client Architecture 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) Client process client TCP socket
25
2/2/2004 TCP Client/Server Interaction wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port= x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port= x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket Server (running on hostid ) Client send request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup
26
2/2/2004 TCPClient.java 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
27
2/2/2004 TCPClient.java 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(); } Create input stream attached to socket Send line to server Read line from server
28
2/2/2004 TCPServer.java 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
29
2/2/2004 TCPServer.java DataOutputStream outToClient = new DataOutputStream (connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } Read in line from socket Create output stream, attached to socket Write out line to socket End of while loop, loop back and wait for another client connection
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.