Process Communication COMPUTER NETWORKING Part 1 Fundamentals and

  • Slides: 32
Download presentation
Process Communication COMPUTER NETWORKING Part 1 Fundamentals and Grand Tour of Computer Networking Thanks

Process Communication COMPUTER NETWORKING Part 1 Fundamentals and Grand Tour of Computer Networking Thanks to the authors of the textbook [KR] for providing the base slides. I made several changes/additions. These slides may incorporate materials kindly provided by Prof. Dakai Zhu. So I would like to thank him, too. Turgay Korkmaz korkmaz@cs. utsa. edu Distributed Systems 1. 1 TS

Computer Networking n Layered Protocols n Grand tour of computer networking, the Internet n

Computer Networking n Layered Protocols n Grand tour of computer networking, the Internet n Client-server paradigm, n Socket Programming Distributed Systems 1. 2 (part 2) TS

Objectives n To understand how processes communicate (the heart of distributed systems) n To

Objectives n To understand how processes communicate (the heart of distributed systems) n To understand computer networks and their layers n To understand client-server paradigm and low- level message passing using sockets Distributed Systems 1. 3 TS

Fundamental Problem How can two processes A and B communicate? B A OS Send

Fundamental Problem How can two processes A and B communicate? B A OS Send messages A B Logical link OS OS network n Many different agreements (protocols) are needed at various layers. A protocol specifies format, order, actions n Application-layer protocols l Bit representation to meaning of each message n Other-layers and protocols How to actually transmit messages through a network l Addressing, performance, scalability, reliability, security l Distributed Systems 1. 4 TS

Client-Server Paradigm n Many applications (http, ftp, Process: program running within a host. rlogin,

Client-Server Paradigm n Many applications (http, ftp, Process: program running within a host. rlogin, e-mail, web) use the client-server model n Within the same host, two Client process: a process that initiates communication processes communicate using inter-process communication (e. g. , shared Server process: a process that waits to be contacted memory, pipe, FIFO, signal defined by OS). n processes (applications) in different hosts communicate by exchanging messages using transport layer Distributed Systems r Note: applications with P 2 P architectures have client processes & server processes 1. 5 From Computer Networking. TS by Kurose and Ross.

What’s Network (the Internet)? To learn more, take CS 3783 network n Network of

What’s Network (the Internet)? To learn more, take CS 3783 network n Network of networks connecting millions of devices: l Hosts (end systems) l Links (e. g. , cable, fiber, wireless) l Routers and Switches n Collection of protocols providing communication services to distributed applications n Networks are complex! l How can we deal with complexity? l Modular design, layering! Distributed Systems 1. 6 From Computer Networking. TS by Kurose and Ross.

Internet protocol stack n application: Protocols that are designed to meet the communication requirements

Internet protocol stack n application: Protocols that are designed to meet the communication requirements of specific applications, often defining the interface to a service. (FTP, SMTP, HTTP) n transport: process-to-process data transfer (TCP, UDP) n network: routing of datagrams from source to destination (IP, OSPF, BGP) application transport network link n link: data transfer between neighboring network elements (PPP, Ethernet) physical n physical: transmission of bits on a link (electrical signals on cable, light signals on fibre or other electromagnetic signals on radio) Distributed Systems 1. 7 From Computer Networking. TS by Kurose and Ross.

ISO/OSI reference model n presentation: allow applications to interpret meaning of data, e. g.

ISO/OSI reference model n presentation: allow applications to interpret meaning of data, e. g. , encryption, compression, machine-specific conventions l Data can be represented differently on different machine architectures (e. g. , little-endian vs. bigendian). So, when transmitting data between different machines, sender and receiver must use XDR (external data representation) which represents data independently of machine architecture. n session: synchronization, check pointing, recovery of data exchange n Internet stack “missing” these layers! l application presentation session transport network link physical these services, if needed, must be implemented in application Distributed Systems 1. 8 From Computer Networking. TS by Kurose and Ross.

Why layering? n Explicit structure allows identification of complex pieces n Each layer l

Why layering? n Explicit structure allows identification of complex pieces n Each layer l gets a service from the one below, l performs a specific task, and l provides a service to the one above n Modularization eases maintenance and updating of system l We can change the implementation of a layer without affecting the rest of the system as long as the interfaces between the layers are kept the same! n In some cases, layering considered harmful! Why? Distributed Systems 1. 9 From Computer Networking. TS by Kurose and Ross.

transport As a programmer, how can we use all these layers to send data

transport As a programmer, how can we use all these layers to send data from process A to process B through a network? network SOCKETS network link API, an interface, gate, door between a process (application) and transport layer link application physical application transport physical network Distributed Systems 1. 10 From Computer Networking. TS by Kurose and Ross.

Addressing processes n to receive messages, process must have a unique identifier n host

Addressing processes n to receive messages, process must have a unique identifier n host device has unique 32 -bit IP address B C OS OS network n identifier includes both IP address and port number associated with the process n What is a port number? n Q: does IP address of host on which process runs suffice for identifying the process? l A l 16 bits integer used by transport layer to identify end points (processes) on a host l well-known ports: 1 – 1023 Telnet 23; FTP 21; HTTP 80 A: No, many processes can be running on the same host l registered ports: 1024 – 49151 l dynamic or private ports: 49152 - 65535 To communicate, client must know the server’s IP address, and port number. How will the server know the client’s IP address and port number? Distributed Systems 1. 11 From Computer Networking. TS by Kurose and Ross.

Encapsulation source M message segment Ht M datagram Hn Ht M frame Hl Hn

Encapsulation source M message segment Ht M datagram Hn Ht M frame Hl Hn Ht M application transport network link physical switch destination M Ht M Hn Ht Hl Hn Ht M M Distributed Systems application transport network link physical Hn Ht Hl Hn Ht M M network link physical Hn Ht M router 1. 12 From Computer Networking. TS by Kurose and Ross.

Distributed Systems and Layer Structure Middleware layer (RPC, RMI) Socket common services and protocols

Distributed Systems and Layer Structure Middleware layer (RPC, RMI) Socket common services and protocols to many different applications TCP & UDP Higher-level app protocols communication facilities for most distributed systems IP Ethernet Distributed Systems 1. 13 Low-level Layers TS

ay s ill out w b g We re a n i t mo

ay s ill out w b g We re a n i t mo cke mm so ogra 2! pr part in Application Transport Network Link Physical But first let us review all the layers in a bottom-up fashion (more details are in CS 3873) GRAND TOUR OF COMPUTER NETWORKING Distributed Systems 1. 14 TS

Physical Layer OPT Transmission of bits on a link • electrical signals on cable,

Physical Layer OPT Transmission of bits on a link • electrical signals on cable, • light signals on fibre • electromagnetic signals on radio Distributed Systems 1. 15 From Computer Networking. TS by Kurose and Ross.

OPT Link Layer n Data transfer between neighboring network elements l host Link layer

OPT Link Layer n Data transfer between neighboring network elements l host Link layer services 4 Framing, error detection and correction… l Multiple access protocols l Link-layer Addressing l Ethernet l Link-layer switches l PPP application transport network link cpu memory controller link physical host bus (e. g. , PCI) physical transmission network adapter card datagram controller receiving host sending host datagram frame Distributed Systems 1. 16 From Computer Networking. TS by Kurose and Ross.

Network layer: IP Addressing n IP address: 32 -bit 223. 1. 1. 1 unique

Network layer: IP Addressing n IP address: 32 -bit 223. 1. 1. 1 unique identifier for host, router interface 223. 1. 1. 2 223. 1. 1. 4 n interface: connection between host/router and physical link l router’s typically have multiple interfaces l host typically has one interface l IP addresses associated with each interface l 223. 1. 1. 3 223. 1. 2. 9 223. 1. 3. 27 223. 1. 2. 2 223. 1 host part subnet part 223. 1. 1. 1 = 11011111 00000001 IP addresses on the same network should have the same prefix (net. ID) Distributed Systems 223. 1. 2. 1 223 1. 17 1 1 1 From Computer Networking. TS by Kurose and Ross.

Network layer: IP datagram format IP protocol version number header length (bytes) “type” of

Network layer: IP datagram format IP protocol version number header length (bytes) “type” of data max number remaining hops (decremented at each router) upper layer protocol to deliver payload to 32 bits total datagram length (bytes) ver head. type of len service length fragment 16 -bit identifier flgs offset time to upper header layer live checksum for fragmentation/ reassembly 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP or UDP segment) Distributed Systems OPT 1. 18 E. g. timestamp, record route taken, specify list of routers to visit. From Computer Networking. TS by Kurose and Ross.

OPT Network layer n Transports datagrams from n n sending host to receiving host

OPT Network layer n Transports datagrams from n n sending host to receiving host through the network [On sending side] : Takes segments from transport layer and encapsulates them into datagrams [On receiving side]: Extracts segments from datagrams and delivers them to transport layer Routers examine header fields in all IP datagrams and forwards it to next node How to know the next node? Distributed Systems 1. 19 application transport network data link physical network data link physical network data link physical application transport network data link physical From Computer Networking. TS by Kurose and Ross.

OPT Forwarding Problem: Where to Send Next? routing algorithm local forwarding table header value

OPT Forwarding Problem: Where to Send Next? routing algorithm local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 Destination address in arriving packet’s header 1 0111 3 2 How to automate this process and find the best paths? Distributed Systems 1. 20 From Computer Networking. TS by Kurose and Ross.

Network layer: putting togeter OPT Host, router network layer functions: Routing protocols • path

Network layer: putting togeter OPT Host, router network layer functions: Routing protocols • path selection • RIP, OSPF, BGP Network layer Transport layer: TCP, UDP IP protocol • addressing conventions • datagram format • packet handling conventions forwarding table ICMP protocol • error reporting • router “signaling” Link layer physical layer Distributed Systems 1. 21 From Computer Networking. TS by Kurose and Ross.

OPT IP addresses: how to get one? Q: How to get the (sub)network portion

OPT IP addresses: how to get one? Q: How to get the (sub)network portion of the address? Corporation for ISP's block 11001000 00010111 00010000 200. 23. 16. 0/20 A: ICANN: Internet Assigned Names and Numbers Organization 0 Organization 1 Organization 2. . . Organization 7 11001000 00010111 00010000 11001000 00010111 00010010 0000 11001000 00010111 00010100 0000 …. 11001000 00010111 00011110 0000 l allocates addresses, l manages DNS l assigns domain names, resolves disputes 200. 23. 16. 0/23 200. 23. 18. 0/23 200. 23. 20. 0/23 …. 200. 23. 30. 0/23 Q: Given the (sub)network portion, how to get host portion? A: Local network owner l hard-coded by system admin in a file 4 Windows: 4 UNIX: l control-panel->network->configuration->tcp/ip->properties /etc/rc. config DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server “plug-and-play” Distributed Systems 1. 22 From Computer Networking. TS by Kurose and Ross.

IP addressing OPT CIDR vs. Class-based addressing CIDR: Classless Inter. Domain Routing l subnet

IP addressing OPT CIDR vs. Class-based addressing CIDR: Classless Inter. Domain Routing l subnet portion of address of arbitrary length l address format: a. b. c. d/x, where x is # bits in subnet portion of address host part subnet part 11001000 00010111 00010000 200. 23. 16. 0/23 Distributed Systems 1. 23 From Computer Networking. TS by Kurose and Ross.

Transport Layer n provide logical communication between app processes running on different hosts lo

Transport Layer n provide logical communication between app processes running on different hosts lo ca gi n How to know which process? nd le n transport protocols run in end nd -e systems send side: breaks app messages into segments, passes to network layer or sp an tr l application transport network data link physical t application transport network data link physical l rcv side: reassembles segments into messages, passes to app layer n more than one transport protocol available to apps l Internet: TCP and UDP Distributed Systems 1. 24 From Computer Networking. TS by Kurose and Ross.

Transport Layer: port numbers 0 1 2 3 …. 0 x. FFFF * 32

Transport Layer: port numbers 0 1 2 3 …. 0 x. FFFF * 32 bits source port # length source port # dest port # checksum head len 0 dest port # sequence number ack number not used UA P R S F Receive window checksum Urg data pnter Options (variable length) Application data (message) UDP 1 2 Application data (variable length) TCP 3 …. 0 x. FFFF * Distributed Systems application transport network data link physical 1. 25 application transport network data link physical From Computer Networking. TS by Kurose and Ross.

Internet transport protocols services TCP service: UDP service: n connection-oriented: setup n unreliable data

Internet transport protocols services TCP service: UDP service: n connection-oriented: setup n unreliable data transfer required between client and server processes between sending and receiving process n reliable, in-order byte-stream n does not provide: transport between sending and receiving process connection setup, reliability, flow control, congestion control, timing, throughput guarantee, or security n flow control: sender won’t overwhelm receiver n congestion control: throttle sender when network overloaded n does not provide: timing, Q: why bother? Why is there a UDP? minimum throughput guarantees, security Distributed Systems 1. 26 From Computer Networking. TS by Kurose and Ross.

OPT UDP: User Datagram Protocol [RFC 768] n “no frills, ” “bare bones” Internet

OPT UDP: User Datagram Protocol [RFC 768] n “no frills, ” “bare bones” Internet transport protocol Why is there a UDP? n “best effort” service, UDP n no connection establishment segments may be: (which can add delay) l lost l delivered out of order to app n simple: no connection state n small segment header n connectionless: l l n no congestion control: UDP no handshaking between UDP sender, receiver each UDP segment handled independently of others Distributed Systems at sender, receiver 1. 27 can blast away as fast as desired From Computer Networking. TS by Kurose and Ross.

OPT UDP: more n often used for streaming 32 bits multimedia apps l loss

OPT UDP: more n often used for streaming 32 bits multimedia apps l loss tolerant l rate sensitive n other UDP uses l DNS l SNMP Length, in bytes of UDP segment, including header add reliability at application layer application-specific error recovery! Distributed Systems length dest port # checksum Application data (message) n reliable transfer over UDP: l source port # UDP segment format 1. 28 From Computer Networking. TS by Kurose and Ross.

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 n point-to-point: l n full duplex

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 n point-to-point: l n full duplex data: one sender, one receiver n reliable, in-order byte stream: l no “message boundaries” n pipelined: l l bi-directional data flow in same connection l MSS: maximum segment size n connection-oriented: l TCP congestion and flow control set window size n send & receive buffers handshaking (exchange of control msgs) init’s sender, receiver state before data exchange n flow controlled: l Distributed Systems 1. 29 sender will not overwhelm receiver From Computer Networking. TS by Kurose and Ross.

TCP segment structure OPT 32 bits URG: urgent data (generally not used) ACK: ACK

TCP segment structure OPT 32 bits URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP) Distributed Systems source port # dest port # sequence number acknowledgement number head len not used UA P RS F Receive window checksum Urg data pnter Options (variable length) counting by bytes of data (not segments!) # bytes rcvr willing to accept application data (variable length) 1. 30 From Computer Networking. TS by Kurose and Ross.

Application Layer www. someschool. edu/somedir/page. html n HTTP path name Server name Client TCP

Application Layer www. someschool. edu/somedir/page. html n HTTP path name Server name Client TCP port 80 Server GET /somedir/page. html HTTP/1. 1 Host: www. someschool. edu User-agent: Mozilla/4. 0 HTTP/1. 1 200 OK Connection: close Connection close Accept-language: eng Date: Thu, 06 Aug 1998 12: 00: 15 GMT Server: Apache/1. 3. 0 (Unix) (extra carriage return, line feed) Last-Modified: Mon, 22 Jun 1998 … Content-Length: 6821 Content-Type: text/html data data. . . Distributed Systems 1. 31 TS

fox 03> server port application Can we implement a web server and communicate with

fox 03> server port application Can we implement a web server and communicate with it using an existing browser? application transport network link physical SOCKET PROGRAMMING PART 2 link physical network Distributed Systems 1. 32 From Computer Networking. TS by Kurose and Ross.