DOC PREVIEW
CMU 15441 Computer Networking - Lecture

This preview shows page 1-2-20-21 out of 21 pages.

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

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21– 1 –15-441, Fall 2003Advice on ProgrammingSept. 4, 2003TopicsTopicsRobust ProgrammingVersion ControlUsing scripting languagesClass02b15-441– 1 –15-441, Fall 2003About This LectureVersion control / Source controlVersion control / Source controlPresented today: RCS(by a rogue instructor)Rogue instructor's opinion of RCS: extremelyextremely obsolete(Though it can be used effectively as a building block)Why will we discuss RCS today?“Received wisdom” says...»It's really hard to get students to use source control.»Many refuse.»The quickest thing to explain is RCS.»Maybe if we describe something simple people might use it.– 1 –15-441, Fall 2003About This LectureHope, fear, loathing, ...Hope, fear, loathing, ...We hope you will use something to safeguard your sanityEasiest thing to explain is RCSRCS is fine for Project 1Your “friends” may have already introduced you to CVS“Friends don't let friends branch CVS”It's fine with us if you use CVS»(necessary evolutionary step, like tube worms)For a conceptually clearer time...Try PRCSIt's small (not as small as RCS, not as big as CVS)Most-important features of source control are default behaviors!See last semester's PRCS intro from 15-410, posted on 441 site– 1 –15-441, Fall 2003Client / ServerSessionClient/Server CodeClientServersocket socketbindlistenrio_readlinebrio_writenrio_readlinebrio_writenConnectionrequestrio_readlinebclosecloseEOFAwait connectionrequest fromnext clientopen_listenfdopen_clientfdacceptconnect– 1 –15-441, Fall 2003Robustness PrinciplesClientClientNothing user does/types should make program crashMust perform complete checking for user errorsServerServerNothing a client does should cause server to malfunctionPossibly malicious clientsThings to Worry AboutThings to Worry AboutError return codes by system callsString overflowsMalformed messagesMemory/resource leaksEspecially for server– 1 –15-441, Fall 2003Echo Client Main Routine#include "csapp.h" /* 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 = Open_clientfd(host, port); Rio_readinitb(&rio, clientfd); while (Fgets(buf, MAXLINE, stdin) != NULL) { Rio_writen(clientfd, buf, strlen(buf)); Rio_readlineb(&rio, buf, MAXLINE); Fputs(buf, stdout); } Close(clientfd); exit(0); } No checking of command line argumentsWrappers exit on errorfgets does not insert \n when string too long– 1 –15-441, Fall 2003Robust Version of Echo Client (1) #include <limits.h>/* To demonstrate truncation */#define LINELEN 20/* Maximum number of errors to tolerate before exiting */int errlimit = 5;void errcheck(char *message, int fatal){ if (--errlimit == 0 || fatal) { fprintf(stderr, "Error: %s. Exiting\n", message); exit(1); } fprintf(stderr, "Error: %s. Continuing\n", message);}void usage(char *progname) { fprintf(stderr, "Usage: %s host port\n", progname); exit(0);}– 1 –15-441, Fall 2003Robust Version of Echo Client (2) int main(int argc, char **argv) { int clientfd, port; char *host, buf[LINELEN]; rio_t rio; if (argc != 3) usage(argv[0]); host = argv[1]; port = atoi(argv[2]); if (port <= 0 || port > SHRT_MAX) errcheck("Invalid Port", 1); clientfd = open_clientfd(host, port); if (clientfd < 0) errcheck("Couldn't open connection to server", 1); rio_readinitb(&rio, clientfd); ...– 1 –15-441, Fall 2003Robust Version of Echo Client (3) ... while (fgets(buf, LINELEN, stdin) != NULL) { int n; if (strlen(buf) == LINELEN-1 && buf[LINELEN-1] != '\n') strcpy(buf+LINELEN-5, "...\n"); /* Truncate string */ if (rio_writen(clientfd, buf, strlen(buf)) < 0) { errcheck("Failed to send message", 0); continue; } if ((n = rio_readlineb(&rio, buf, LINELEN) <= 0)) { if (n == 0)errcheck("Unexpected EOF from server\n", 1); elseerrcheck("Failed to receive reply from server", 0); } if (fputs(buf, stdout) < 0) errcheck("Couldn't print reply\n", 0); } ...– 1 –15-441, Fall 2003Robust Version of Echo Client (4) ... if (close(clientfd) < 0) errcheck("Couldn't close connection to server", 1); exit(0);}– 1 –15-441, Fall 2003Design IssuesError Classification & RecoveryError Classification & RecoveryFatal vs. nonfatal errorsServer code should only have fatal error when something is wrong on server machineWhat to do when when encounter nonfatal errorSkip to next activityServer might close connection to malfunctioning clientOther Types of ErrorsOther Types of ErrorsClient dormant too longAdd timeouts to codeGets very messyDenial of service attacksDifficult to detect and/or handle– 1 –15-441, Fall 2003Version ControlTypical Problems in Managing Software ProjectTypical Problems in Managing Software ProjectMultiple people simultaneously edit single fileWant to prevent this or have some way to merge updatesBug appears in new version that was not detected in earlier versionWant to run tests on older versionCustomer reports problem with program. Turns out he/she has old version of codeWant to back up to earlier version of programCode evolves along incompatible paths by two groupsWant to reconcile into common versionSolutionSolutionImplement some form of automatic version control– 1 –15-441, Fall 2003RCSRevision Control SystemRevision Control SystemBasic Unix program(s) for managing software projectWritten by Walter Tichy, CMU PhD 1980Basic IdeaBasic IdeaCode file foo.c has RCS version foo.c,vComplete history of all versions of fileStored in compacted formUser can “check out” copy of fileEither read-only or writableEven when writable, only single user can do soCan check out older versions of programWhen file modified, can “check in” fileIncrements version numberBecomes available for other users to check out– 1 –15-441, Fall 2003RCS ExampleCode for Echo ServerCode for Echo Server% lsMakefile csapp.c csapp.h echoserver.c% mkdir RCS # Directory for RCS files% ci Makefile csapp.c csapp.h echoserver.c# RCS prompts for descriptions of


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

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?