DOC PREVIEW
CMU 15441 Computer Networking - Lecture

This preview shows page 1-2-3-4-29-30-31-32-33-60-61-62-63 out of 63 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 63 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 63 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 63 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 63 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 63 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 63 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 63 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 63 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 63 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 63 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 63 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 63 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 63 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 63 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Network Programming IntroductionJan. 25, 2006TopicsTopicsProgrammer's view of the InternetSockets interfaceWriting clients and serversConcurrency with I/O multiplexingL03a_Sockets15-441(Borrowing heavily from 15-213)– 2 –15-441, Spring 2006About This Lecture“Intro to writing client/server programs with TCP”“Intro to writing client/server programs with TCP”Stolen from 15-213Should be “review”Will zoom through these slidesYou may review at your leisureExtensions to reach Project 1Extensions to reach Project 115-213 “rio” package may not be advisableYou'll use UDP, not TCPPacket protocol rather than byte-streamNo “connections” (hence no “disconnections” aka EOFs)You may find error reporting confusing at first– 3 –15-441, Spring 2006A Client-Server TransactionClientprocessServerprocess1. Client sends request2. Server handlesrequest3. Server sends response4. Client handlesresponseResourceEvery network application is based on the client-server Every network application is based on the client-server model:model: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).– 4 –15-441, Spring 2006Network ApplicationsAccess to Network via Program InterfaceAccess 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, reliability, ordering, &c.Client ComputerOSNetworkInterfaceClientAppl.SocketOS +NetworkAPIsServer ComputerOSNetworkInterfaceServerAppl.SocketOS +NetworkAPIsInternet– 5 –15-441, Spring 2006ClientsExamples of client programsExamples of client programsWeb browsers, ftp, telnet, sshHow does a client specify a server?How does a client specify a 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 portsPort 7: Echo serverPort 23: Telnet serverPort 25: Mail serverPort 80: Web server– 6 –15-441, Spring 2006Internet Connections (TCP/IP)Connection socket pair(128.2.194.242:3479, 208.216.181.15:80)Server(port 80)ClientClient socket address128.2.194.242:3479Server socket address208.216.181.15:80Client host address128.2.194.242 Server host address208.216.181.15Clients and servers communicate by sending streams Clients and servers communicate by sending streams of bytes over of bytes over connectionsconnections..Connections are point-to-point, full-duplex (2-way Connections are point-to-point, full-duplex (2-way communication), and reliable.communication), and reliable.Note: 3479 is anephemeral port allocatedby the kernel Note: 80 is a well-known portassociated with Web servers– 7 –15-441, Spring 2006Using Ports to Identify ServicesWeb server(port 80)Client hostServer host 128.2.194.242Echo server(port 7)Service request for128.2.194.242:80(i.e., the Web server)Web server(port 80)Echo server(port 7)Service request for128.2.194.242:7(i.e., the echo server)KernelKernelClientClient– 8 –15-441, Spring 2006ServersServers are long-running processes (daemons).Servers 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 Each server waits for requests to arrive on a well-known port associated with a particular service.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 A machine that runs a server process is also often referred to as a “ server.”referred to as a “ server.”See /etc/services for a list of semi-standard service to port bindings.– 9 –15-441, Spring 2006Sockets InterfaceCreated in the early 80’s as part of the original Berkeley Created in the early 80’s as part of the original Berkeley distribution of Unix that contained an early version of distribution of Unix that contained an early version of the Internet protocols.the Internet protocols.Provides a user-level interface to the network.Provides a user-level interface to the network.Underlying basis for all Internet applications.Underlying basis for all Internet applications.Based on client/server programming model.Based on client/server programming model.– 10 –15-441, Spring 2006Client / ServerSessionOverview of the Sockets InterfaceClientServersocket socketbindlistenrio_readlinebrio_writenrio_readlinebrio_writenConnectionrequestrio_readlinebclosecloseEOFAwait connectionrequest fromnext clientopen_listenfdopen_clientfdacceptconnect– 11 –15-441, Spring 2006SocketsWhat is a socket?What 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. Remember: All Unix I/O devices, including networks, are modeled as files.Clients and servers communicate with each by reading Clients and servers communicate with each by reading from and writing to socket descriptors.from and writing to socket descriptors.The main distinction between regular file I/O and socket The main distinction between regular file I/O and socket I/O is how the application “ opens” the socket I/O is how the application “ opens” the socket descriptors.descriptors.– 12 –15-441, Spring 2006Socket Address StructuresGeneric socket address:Generic socket address:For address arguments to connect, bind, and accept.Necessary only because C did not have generic (void *) pointers when the sockets interface was designed.  Internet-specific socket address:Internet-specific socket address:Must cast (sockaddr_in *) to (sockaddr *) for connect, bind, and accept.struct sockaddr { unsigned short sa_family; /* protocol family */ char sa_data[14]; /* address data. */ }; struct sockaddr_in { unsigned short sin_family; /* address family (always AF_INET) */ unsigned short sin_port; /* port num in network byte order */ struct in_addr sin_addr; /* IP addr in


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

74 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

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?