Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 School of Computing Science Simon Fraser University CMPT 471: Computer Networking II Introduction Instructor: Dr. Mohamed Hefeeda.

Similar presentations


Presentation on theme: "1 School of Computing Science Simon Fraser University CMPT 471: Computer Networking II Introduction Instructor: Dr. Mohamed Hefeeda."— Presentation transcript:

1

2 1 School of Computing Science Simon Fraser University CMPT 471: Computer Networking II Introduction Instructor: Dr. Mohamed Hefeeda

3 2 Course Objectives  Understand  principles of designing and operating computer networks  structure and protocols of the Internet  services that can/cannot be offered by the Internet  Know how to  implement network protocols and applications  Be informed about  recent/hot topics in networking research and industry  top technical conferences/journals in networking research and technology

4 3 Course Info: Textbooks and References  Textbook  Kurose and Rose, Computer Networking: A top-down Approach, latest edition  References  Posted on the course web page  Course web page http://nsl.cs.sfu.ca/teaching/14/471/ Access it from my web page: http://www.cs.sfu.ca/~mhefeeda

5 4 Course Info: Grading (Tentative)  Assignments, Projects, Class Participation: 50%  Several programming projects mostly in C and Java  Assignments include problems sets, researching topics, conducting experiments, presentations, …  Must read Assignment PolicyAssignment Policy  Midterm Exams and Quizzes: 50%  No final

6 5 Course Info: Topics  Review of Networking Basics:  Internet Architecture and TCP/IP Stack  Multimedia Networking  Wireless Networks  Network Management  Selected topics from  Virtual Networks and Overlays  Network Security  Software Defined Networks  Cloud Computing  Data Center Networking

7 6 Quick Survey: did you cover …  Socket programming?  Wireshark experiments?  C programming?  Unix?  IP Multicast?  Multimedia Networking?  Wireless Networks?  Network Management?  Network Security?

8 7 Basic Networking Concepts

9 8 Review of Basic Networking Concepts  Internet structure  Protocol layering and encapsulation  Socket programming  Transport layer  Reliability and congestion control  Performance modeling of TCP  Network Layer  Addressing, Forwarding, Routing  IP Multicast

10 Introduction  Internet: “network of networks”  Interconnected ISPs  protocols control sending, receiving of messages  e.g., TCP, IP, HTTP, Skype, 802.11  Internet standards  RFC: Request for comments  IETF: Internet Engineering Task Force The Internet: Network of Networks mobile network global ISP regional ISP home network institutional network 1-9

11 10 Internet structure: network of networks  roughly hierarchical  at center: “tier-1” ISPs (e.g., MCI, Sprint, and AT&T), national/international coverage  treat each other as equals Tier 1 ISP Tier-1 providers interconnect (peer) privately IXP Tier-1 providers also interconnect at public Internet Exchange Points (IXPs)

12 Introduction Tier-1 ISP: e.g., Sprint … to/from customers peering to/from backbone … … … … POP: point-of-presence 1-11

13 12 Internet structure: Tier-2 ISPs  “Tier-2” ISPs: smaller (often regional) ISPs  Connect to one or more tier-1 ISPs, possibly other tier-2 ISPs Tier 1 ISP IXP Tier-2 ISP Tier-2 ISP pays tier-1 ISP for connectivity to rest of Internet Tier-2 ISP is customer of tier-1 provider Tier-2 ISPs also peer privately with each other, interconnect at NAP

14 13 Internet structure: Tier-3 ISPs  “Tier-3” ISPs and local ISPs  last hop (“access”) network (closest to end systems) Tier 1 ISP IXP Tier-2 ISP local ISP local ISP local ISP local ISP local ISP Tier 3 ISP local ISP local ISP local ISP Local and tier- 3 ISPs are customers of higher tier ISPs connecting them to rest of Internet

15 14 Internet structure: packet journey  a packet passes through many networks! Tier 1 ISP NAP Tier-2 ISP local ISP local ISP local ISP local ISP local ISP Tier 3 ISP local ISP local ISP local ISP

16 15 Internet protocol stack  application: supporting network applications  FTP, SMTP, HTTP  transport: process-process data transfer  TCP, UDP  network: routing of datagrams from source to destination  IP, routing protocols  link: data transfer between neighboring network elements  PPP, Ethernet  physical: bits “on the wire” application transport network link physical

17 16 datagram frame HtHt HnHn HlHl M HtHt HnHn M segment HtHt M message M HtHt HnHn HlHl M HtHt HnHn M HtHt M M application transport network link physical application transport network link physical link physical network link physical HtHt HnHn HlHl M HtHt HnHn M HtHt HnHn HlHl M HtHt HnHn M HtHt HnHn HlHl M HtHt HnHn HlHl M source destination router switch Encapsulation

18 17 Why layering? Dealing with complex systems:  explicit structure allows identifying complex relationships among system’s pieces  modularization eases maintenance, updating of system  change of implementation of layer’s service transparent to rest of system  e.g., change in gate procedure does not affect rest of system  What is the downside of layering?

19 18 Internet Services  View the Internet as a communication infrastructure that provides services to apps  Web, email, games, e-commerce, file sharing, …  Two communication services  Connectionless unreliable  Connection-oriented reliable

20 19 Internet Services  Connection-oriented  Prepare for data transfer ahead of time  establish connection  set up state in the two communicating hosts  Usually comes with reliability, flow and congestion control  TCP: Transmission Control Protocol  Connectionless  No connection set up, simply send  Faster, less overhead  No reliability, flow control, or congestion control  UDP: User Datagram Protocol How can we access these services?

21 20 Network (Socket) Programming  Process sends/receives messages to/from its socket  Socket is the interface (API) between application and transport layer  Process is identified by:  IP address,  Transport protocol, and  Port number process TCP with buffers, variables socket host or server process TCP with buffers, variables socket host or server Internet controlled by OS controlled by app developer

22 21 Socket Programming  Socket API  introduced in BSD 4.1 UNIX, 1981  explicitly created, used, released by apps  client/server paradigm  provides two services reliable, byte stream-oriented unreliable datagram

23 22 Socket Programming using TCP  TCP service: reliable transfer of bytes from one process to another  virtual pipe between sender and receiver process TCP with buffers, variables socket controlled by application developer controlled by operating system host or server process TCP with buffers, variables socket controlled by application developer controlled by operating system host or server internet

24 23 Socket Programming using TCP wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port= x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port= x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket Server (running on hostid ) Client send request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup

25 24 Socket Programming using TCP  Server process must be running first, and  creates a socket (door) that accepts client’s contact, then wait  Client contacts server by creating local TCP socket using IP address, port number of server process  When client creates socket  client TCP (in OS kernel) establishes connection to server TCP  When contacted by client  server TCP creates new socket for server process to communicate with client allows server to talk with multiple clients source port numbers and IPs used to distinguish clients

26 25 Socket Programming using UDP close clientSocket Server (running on hostid ) create socket, clientSocket = DatagramSocket() Client read reply from clientSocket Create datagram ( hostid,port=x,data) send datagram request using clientSocket create socket, port= x, for incoming request: serverSocket = DatagramSocket() read request from serverSocket write reply to serverSocket specifying client host address, port number

27 26 Socket programming using UDP  UDP Service: unreliable transfer of datagrams between client and server  no connection between client and server  no handshaking  sender explicitly attaches IP address and port of destination to each packet  server must extract IP address, port of sender from received packet  transmitted data may be received out of order, or lost

28 Examples in C 27

29 TCP Daytime Server 28 int main (int argc, char **argv) { int listenfd, connfd; struct sockaddr_in servaddr; char buff[MAXLINE]; time_t ticks; listenfd = socket(AF_INET, SOCK_STREAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(DAYTIME_PORT); /* daytime server */ bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); listen(listenfd, LISTENQ); for ( ; ; ) { connfd = accept(listenfd, (struct sockaddr *) NULL, NULL); ticks = time(NULL); snprintf(buff, sizeof(buff), "%.24s\r\n", ctime(&ticks)); write(connfd, buff, strlen(buff)); printf("Sending response: %s", buff); close(connfd); }}

30 htonX and ntohX macros: Important  Some machine use “big endian” and others use “little endian” to store numbers  Whenever sending numbers to network use htonX  Whenever receiving numbers from network use ntohX 29

31 TCP Daytime Client 30 int main(int argc, char **argv) { … if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("socket error\n"); exit(1); } bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(DAYTIME_PORT); /* daytime server */ if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0) { printf("inet_pton error for %s\n", argv[1]); exit(1); } if (connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) { printf("connect error\n"); exit(1); } while ( (n = read(sockfd, recvline, MAXLINE)) > 0) { recvline[n] = 0; /* null terminate */ if (fputs(recvline, stdout) == EOF) { printf("fputs error\n"); exit(1); } }

32 31 Concurrent TCP Servers  Daytime server accepts one connection at a time  Not good for other servers, e.g., Web servers  How would you make it handle multiple connections concurrently?  We need some parallelism!  But where?

33 TCP Daytime Server 32 int main (int argc, char **argv) { int listenfd, connfd; struct sockaddr_in servaddr; char buff[MAXLINE]; time_t ticks; listenfd = socket(AF_INET, SOCK_STREAM, 0); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(DAYTIME_PORT); /* daytime server */ bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); listen(listenfd, LISTENQ); for ( ; ; ) { connfd = accept(listenfd, (struct sockaddr *) NULL, NULL); ticks = time(NULL); snprintf(buff, sizeof(buff), "%.24s\r\n", ctime(&ticks)); write(connfd, buff, strlen(buff)); printf("Sending response: %s", buff); close(connfd); }}

34 Concurrent Server 33 for ( ; ; ) { connfd = accept(listenfd, …); if ( (pid = fork()) == 0) { close(listenfd); /*child closes listening socket */ doit(connfd); /*process the request */ close(connfd); /*done with this client */ exit(0); /*child terminates */ } close(connfd); /*parent closes connected socket */ }  Fork: duplicates the entire process that called it  Fork returns twice!  One to the child process, return value = 0  Second to parent with non zero (pid of the created child)

35 Summary 34  Quick review to Internet structure  Protocol layering  Socket programming using TCP and UDP


Download ppt "1 School of Computing Science Simon Fraser University CMPT 471: Computer Networking II Introduction Instructor: Dr. Mohamed Hefeeda."

Similar presentations


Ads by Google