DOC PREVIEW
CMU 15441 Computer Networking - Lecture

This preview shows page 1-2-3-4-5-35-36-37-38-39-70-71-72-73-74 out of 74 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 74 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Network ProgrammingSeptember 6, 2005A Client-Server ExchangeNetwork ApplicationsInternet Connections (TCP/IP)ClientsUsing Ports to Identify ServicesServersOverview of the Sockets InterfaceSocketsSocket Programming ClichesSocket Programming HelpSocket Address StructuresReliable I/O (RIO) SummaryEcho Client Main RoutineClient-side ProgrammingEcho Client: open_clientfdEcho Client: open_clientfd (socket)Echo Client: open_clientfd (gethostbyname)Echo Client: open_clientfd (connect)Server-side ProgrammingServers and sockets – 1 isn’t enoughConnected vs. Listening DescriptorsEcho Server: accept IllustratedEcho Server: Main LoopEcho Server: open_listenfdEcho Server: open_listenfd (cont)Echo Server: open_listenfd(socket)Echo Server: open_listenfd (initialize socket address)Echo Server: open_listenfd (bind)Echo Server: open_listenfd (listen)Echo Server: acceptEcho Server: Main RoutineEcho Server: Identifying the ClientEcho Server: echoRunning Echo Client/ServerTypes of Server ImplementationsIterative ServersFundamental Flaw of Iterative ServersConcurrent ServersPossible Mechanisms for Creating Concurrent FlowsEvent-Based Concurrent Servers Using I/O MultiplexingThe select FunctionMacros for Manipulating Set DescriptorsEvent-based Concurrent Echo ServerEvent-based Concurrent Server (cont)Event-based Concurrent Server (cont)Event-based Concurrent Server (cont)Event-based Concurrent Server (cont)Pro and Cons of Event-Based DesignsAttack #1Attack #2: Partial LinesFlaky ClientImplementing a Robust ServerRobust ServerRobust Server LoopNOTE (Just to complicate things…)Conceptual ModelFor More InformationFor More InformationGDB and Version Control (RCS/CVS)Debugging with GDBControlling Your Program With GDBExamining the State of Your ProgramVersion Control with RCSCreating RCS FilesChecking out filesVersionsVersion Control with CVSVersion Control continuedMore information…Tips for the pastMore tips for the pastFinally…Network ProgrammingSeptember 6, 2005TopicsProgrammer’s view of the InternetSockets interfaceWriting clients and serversConcurrency with I/O multiplexingDebugging With GDBVersion Control (RCS/CVS)Tips from the trenches: Projects 1 & 2class03.ppt15-441David MurraySlides based on those of Dave Maltz,Randy Bryant, Geoff Langale,and the 15-213 crewA Client-Server ExchangeClientprocessServerprocess1. Client sends request2. Server handlesrequest3. Server sends response4. Client handlesresponseResourceA server process and one or more client processesServer manages some resource.Server provides service by manipulating resource for clients.Note: clients and servers are processes running on hosts (can be the same or different hosts).215-441, Spring 2005Network ApplicationsClient MachineClient MachineServer MachineServer MachineOSNetworkInterfaceClientAppl.SocketOSNetworkInterfaceServerAppl.OS +NetworkAPIsOS +NetworkAPIsSocketInternetAccess to Network via Program InterfaceSockets make network I/O look like filesCall system functions to control and communicateNetwork code handles issues of routing, segmentation.315-441, Spring 2005Internet Connections (TCP/IP)Two common paradigms for clients and servers communicationz Datagrams (UDP protocol SOCK_DGRAM)z Connections (TCP protocol, SOCK_STREAM) Connections are point-to-point, full-duplex (2-way communication), and reliable. (TODAY’S TOPIC!)415-441, Spring 2005Client socket address128.2.194.242:3479Server socket address208.216.181.15:80Connection socket pair(128.2.194.242:3479, 208.216.181.15:80)Server(port 80)ClientClient host address128.2.194.242Server host address208.216.181.15Note: 80 is a well-known portassociated with Web serversNote: 3479 is anephemeral port allocatedby the kernelClients515-441, Spring 2005Examples of client programsWeb browsers, ftp, telnet, sshHow does a client find the server?The IP address in the server socket address identifies the host (more precisely, an adaptor on the host)The (well-known) port in the server socket address identifies the service, and thus implicitly identifies the server process that performs that service.Examples of well known portsz Port 7: Echo serverz Port 23: Telnet serverz Port 25: Mail serverz Port 80: Web serverUsing Ports to Identify ServicesServer host 128.2.194.242Web server(port 80)Client hostService request for128.2.194.242:80(i.e., the Web server)Echo server(port 7)KernelClient615-441, Spring 2005Web server(port 80)Echo server(port 7)Service request for128.2.194.242:7(i.e., the echo server)KernelClientServers715-441, Spring 2005Servers are long-running processes (daemons).Created at boot-time (typically) by the init process (process 1)Run continuously until the machine is turned off.Each server waits for requests to arrive on a well-known port associated with a particular service.Port 7: echo serverPort 23: telnet serverPort 25: mail serverPort 80: HTTP serverA machine that runs a server process is also often referred to as a “server.”See /etc/services for a comprehensive list of the services available on a Linux machine.Overview of the Sockets InterfaceClientServer815-441, Spring 2005Client / ServerSessionsocket socketbindlistenreadwritereadwriteConnectionrequestreadclosecloseEOFopen_listenfdopen_clientfdacceptconnectAwait connectionrequest fromnext clientSockets915-441, Spring 2005What is a socket?To the kernel, a socket is an endpoint of communication.To an application, a socket is a file descriptor that lets the application read/write from/to the network.z Remember: All Unix I/O devices, including networks, are modeled as files.Clients and servers communicate with each by reading from and writing to socket descriptors.The main distinction between regular file I/O and socket I/O is how the application “opens” the socket descriptors.Socket Programming Cliches1015-441, Spring 2005Network Byte OrderingNetwork is big-endian, host may be big- or little-endianFunctions work on 16-bit (short) and 32-bit (long) values htons() / htonl() : convert host byte order to network byte orderntohs() / ntohl(): convert network byte order to host byte orderUse these to convert network addresses, ports, …Structure CastsYou will see a lot of ‘structure casts’struct sockaddr_in serveraddr; /* fill in serveraddr with an address */…/* Connect takes (struct sockaddr *) as its second argument */ connect(clientfd, (struct sockaddr *) &serveraddr,sizeof(serveraddr)); …Socket


View Full Document

CMU 15441 Computer Networking - Lecture

Documents in this Course
Lecture

Lecture

14 pages

Lecture

Lecture

19 pages

Lecture

Lecture

14 pages

Lecture

Lecture

78 pages

Lecture

Lecture

35 pages

Lecture

Lecture

4 pages

Lecture

Lecture

4 pages

Lecture

Lecture

29 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

38 pages

Lecture

Lecture

40 pages

Lecture

Lecture

13 pages

Lecture

Lecture

47 pages

Lecture

Lecture

49 pages

Lecture

Lecture

7 pages

Lecture

Lecture

18 pages

Lecture

Lecture

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

17 pages

lecture

lecture

13 pages

Lecture

Lecture

21 pages

Lecture

Lecture

14 pages

Lecture

Lecture

53 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

20 pages

Lecture

Lecture

39 pages

Lecture

Lecture

10 pages

Lecture

Lecture

40 pages

Lecture

Lecture

25 pages

lecture

lecture

11 pages

lecture

lecture

7 pages

Lecture

Lecture

10 pages

lecture

lecture

46 pages

lecture

lecture

7 pages

Lecture

Lecture

8 pages

lecture

lecture

55 pages

lecture

lecture

45 pages

lecture

lecture

47 pages

lecture

lecture

39 pages

lecture

lecture

33 pages

lecture

lecture

38 pages

lecture

lecture

9 pages

midterm

midterm

16 pages

Lecture

Lecture

39 pages

Lecture

Lecture

14 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

41 pages

Lecture

Lecture

38 pages

Lecture

Lecture

9 pages

Lab

Lab

3 pages

Lecture

Lecture

53 pages

Lecture

Lecture

51 pages

Lecture

Lecture

38 pages

Lecture

Lecture

42 pages

Lecture

Lecture

49 pages

Lecture

Lecture

63 pages

Lecture

Lecture

7 pages

Lecture

Lecture

51 pages

Lecture

Lecture

35 pages

Lecture

Lecture

29 pages

Lecture

Lecture

65 pages

Lecture

Lecture

47 pages

Lecture

Lecture

41 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

35 pages

Lecture

Lecture

15 pages

Lecture

Lecture

52 pages

Lecture

Lecture

16 pages

Lecture

Lecture

4 pages

lecture

lecture

27 pages

lecture04

lecture04

46 pages

Lecture

Lecture

46 pages

Lecture

Lecture

13 pages

lecture

lecture

41 pages

lecture

lecture

38 pages

Lecture

Lecture

40 pages

Lecture

Lecture

25 pages

Lecture

Lecture

38 pages

lecture

lecture

11 pages

Lecture

Lecture

42 pages

Lecture

Lecture

12 pages

Lecture

Lecture

36 pages

Lecture

Lecture

46 pages

Lecture

Lecture

35 pages

Lecture

Lecture

34 pages

Lecture

Lecture

9 pages

lecture

lecture

49 pages

class03

class03

39 pages

Lecture

Lecture

8 pages

Lecture 8

Lecture 8

42 pages

Lecture

Lecture

20 pages

lecture

lecture

29 pages

Lecture

Lecture

9 pages

lecture

lecture

46 pages

Lecture

Lecture

12 pages

Lecture

Lecture

24 pages

Lecture

Lecture

41 pages

Lecture

Lecture

37 pages

lecture

lecture

59 pages

Lecture

Lecture

47 pages

Lecture

Lecture

34 pages

Lecture

Lecture

38 pages

Lecture

Lecture

28 pages

Exam

Exam

17 pages

Lecture

Lecture

21 pages

Lecture

Lecture

15 pages

Lecture

Lecture

9 pages

Project

Project

20 pages

Lecture

Lecture

40 pages

L13b_Exam

L13b_Exam

17 pages

Lecture

Lecture

48 pages

Lecture

Lecture

10 pages

Lecture

Lecture

52 pages

21-p2p

21-p2p

16 pages

lecture

lecture

77 pages

Lecture

Lecture

18 pages

Lecture

Lecture

62 pages

Lecture

Lecture

25 pages

Lecture

Lecture

24 pages

Project

Project

20 pages

Lecture

Lecture

47 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Roundup

Roundup

45 pages

Lecture

Lecture

47 pages

Lecture

Lecture

39 pages

Lecture

Lecture

13 pages

Midterm

Midterm

22 pages

Project

Project

26 pages

Lecture

Lecture

11 pages

Project

Project

27 pages

Lecture

Lecture

10 pages

Lecture

Lecture

50 pages

Lab

Lab

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

6 pages

r05-ruby

r05-ruby

27 pages

Lecture

Lecture

8 pages

Lecture

Lecture

28 pages

Lecture

Lecture

30 pages

Project

Project

13 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

48 pages

Lecture

Lecture

55 pages

Lecture

Lecture

36 pages

Lecture

Lecture

17 pages

Load more
Download Lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?