DOC PREVIEW
CMU CS 15213 - Lecture

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

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

Unformatted text preview:

15 213 Internetworking II Network programming Topics April 20 2000 client server model Berkeley sockets TCP client and server examples UDP client and server examples I O multiplexing with select class26 ppt Internet protocol stack Berkeley sockets interface User application program FTP Telnet WWW email Unreliable best effort datagram delivery processprocess User datagram protocol UDP Unreliable best effort datagram delivery host host class26 ppt Transmission control protocol TCP Internet Protocol IP Reliable byte stream delivery processprocess Network interface ethernet hardware 2 Physical connection CS 213 S 00 UDP vs TCP User Datagram Protocol UDP unreliable datagrams from process to process thin veneer over IP similar to sending surface mail each message is an independent chunk of data datagram messages may not arrive or may arrive out of order faster than TCP requires no server state but ureliable Transmission Control Protocol TCP reliable byte stream from process to process complex implementation similar to placing a phone call no messages just a continuous stream of bytes over a connection bytes arrive in order slower and requires more resources but cleaner user semantics class26 ppt 3 CS 213 S 00 Berkeley Sockets Interface Created in the early 80 s as part of the original Berkeley distribution of Unix that contained the TCP IP protocol stack Provides user level interface to UDP and TCP Underlying basis for all Internet applications Based on client server programming model class26 ppt 4 CS 213 S 00 Client server programming model Client server distributed computing Client server are both processes Server manages a resource Client makes a request for a service client request server process request client server request may involve a conversation according to some server protocol Server provides service by manipulating the resource on behalf of client and then returning a response class26 ppt 5 client response server CS 213 S 00 Internet Servers Servers are long running processes daemons Created at boot time typically by the init process Run continuously until the machine is turned off Each server waits for either TCP connection requests or UDP datagrams to arrive on a wellknown port associated with a particular service port 7 echo server port 25 mail server port 80 http server A machine that runs a server process is also often referred to as a server class26 ppt 6 CS 213 S 00 Server examples Web server port 80 resource files compute cycles CGI programs service retrieves files and runs CGI programs on behalf of the client FTP server 20 21 resource files service stores and retrieve files Telnet server 23 resource terminal service proxies a terminal on the server machine Mail server 25 resource email spool file service stores mail messages in spool file class26 ppt 7 CS 213 S 00 Server examples cont DNS name server 53 resource distributed name database service distributed database lookup Whois server 430 resource second level domain name database e g cmu edu service database lookup Daytime 13 resource system clock service retrieves value of system clock DHCP server 67 resource IP addresses service assigns IP addresses to clients class26 ppt 8 CS 213 S 00 Server examples cont X server 177 resource display screen and keyboard service paints screen and accepts keyboard input on behalf of a client AFS file server 7000 resource subset of files in a distributed filesystem e g AFS NFS service retrieves and stores files Kerberos authentication server 750 resource tickets service authenticates client and returns tickets etc services file gives a comprehensive list for Linux machines class26 ppt 9 CS 213 S 00 File I O open Must open a file before you can do anything else open returns a small integer file descriptor fd 0 indicates that an error occurred predefined file descriptors 0 stdin 1 stdout 2 stderr int fd file descriptor if fd open etc hosts O RDONLY 0 perror open exit 1 class26 ppt 10 CS 213 S 00 File I O read read allows a program to access the contents of file char buf 512 int fd file descriptor int nbytes number of bytes read open the file read up to 512 bytes from file fd if nbytes read fd buf sizeof buf 0 perror read exit 1 read returns the number of bytes read from file fd nbytes 0 indicates that an error occurred if successful read places nbytes bytes into memory starting at address buf class26 ppt 11 CS 213 S 00 File I O write write allows a program to modify file contents char buf 512 int fd file descriptor int nbytes number of bytes read open the file write up to 512 bytes from buf to file fd if nbytes write fd buf sizeof buf 0 perror write exit 1 write returns the number of bytes written from buf to file fd nbytes 0 indicates that an error occurred class26 ppt 12 CS 213 S 00 What is a socket A socket is a descriptor that lets an application read write from to the network Unix uses the same abstraction for both file I O and network I O Clients and servers communicate with each other via TCP and UDP using the same socket abstraction applications read and write TCP byte streams by reading from and writing to socket descriptors applications read write UDP datagrams by reading from and writing to socket descriptors Main difference between file I O and socket I O is how the application opens the sock descriptors class26 ppt 13 CS 213 S 00 Key data structures Defined in usr include netinet in h Internet address struct in addr unsigned int s addr 32 bit IP address Internet style socket address struct sockaddr in unsigned short int sin family unsigned short int sin port struct in addr sin addr unsigned char sin zero Address family AF INET Port number IP address Pad to sizeof struct sockaddr Internet style sockets are characterized by a 32 bit IP address and a port class26 ppt 14 CS 213 S 00 Key data structures Defined in usr include netdb h Domain Name Service DNS struct hostent char h name char h aliases int h addrtype int h length char h addr list host entry official name of host alias list host address type length of address list of addresses Hostent is a DNS host entry that associates a domain name e g cmu edu with an IP addr 128 2 35 186 DNS is a world wide distributed database of domain name IP address mappings Can be accessed from user programs using gethostbyname domain name to IP address or gethostbyaddr IP address to domain name Can also be accessed from the shell using nslookup or dig class26 ppt 15 CS 213 S 00 TCP echo server prologue The server listens on a port


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

lecture

lecture

44 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

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?