1 / 51

CSS432 Computer Networking

CSS432 Computer Networking. Prof. Athirai Irissappane http://courses.washington.edu/css432/athirai/ athirai@uw.edu. Source from Prof. Munehiro Fukuda, Computer Networks Lecture Slides. Networks Building Blocks Network Architecture Protocols Design Issues Network Security….

kristint
Download Presentation

CSS432 Computer Networking

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSS432 Computer Networking Prof. Athirai Irissappane http://courses.washington.edu/css432/athirai/ athirai@uw.edu Source from Prof. Munehiro Fukuda, Computer Networks Lecture Slides CSS 432

  2. Networks Building Blocks Network Architecture Protocols Design Issues Network Security… CSS 432

  3. 4 Assignments 1 Project Class Discussions Mid Term Final Exam CSS 432

  4. CSS432 FoundationTextbook Ch1 CSS 432

  5. Outline Network Basics Network Architecture Implementing Network Software Performance CSS 432

  6. What is a Network? application application Node Router Host Links • Network: Internet • Nodes/Hosts: Laptop, Mobil Phone • Router/Switch/Hub: Forwards messages • Links: Wired/ Wireless • Application: E-mail, Skype 2 or more computers (nodes) that are linked CSS 432

  7. Direct connectivity: limitations length #nodes Building Blocks • Direct connectivity: Nodes directly connected to each other • point-to-point: Direct link between 2 nodes • multiple access: >2 nodes share a single link CSS 432

  8. Clouds - Networks • Indirect Connectivity: no direct physical connection • Switched Network • Internetwork • Network: set of nodes, each connected to one or more p2p link • Cloud represents any kind of network • Switched network: Node linked to switches which forward data • Circuit switch • Packet switch Switch: forwarding message CSS 432

  9. Circuit switching: carry bit streams • Dedicated circuit established (b/w source and destination) • Telephone network (call before specking) • Real time – Voice signals • waste resource capacity (connection cannot be used by others) • Packet switching: store-and-forward messages (e.g., Internet) • Limits size of packets: break down large messages • No dedicated connection, packets find their route to destination using routers CSS 432

  10. Clouds - Networks • Internetwork: • A set of independent clouds (networks) interconnected to forma an internetwork • Internet • Router/Gateway: a node connected to 2 or more networks Router/gateway: forwarding message CSS 432

  11. L1 R1 L2 R2 Switch 1 Switch 2 L3 R3 Multiplexing (hosts share n/w) • Indirect Connection limitation: • what happens when more than one pair of hosts want to send and receive messages at the same time? • several host need to use the same link to send messages (to the same destination) (bandwidth of the link)? • Multiplexing: physical link is shared by multiple hosts, each assumes that the link is dedicated to them. CSS 432

  12. Multiplexing • Synchronous Time-Division Multiplexing (STDM) • Shared over time • Round Robin fashion (L1-R1, L2-R2, L3-R3) • Frequency-Division Multiplexing (FDM) • Transmission across same link but different frequencies • E.g., different cable channels transmitted over one coaxial cable • Two limitations: • If a host has no data to send, the corresponding time slot or frequency becomes idle. • The maximum number of flows, (#time slots and #different frequencies) are fixed. CSS 432

  13. Statistical Multiplexing • On-demand time-division • L1-R1, L3-R1 (L2 has no packets to transfer) • Limit max no. of packets transferred per flow • Packets from different sources interleaved on link • No. of incoming packets greater than outgoing packets • Buffer packets that are contending for the link • Buffer (queue) overflow is called congestion L1 L2 R1 … L3 CSS 432

  14. Inter-Process Communication • Turn host-to-host connectivity into process-to-process communication, i.e., communication between application processes • All application processes need to access some common set of services in the network • (1) ensure data is sent/received (2) packets sent received in same order (3)packets fail to arrive (4)eaves dropping over the channel • Network provides these services in terms of Channels • Abstract the network complexity from application developer • Fill gap between what applications expect and what the underlying technology provides. CSS 432

  15. Host Host Application Host Channel Application Host Host Common Channels • Client Server Communication • Two types of communication channel • Request/Reply (Connection Oriented) Channels • Message Stream (Connectionless) Channels CSS 432

  16. Connection-Oriented (Request Reply) • End-to-End connection set up. Guarantees every message sent is received • Examples: FTP, Web (HTTP), NFS • Requirements: At most one message delivery, FIFO order, Security • Connectionless (Message Stream) • No explicit connection set up before sending messages • No effort to check if receiver receives the sent message • Examples: On-demand video, Video conferencing • Requirements: One/two-way traffic, Bulk data transfer: 60Mbps, Some data may be dropped off, FIFO order in most cases, Security CSS 432

  17. Network Architecture: Layering • Blue print for designing network • OSI – 7 layer • Internet architecture • Abstraction: hide complexity • Layering: decompose problems, modular design Application programs Connection-Oriented Connectionless Process to Process channels channel channel Host-to-host connectivity Hardware Example of a layered network system CSS 432

  18. Network Architecture: Layering • Alternative abstractions at each layer Application programs Connection-Oriented Connectionless channel channel Host-to-host connectivity Hardware Example of a layered network system CSS 432

  19. Protocols and Interfaces • Protocol: abstract objects that make up each layer • defines the interfaces between the layers in the same system and with the layers of peer system • Provides communication services that higher level objects can use • Each layer’s protocol has two different interfaces • service interface: communication services for objects of same computer • peer-to-peer interface: form and meaning of messages exchanged with peer (only direct at H/W level) CSS 432

  20. Host 1 Host2 Service High-level High-level interface object object Protocol Protocol Peer-to-peer interface Protocols and Interfaces Protocol Graph Service and Peer Interfaces • Protocol Graph: • Hardware level: peers communicate directly • Other levels: Protocol communicated with peer by passing message to lower level protocol that delivers message to peer • Each level can have multiple protocols: RRP – Request Reply Protocol, MSP- Message Stream Protocol, HHP- Host to Host Protocol • Nodes: Protocol, Edges: Depends on CSS 432

  21. End host End host Application Application Presentation Presentation Session Session Transport Transport Network Network Network Network Data link Data link Data link Data link Physical Physical Physical Physical One or more nodes within the network OSI Architecture (Open System Interconnection) User interact with application Data Format to be used (32 vs 64 bit conversion) Create sessions between hosts. Combines different transport streams of a single application. Audio and video stream of a video chat application can be combined Receives data from session, divides it into messages Divides messages into packets. Routing: Ensure packets reach correct destination Divides packets into frames. Routing: Error free data transfer Actual physical transfer of raw bits

  22. OSI Architecture • Physical Layer • Handles the transmission of raw bits over a communication link • Data Link Layer • Collects a stream of bits into a larger aggregate called a frame • Network adaptor along with device driver in OS implement the protocol in this layer • Frames are actually delivered to hosts • Network Layer • Handles routing among nodes within a packet-switched network • Unit of data exchanged between nodes in this layer is called a packet The lower three layers are implemented on all network nodes CSS 432

  23. OSI Architecture • Transport Layer • Implements a process-to-process channel • Unit of data exchanges in this layer is called a message • Session Layer • Provides a name space that is used to tie together the potentially different transport streams that are part of a single application • controls connections (begin, terminate) • Presentation Layer • Concerned about the format of data exchanged between peers • Application Layer • Standardize common type of exchanges • Interacts with user application The transport layer and the higher layers typically run only on end-hosts and not on the intermediate switches and routers CSS 432

  24. Internet (TCP/IP) Architecture • 4 layer model • Defined by Internet Engineering Task Force (IETF) • Does not imply strict layering. The application is free to bypass the defined transport layers and to directly use IP or other underlying networks • Subnetwork: network protocols mainly for sending and receiving data (combination of physical, data link layer) • IP Internet Protocol: Interconnection of different networks. Addressing, Routing, fragmentation (Network Layer) • TCP, UPD : Transport layer protocols • Application Layer: Interacts with user application

  25. FTP HTTP NV TFTP Netscape, IE, Mosaic, etc. UDP TCP IP … NET NET NET 2 1 n -Focal point for the architecture -common method of exchanging packets across networks Internet Architecture • Hourglass Design: wide at the top, narrow in the middle and wide at the bottom. IP serves as the focal point for the architecture • Application vs Application Protocol (FTP, HTTP) Reliable byte-stream channel Unreliable datagram delivery Internet Protocol Ethernet, FDDI, etc. CSS 432

  26. Performance • Bandwidth • Width of the frequency band • # of bits per second that can be transmitted over a communication link • 1 Mbps: 1 x 106 bits/second • 1 x 10-6 seconds to transmit each bit • each bit occupies a 1 microsecond slot • 2 Mbps • each bit occupies a 0.5 microsecond slot • Larger bandwidth  smaller width more will be transmitted per unit time

  27. Bandwidth Bits transmitted at a particular bandwidth can be regarded as having some width: (a) bits transmitted at 1Mbps (each bit 1 μs wide); (b) bits transmitted at 2Mbps (each bit 0.5 μs wide).

  28. Performance Metrics CSS 432

  29. Performance Metrics • Calculate the latency (from first bit sent to last bit received) for100-Mbps Ethernet with a single store-and-forward switch in the path and a packet size of 12,000 bits. Assume that each link introduces a propagation delay of 10 μs and that the switch begins retransmitting immediately after it has finished receiving the packet. • First answer (0.02) extra credits added to discussion scores CSS 432

  30. Delay x Bandwidth Product • We think the channel between a pair of processes as a hollow pipe • Latency (delay) length of the pipe and bandwidth the width of the pipe • Amount of data “in flight” or “in the pipe” • Example: 100ms x 45Mbps = 560KB CSS 432

  31. Delay x Bandwidth Product • Fully utilize the network: Sender can transmit Delay × bandwidth bits before the first bit arrives at the receiver • If the sender waits for a signal from receiver that it has started to receive, then sender can transmit one more Delay × bandwidth bits • Totally the sender can transmit • 2 x Delay x Bandwidth = RTT x Bandwidth • Receiver must prepare a buffer whose size is at least 2 x Delay x Bandwidth CSS 432

  32. Delay x Bandwidth Product • Relative importance of bandwidth and latency depends on application • For large file transfer, bandwidth is critical • For small messages (HTTP, NFS, etc.), latency is critical • Variance in latency (jitter) can also affect some applications (e.g., audio/video conferencing) • High speed networks with high bandwidth RTT dominates CSS 432

  33. Bandwidth vs Throughput • Bandwidth Vs throughput • Bandwidth: (Max) number of bits that can be transmitted per time unit over a communication link • Throughput: actual number of bits transmitted per unit time CSS 432

  34. Bandwidth vs Throughput • Thoughput (Actual Bandwidth)= Size / Latency • Latency = Propagation delay + transmit time+ queuing delay • Sometimes, one requests data after which it is sent • Latency = 2*propagation delay + transmit time + queuing delay • Latency = RTT + size/bandwidth + queuing delay, if RTT = 2*propagation delay • Latency = RTT + size/bandwidth, if queuing delay=0 • RTT: accounts for request to send data and data sent back • Example: • 1-MB file across a 1-Gbps network with RTT=100ms. • Request data and then send • 1MB / 1Gbps = 8Mb / 1000Mbps = 8msec • Time = 100 + 8 = 108msec • Thoughput = 1MB / 108msec = 74.1 Mbps CSS 432

  35. Network Programming • Interfaces provided by the OS (they already have traditional network protocols implemented) to the networking subsystem • Network programming application interface (API) • Each protocol provides a certain set of services, and the API provides a syntax by which those services can be invoked in this particular OS • Socket Interface was originally provided by the Berkeley distribution of Unix - Now supported in virtually all operating systems CSS 432

  36. Socket • What is a socket? • End point of Communication (IP address + Port) • The point where a local application process attaches to the network • IP address: address of network adapter • Port: 16 bit unsigned integer (0-65535) • Lower numbers (<=1024) are standard services (21-FTP) • >5000 is available to be used • Identify particular process of the host (Host can run many processes) • An application creates the socket CSS 432

  37. Socket • The Socket interface defines operations for • Creating a socket • Attaching a socket to the network • Sending and receiving messages through the socket • Closing the socket • Refer Linux Man Pages or https://linux.die.net/man/2/ for the signature of the functions used in socket programming CSS 432

  38. Socket • Socket Family/ Communication Domain • PF_INET denotes the Internet family • Communication between remote hosts • PF_UNIX denotes the Unix pipe facility • Communication between process in local host • PF_PACKET denotes direct access to the network interface (i.e., it bypasses the TCP/IP protocol stack) • Socket Type • SOCK_STREAM is used to denote a byte stream (TCP) • SOCK_DGRAM is an alternative that denotes a message oriented service, such as that provided by UDP CSS 432

  39. Creating a Socket int sockfd = socket(address_family, type, protocol); • The socket number returned is the socket descriptor for the newly created socket • int sockfd = socket (PF_INET, SOCK_STREAM, 0); • int sockfd = socket (PF_INET, SOCK_DGRAM, 0); The combination of PF_INET and SOCK_STREAM implies TCP CSS 432

  40. Client-Serve Model with TCP • Server • Passive open • Prepares to accept connection, does not actually establish a connection • Server invokes int bind (int socket, struct sockaddr *address, int addr_len) int listen (int socket, int backlog) int accept (int socket, struct sockaddr *address,int *addr_len) struct sockaddr_in { short sin_family; // e.g. AF_INET unsigned short sin_port; // e.g. htons(3490) struct in_addr sin_addr; // IP internet address char sin_zero[8]; // zero this if needed }; struct in_addr { unsigned long s_addr; // load with inet_aton() // convert IP addr to binary }; Use htons(3490) while specifying port number. Sync byte ordering between network protocol and host. (Order of storing lower order byte and higher order byte) CSS 432

  41. Client-Serve Model with TCP • Bind • Binds the newly created socket to the specified address i.e. the network address of the local participant (the server) • Address is a data structure which combines IP and port • Listen • Defines how many connections can be pending on the specified socket • Accept • Carries out the passive open • Blocking operation • Does not return until a remote participant has established a connection • When it does, it returns a new socket that corresponds to the new established connection and the address argument contains the remote participant’s address CSS 432

  42. Client-Serve Model with TCP • Client • Application performs active open • It says who it wants to communicate with • Creates Socket • No explicit bind. The kernel binds the socket with the available port number during connect • Client invokes int connect (int socket, struct sockaddr *address,intaddr_len) • Connect Does not return until TCP has successfully established a connection at which application is free to begin sending data • Address contains remote machine’s address (server address and port) • The client usually specifies only remote participant’s address and let’s the system fill in the local information • Whereas a server usually listens for messages on a well-known port • A client does not care which port it uses for itself, the OS simply selects an unused one CSS 432

  43. Client-Serve Model with TCP Once a connection is established, the application process invokes two operation • read(int socket, void *buf, size_t count); • read count bytes from socket into buf • write(int socket, const void *buf, size_t count) • writes count bytes from buf to socket • readv(int socket, const struct iovec *iov, int iovcnt); • (batch read) reads iovcnt number of buffers from the socket into iov • writev(int socket, const struct iovec *iov, int iovcnt) • (batch write) writes iovcnt number of buffers from iov to socket struct iovec { ptr_t iov_base; /* Starting address */ size_t iov_len; /* Length in bytes */ }; each iovec entry specifies the base address and length of an area in memory from which data should be written/read iov points to an array of iovec structures of size iovcnt CSS 432

  44. Active Open (Client) Connectionless: UDP (SOCK_DGRAM) bind( int sd, struct sockaddr *name, socklen_t namelen ); sendto( sd, buf, sizeof( buf ), flag, struct sockaddr *name, socklen_t namelen ); recvfrom( sd, buf, sizeof( buf ), flag, struct sockaddr *addr, socketlen_t, *addrlen ); Connection-oriented: TCP (SOCK_STREAM) connect( int sd, struct sockaddr *name, socklen_t namelen ) write( sd, buf, sizeof( buf ) ); writev( sd, struct iovec *iov, int iovcnt ); read( sd, buf, sizeof( buf ) ); Passive Open (Server) Connectionless: UDP (SOCK_DGRAM) bind( int sd, struct sockaddr *name, socklen_t namelen ); recvfrom( sd, buf, sizeof( buf ), flag, struct sockaddr *addr, socketlen_t, *addrlen ); sendto( sd, buf, sizeof( buf ), flag, struct sockaddr *name, socklen_t namelen ); Connection-oriented: TCP (SOCK_STREAM) bind( int sd, struct sockaddr *name, socklen_t namelen ); listen( sd, 5 ); accept( sd, struct sockaddr *addr, socket_t *addrlen ); read( sd, buf, sizeof( buf ) ); readv( std, struct iovec *iov, int iovcnt) write( sd, buf, sizeof( buf ) ); Network Programming: Socket API • Creating a socket: int socket(int domain, int type, int protocol) • domain =PF_INET, PF_UNIX • type = SOCK_STREAM, SOCK_DGRAM packets Connection request Stream data HW1 uses these. • close (int sd) CSS 432

  45. Sockets (TCP Example) SERVER: int sd, newSd; sd = socket(AF_INET, SOCK_STREAM, 0); CLIENT: int sd = socket(AF_INET, SOCK_STREAM, 0); returns the ipadress of the server name you send Hostent structure (mapping between host name and address) Fill with zeros sockaddr_in server; bzero( (char *)&server, sizeof( server ) ); server.sin_family =AF_INET; server.sin_addr.s_addr = htonl( INADDR_ANY ) server.sin_port = htons( 12345 ); bind( sd, (sockaddr *)&server, sizeof( server ) ); struct hostent *host = gethostbyname( arg[0] ); sockaddr_in server; bzero( (char *)&server, sizeof( server ) ); server.sin_family = AF_INET; server.s_addr = inet_addr( inet_ntoa( *(struct in_addr*)*host->h_addr_list ) ); server.sin_port = htons( 12345 ); listen( sd, 5 ); connect( sd, (sockaddr *)&server, sizeof( server ) ); Creates a new socket newsd for specific client; Multiple clients can connect to server sockaddr_in client; socklen_t len=sizeof(client); while( true ) { newSd = accept(sd, (sockaddr *)&client, &len); Create a new child process, handling specific client at newsd Close the generic socketsd, use specific socket newsd write( sd, buf1, sizeof( buf ) ); write( sd, buf2, sizeof( buf ) ); if ( fork( ) == 0 ) { close( sd ); read( newSd, buf1, sizeof( buf1 ) ); read( newSd, buf2, sizeof( buf2 ) ); } close( newSd ); } The parent process closes the client specific newsd and accepts connection from other clients using sd close( newsd); exit( 0 ); CSS 432

  46. socket() socket() socket() bind() listen() connect() connect() accept() write() write() buf2, buf1 buf2, buf1 read() read() Sockets (Code Example) int sd, newSd; sd = socket(AF_INET, SOCK_STREAM, 0); int sd = socket(AF_INET, SOCK_STREAM, 0); sockaddr_in server; bzero( (char *)&server, sizeof( server ) ); server.sin_family =AF_INET; server.sin_addr.s_addr = htonl( INADDR_ANY ) server.sin_port = htons( 12345 ); bind( sd, (sockaddr *)&server, sizeof( server ) ); struct hostent *host = gethostbyname( arg[0] ); sockaddr_in server; bzero( (char *)&server, sizeof( server ) ); server.sin_family = AF_INET; server.s_addr = inet_addr( inet_ntoa( *(struct in_addr*)*host->h_addr_list ) ); server.sin_port = htons( 12345 ); listen( sd, 5 ); connect( sd, (sockaddr *)&server, sizeof( server ) ); sockaddr_in client; socklen_t len=sizeof(client); while( true ) { newSd = accept(sd, (sockaddr *)&client, &len); write( sd, buf1, sizeof( buf ) ); write( sd, buf2, sizeof( buf ) ); if ( fork( ) == 0 ) { close( sd ); read( newSd, buf1, sizeof( buf1 ) ); read( newSd, buf2, sizeof( buf2 ) ); } close( newSd ); } close( newsd); exit( 0 ); CSS 432

  47. Active Open (Client) connect( int sd, struct sockaddr *name, socklen_t namelen ) Passive Open (Server) bind( int sd, struct sockaddr *name, socklen_t namelen ); listen( sd, 5 ); accept( sd, struct sockaddr *addr, socket_t *addrlen ); file Socket data structure Socket data structure Socket data structure type type type protocol protocol protocol so_pcb so_pcb so_pcb 0 0 so_rcv so_rcv so_rcv 1 1 so_snd so_snd so_snd 2 2 3 3 4 4 File structure table User file descriptor table User file descriptor table File structure table l_addr l_port f_addr f_port socket inpcb: Internet protocol control block Socket Implementation • Creating a socket: int socket(int domain, int type, int protocol) • domain =PF_INET, PF_UNIX • type = SOCK_STREAM, SOCK_DGRAM Represents the file: file attributes, location inode Client process Server process int fd = open( “fileA”, O_RDONLY, 0 ); Type, protocol, pcb, buffers Newly created socket for specific client file descriptors provide index of resource (file, socket) on the file table packet copied copied packet packet packet packet packet Pcb – ipaddress, ports of the hosts DLL: points back to socket l_addr l_port inpcb: Internet protocol control block f_addr f_port CSS 432 socket

  48. write/read Send and receive a message in buf writev/readv Gather and scatter messages in a single pair of writev/readv Blocking write/read Write( ) is blocked (does not return) until a message is sent. Send atleast a byte Read( ) is blocked until a message is received Non-blocking Write( ) returns when empty Read( ) returns null without waiting for a message. TCP Communication default Memory buffers Buffer descriptor list 100 1400 1500 CSS 432 1500

  49. Non-Blocking CommunicationC/C++ Example • To change the blocking to non blocking change the flags of the socket • set_fl(sd, O_NONBLOCK); • Polling • Periodically check if a socket is ready to read data • Example: sd = socket( AF_INET, SOCKET_STREAM, 0); set_fl(sd, O_NONBLOCK); // set the socket as non-blocking struct pollfd pfd; pfd.fd = sd; poll( &pfd, 1, timeout ) // poll the socket status int poll(struct pollfd *fds, nfds_t nfds, int timeout) : Returns number of filedescriptors/sockets with occurred events; blocks till timeout, returns -1 if error fds -> set of sockets to be monitored, nfds - number of sockets struct pollfd { int fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ }; Events: POLLIN (data is present to read), POLL OUT (data is present to write) CSS 432

  50. Non-Blocking CommunicationC/C++ Example • Interrupt (an interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention) • Notified from the system when a socket is ready to read data; • Example: sd = socket(AF_INET, SOCKET_STREAM, 0); signal(SIGIO, sigio_func); // set a future interrupt to call sigio_func( ) fcntl(sd, F_SETOWN, getpid( )); // ask OS to deliver this interrupt to me fcntl(sd, F_SETFL, FASYNC); // set flag asynchronous int sigio_func( ) { // invoked upon an interrupt } SIGIO: this interrupt signal is sent when a file descriptor is ready to perform input or output. Fcntl (set the flags for the socket sd) F_setown: for events on file descriptor sd, interrupt me i.e., getpid() F_SETFL : set the file status flags to the value specified by arg FASYNC FASYNC: runs in background, enables generation of signals when event occurs CSS 432

More Related