DOC PREVIEW
CMU CS 15213 - lecture

This preview shows page 1-2-3-21-22-23-42-43-44 out of 44 pages.

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

Unformatted text preview:

Carnegie Mellon Network Programming 15 213 Introduc0on to Computer Systems 20th Lecture Nov 2 2010 Instructors Randy Bryant and Dave O Hallaron 1 Carnegie Mellon Last Time Client Server Transac on 4 Client handles response Client process 1 Client sends request 3 Server sends response Server process Resource 2 Server handles request Note clients and servers are processes running on hosts can be the same or di erent hosts 2 Carnegie Mellon Last Time Logical Structure of an internet host router host router router router router router 3 Carnegie Mellon Internet Connec ons Clients and servers communicate by sending streams of bytes over connecAons Point to point full duplex 2 way communica0on and reliable A socket is an endpoint of a connec on Socket address is an IPaddress port pair A port is a 16 bit integer that iden es a process Ephemeral port Assigned automa0cally on client when client makes a connec0on request Well known port Associated with some service provided by a server e g port 80 is associated with Web servers A connec on is uniquely iden ed by the socket addresses of its endpoints socket pair cliaddr cliport servaddr servport 4 Carnegie Mellon PuJng it all Together Anatomy of an Internet Connec on Client socket address 128 2 194 242 51213 Client Server socket address 208 216 181 15 80 Connec on socket pair 128 2 194 242 51213 208 216 181 15 80 Client host address 128 2 194 242 51213 is an ephemeral port allocated by the kernel Server port 80 Server host address 208 216 181 15 80 is a well known port associated with Web servers 5 Carnegie Mellon Clients Examples of client programs Web browsers ftp telnet ssh How does a client nd the server The IP address in the server socket address iden0 es the host more precisely an adapter on the host The well known port in the server socket address iden0 es the service and thus implicitly iden0 es the server process that performs that service Examples of well know ports Port 7 Echo server Port 23 Telnet server Port 25 Mail server Port 80 Web server 6 Carnegie Mellon Using Ports to Iden fy Services Server host 128 2 194 242 Client host Client Service request for 128 2 194 242 80 i e the Web server Web server port 80 Kernel Echo server port 7 Client Service request for 128 2 194 242 7 i e the echo server Web server port 80 Kernel Echo server port 7 7 Carnegie Mellon Servers Servers are long running processes daemons Created at boot 0me typically by the init process process 1 Run con0nuously un0l the machine is turned o Each server waits for requests to arrive on a well known port associated with a par cular service Port 7 echo server Port 23 telnet server Port 25 mail server Port 80 HTTP server A machine that runs a server process is also o en referred to as a server 8 Carnegie Mellon Server Examples Web server port 80 Resource les compute cycles CGI programs Service retrieves les and runs CGI programs on behalf of the client FTP server 20 21 Resource les Service stores and retrieve les See etc services for a comprehensive list of the port mappings on a Linux machine Telnet server 23 Resource terminal Service proxies a terminal on the server machine Mail server 25 Resource email spool le Service stores mail messages in spool le 9 Carnegie Mellon Sockets Interface Created in the early 80 s as part of the original Berkeley distribu on of Unix that contained an early version of the Internet protocols Provides a user level interface to the network Underlying basis for all Internet applica ons Based on client server programming model 10 Carnegie Mellon Sockets What is a socket To the kernel a socket is an endpoint of communica0on To an applica0on a socket is a le descriptor that lets the applica0on read write from to the network Remember All Unix I O devices including networks are modeled as les Clients and servers communicate with each other by reading from and wri ng to socket descriptors Client clientfd Server serverfd The main dis nc on between regular le I O and socket I O is how the applica on opens the socket descriptors 11 Carnegie Mellon Example Echo Client and Server On Client On Server greatwhite echoserveri 15213 linux echoclient greatwhite ics cs cmu edu 15213 server connected to BRYANT TP4 VLSI CS CMU EDU 128 2 213 29 port 64690 type hello there server received 12 bytes echo HELLO THERE type D Connection closed 12 Carnegie Mellon Watching Echo Client Server 13 Carnegie Mellon Ethical Issues Packet Sni er Program that records network tra c visible at node Promiscuous mode Record tra c that does not have this host as source or des0na0on University Policy Network Traffic Network traffic should be considered private Because of this any packet sniffing or other deliberate attempts to read network information which is not intended for your use will be grounds for loss of network privileges for a period of not less than one full semester In some cases the loss of privileges may be permanent Note that it is permissable to run a packet sniffer explicitely configured in non promiscuous mode you may sniff packets going to or from your machine This allows users to explore aspects of networking while protecting the privacy of others 14 Carnegie Mellon Overview of the Sockets Interface Client Server socket socket bind open listenfd open clientfd listen Connec on request Client Server Session connect accept rio writen rio readlineb rio readlineb rio writen close EOF Await connec on request from next client rio readlineb close 15 Carnegie Mellon Socket Address Structures 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 struct sockaddr unsigned short sa family char sa data 14 protocol family address data sa family Family Speci c 16 Carnegie Mellon Socket Address Structures Internet speci c socket address Must cast sockaddr in to sockaddr for connect bind and accept struct sockaddr in unsigned short sin family unsigned short sin port struct in addr sin addr unsigned char sin zero 8 sin port AF INET address family always AF INET port num in network byte order IP addr in network byte order pad to sizeof struct sockaddr sin addr 0 0 0 0 0 0 0 0 sa family sin family Family Speci c 17 Carnegie Mellon Echo Client Main Rou ne include csapp h Send line to server Receive line from server usage echoclient host port int main int argc char argv int clientfd port char host buf MAXLINE rio t rio host argv 1 port atoi argv 2 clientfd


View Full Document

CMU CS 15213 - lecture

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

47 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

29 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 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 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?