shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

Similar documents
Interprocess Communication Mechanisms

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms

Transport Layer (TCP/UDP)

Sockets Sockets Communication domains

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

A Client-Server Exchange

Sockets 15H2. Inshik Song

ECE 650 Systems Programming & Engineering. Spring 2018

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

Network Implementation

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

Group-A Assignment No. 6

Overview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions

Transport Layer Review

Outline. Inter-Process Communication. IPC across machines: Problems. CSCI 4061 Introduction to Operating Systems

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

We will cover in this order: 2.1, 2.7, 2.5, 2.4, 2.2

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

Chapter 8: I/O functions & socket options

Oral. Total. Dated Sign (2) (5) (3) (2)

9th Slide Set Computer Networks

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Motivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?!

7. TCP 최양희서울대학교컴퓨터공학부

Chapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control

CS631 - Advanced Programming in the UNIX Environment Interprocess Communication II

Internet and Intranet Protocols and Applications

Interprocess Communication

Application Programming Interfaces

05 Transmission Control Protocol (TCP)

Network Programming. Introduction to Sockets. Dr. Thaier Hayajneh. Process Layer. Network Layer. Berkeley API

(Refer Slide Time: 1:09)

QUIZ: Longest Matching Prefix

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

Connections. Topics. Focus. Presentation Session. Application. Data Link. Transport. Physical. Network

Connection-oriented (virtual circuit) Reliable Transfer Buffered Transfer Unstructured Stream Full Duplex Point-to-point Connection End-to-end service

Distributed Systems. 02. Networking. Paul Krzyzanowski. Rutgers University. Fall 2017

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

CSE 461 The Transport Layer

CSE 461 Connections. David Wetherall

NT1210 Introduction to Networking. Unit 10

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

Ports under 1024 are often considered special, and usually require special OS privileges to use.

CSCE 463/612 Networks and Distributed Processing Spring 2018

CSEP 561 Connections. David Wetherall

Network Protocols - Revision

Other Interprocess communication (Chapter 2.3.8, Tanenbaum)

Server algorithms and their design

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Lecture 13: Transportation layer

TSIN02 - Internetworking

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

OSI Transport Layer. objectives

ECE 650 Systems Programming & Engineering. Spring 2018

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Transport Layer. The transport layer is responsible for the delivery of a message from one process to another. RSManiaol

Introduction. Interprocess communication. Terminology. Shared Memory versus Message Passing

System Programming. Introduction to computer networks

Transport layer Internet layer

Workshop on Inter Process Communication Solutions

Operating Systems. 17. Sockets. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

TCP /IP Fundamentals Mr. Cantu

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

The Transmission Control Protocol (TCP)

The Fundamentals. Port Assignments. Common Protocols. Data Encapsulation. Protocol Communication. Tevfik Ko!ar

CSEP 561 Connections. David Wetherall

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Lecture 11: IP routing, IP protocols

Computer Communication Networks Socket Programming

Interprocess Communication

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

JAVA SOCKET PROGRAMMING

Elementary TCP Sockets

Network Communication

Tutorial on Socket Programming

6. The Transport Layer and protocols

Different Layers Lecture 21

Distributed Real-Time Control Systems. Module 26 Sockets

CS 351 Week 15. Course Review

User Datagram Protocol

ECE 333: Introduction to Communication Networks Fall 2002

Chapter 11. Application-Layer Elements Ports

Operating Systems. 16. Networking. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

CMPE 80N: Introduction to Networking and the Internet

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

CS321: Computer Networks Introduction to Application Layer

UNIT 2 TRANSPORT LAYER

Data Communication & Computer Networks MCQ S

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

EECS122 Communications Networks Socket Programming. Jörn Altmann

4. The transport layer

CS 428/528 Computer Networks Lecture 01. Yan Wang

UDP. Networked Systems (H) Lecture 15

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Transcription:

Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name (e.g., a file name, or a shared virtual memory key) in order to establish communication message based signals sockets pipes... Interprocess Communication 2 Message Passing Indirect Message Passing operating system sender send receive receiver operating system sender send receive receiver Direct Message Passing If message passing is indirect, the message passing system must have some capacity to buffer (store) messages.

Interprocess Communication 3 Properties of Message Passing Mechanisms Addressing: how to identify where a message should go Directionality: simplex (one-way) duplex (two-way) half-duplex (two-way, but only one way at a time) Message Boundaries: datagram model: message boundaries stream model: no boundaries Interprocess Communication 4 Properties of Message Passing Mechanisms (cont d) Connections: need to connect before communicating? in connection-oriented models, recipient is specified at time of connection, not by individual send operations. All messages sent over a connection have the same recipient. in connectionless models, recipient is specified as a parameter to each send operation. Reliability: can messages get lost? can messages get reordered? can messages get damaged?

Interprocess Communication 5 Sockets a socket is a communication end-point if two processes are to communicate, each process must create its own socket two common types of sockets stream sockets: support connection-oriented, reliable, duplex communication under the stream model (no message boundaries) datagram sockets: support connectionless, best-effort (unreliable), duplex communication under the datagram model (message boundaries) both types of sockets also support a variety of address domains, e.g., Unix domain: useful for communication between processes running on the same machine INET domain: useful for communication between process running on different machines that can communicate using IP protocols. Interprocess Communication 6 Using Datagram Sockets (Receiver) s = socket(addresstype, SOCK_DGRAM); bind(s,address); recvfrom(s,buf,buflength,sourceaddress);... close(s); socket creates a socket bind assigns an address to the socket recvfrom receives a message from the socket buf is a buffer to hold the incoming message sourceaddress is a buffer to hold the address of the message sender both buf and sourceaddress are filled by the recvfrom call

Interprocess Communication 7 Using Datagram Sockets (Sender) s = socket(addresstype, SOCK_DGRAM); sendto(s,buf,msglength,targetaddress)... close(s); socket creates a socket sendto sends a message using the socket buf is a buffer that contains the message to be sent msglength indicates the length of the message in the buffer targetaddress is the address of the socket to which the message is to be delivered Interprocess Communication 8 More on Datagram Sockets sendto and recvfrom calls may block recvfrom blocks if there are no messages to be received from the specified socket sendto blocks if the system has no more room to buffer undelivered messages datagram socket communications are (in general) unreliable messages (datagrams) may be lost messages may be reordered The sending process must know the address of the receive process s socket. How does it know this?

Interprocess Communication 9 A Socket Address Convention Service Port Description ------------------------------------------------------- echo 7/udp systat 11/tcp netstat 15/tcp chargen 19/udp ftp 21/tcp ssh 22/tcp # SSH Remote Login Protocol telnet 23/tcp smtp 25/tcp time 37/udp gopher 70/tcp # Internet Gopher finger 79/tcp www 80/tcp # WorldWideWeb HTTP pop2 109/tcp # POP version 2 imap2 143/tcp # IMAP Interprocess Communication 10 Using Stream Sockets (Passive Process) s = socket(addresstype, SOCK_STREAM); bind(s,address); listen(s,backlog); ns = accept(s,sourceaddress); recv(ns,buf,buflength); send(ns,buf,buflength);... close(ns); // close accepted connection close(s); // don t accept more connections listen specifies the number of connection requests for this socket that will be queued by the kernel accept accepts a connection request and creates a new socket (ns) recv receives up to buflength bytes of data from the connection send sends buflength bytes of data over the connection.

Interprocess Communication 11 Notes on Using Stream Sockets (Passive Process) accept creates a new socket (ns) for the new connection sourceaddress is an address buffer. accept fills it with the address of the socket that has made the connection request additional connection requests can be accepted using more accept calls on the original socket (s) accept blocks if there are no pending connection requests connection is duplex (both send and recv can be used) Interprocess Communication 12 Using Stream Sockets (Active Process) s = socket(addresstype, SOCK_STREAM); connect(s,targetaddress); send(s,buf,buflength); recv(s,buf,buflength);... close(s); connect sends a connection request to the socket with the specified address connect blocks until the connection request has been accepted active process may (optionally) bind an address to the socket (using bind) before connecting. This is the address that will be returned by the accept call in the passive process if the active process does not choose an address, the system will choose one

Interprocess Communication 13 Illustration of Stream Socket Connections s socket queue of connection requests s s2 s3 process 1 process 2 (active) (passive) process 3 (active) Interprocess Communication 14 Pipes pipes are communication objects (not end-points) pipes use the stream model and are connection-oriented and reliable some pipes are simplex, some are duplex pipes use an implicit addressing mechanism that limits their use to communication between related processes, typically a child process and its parent a pipe() system call creates a pipe and returns two descriptors, one for each end of the pipe for a simplex pipe, one descriptor is for reading, the other is for writing for a duplex pipe, both descriptors can be used for reading and writing

Interprocess Communication 15 One-way Child/Parent Communication Using a Simplex Pipe int fd[2]; char m[] = "message for parent"; char y[100]; pipe(fd); // create pipe pid = fork(); // create child process if (pid == 0) { // child executes this close(fd[0]); // close read end of pipe write(fd[1],m,19);... } else { // parent executes this close(fd[1]); // close write end of pipe read(fd[0],y,100);... } Interprocess Communication 16 Illustration of Example (after pipe()) parent process

Interprocess Communication 17 Illustration of Example (after fork()) parent process child process Interprocess Communication 18 Illustration of Example (after close()) parent process child process

Interprocess Communication 19 Examples of Other Interprocess Communication Mechanisms named pipe: similar to pipes, but with an associated name (usually a file name) name allows arbitrary processes to communicate by opening the same named pipe must be explicitly deleted, unlike an unnamed pipe message queue: like a named pipe, except that there are message boundaries msgsend call sends a message into the queue, msgrecv call receives the next message from the queue Interprocess Communication 20 Signals signals permit asynchronous one-way communication from a process to another process, or to a group of processes, via the kernel from the kernel to a process, or to a group of processes there are many types of signals the arrival of a signal may cause the execution of a signal handler in the receiving process there may be a different handler for each type of signal

Interprocess Communication 21 Examples of Signal Types Signal Value Action Comment ------------------------------------------------- SIGINT 2 Term Interrupt from keyboard SIGILL 4 Core Illegal Instruction SIGKILL 9 Term Kill signal SIGCHLD 20,17,18 Ign Child stopped or terminated SIGBUS 10,7,10 Core Bus error SIGXCPU 24,24,30 Core CPU time limit exceeded SIGSTOP 17,19,23 Stop Stop process Interprocess Communication 22 Signal Handling operating system determines default signal handling for each new process example default actions: ignore (do nothing) kill (terminate the process) stop (block the process) a running process can change the default for some types of signals signal-related system calls calls to set non-default signal handlers, e.g., Unix signal, sigaction calls to send signals, e.g., Unix kill

Interprocess Communication 23 Implementing IPC application processes use descriptors (identifiers) provided by the kernel to refer to specific sockets and pipes, as well as files and other objects kernel descriptor tables (or other similar mechanism) are used to associate descriptors with kernel data structures that implement IPC objects kernel provides bounded buffer space for data that has been sent using an IPC mechanism, but that has not yet been received for IPC objects, like pipes, buffering is usually on a per object basis IPC end points, like sockets, buffering is associated with each endpoint P1 P2 system call interface buffer operating system system call interface Interprocess Communication 24 Network Interprocess Communication some sockets can be used to connect processes that are running on different machines the kernel: controls access to network interfaces multiplexes socket connections across the network P1 P2 P3 P1 P2 P3 operating system network interface network interface operating system network

Interprocess Communication 25 ISO/OSI Reference Model Networking Reference Models 7 Application Layer 6 Presentation Layer 5 Session Layer 4 Transport Layer 3 Network Layer 2 Data Link Layer 1 Physical Layer layer N+1 service layer N+1 protocol Layer N+1 Layer N+1 layer N service layer N protocol Layer N Layer N layer 1 protocol Layer 1 Layer 1 Internet Model layers 1-4 and 7 Interprocess Communication 26 Internet Protocol (IP): Layer 3 every machine has one (or more) IP address, in addition to its data link layer address(es) In IPv4, addresses are 32 bits, and are commonly written using dot notation, e.g.: cpu06.student.cs = 129.97.152.106 www.google.ca = 216.239.37.99 or 216.239.51.104 or... IP moves packets (datagrams) from one machine to another machine principal function of IP is routing: determining the network path that a packet should take to reach its destination IP packet delivery is best effort (unreliable)

Interprocess Communication 27 IP Routing Table Example Routing table for zonker.uwaterloo.ca, which is on three networks, and has IP addresses 129.97.74.66, 172.16.162.1, and 192.168.148.1 (one per network): Destination Gateway Interface routing table key: 172.16.162.* - vmnet1 129.97.74.* - eth0 192.168.148.* - vmnet8 default 129.97.74.1 eth0 destination: ultimate destination of packet gateway: next hop towards destination (or - if destination is directly reachable) interface: which network interface to use to send this packet Interprocess Communication 28 Internet Transport Protocols TCP: transport control protocol connection-oriented reliable stream congestion control used to implement INET domain stream sockets UDP: user datagram protocol connectionless unreliable datagram no congestion control used to implement INET domain datagram sockets

Interprocess Communication 29 TCP and UDP Ports since there can be many TCP or UDP communications end points (sockets) on a single machine, there must be a way to distinguish among them each TCP or UDP address can be thought of as having two parts: (machine name, port number) The machine name is the IP address of a machine, and the port number serves to distinguish among the end points on that machine. INET domain socket addresses are TCP or UDP addresses (depending on whether the socket is a stream socket or a datagram socket). Interprocess Communication 30 Example of Network Layers Application Process Application Process Transport Transport Network Network Network Network Data Link Data Link Data Link Data Link network network network gateways

Interprocess Communication 31 Network Packets (UDP Example) UDP header application message UDP payload application message IP payload IP Header UDP header application message Data Link Payload Data Link Header IP Header UDP header application message Interprocess Communication 32 BSD Unix Networking Layers process system calls socket layer socket queues protocol layer (TCP,UDP,IP,...) interface queues (IP) protocol queue interface layer (ethernet,ppp,loopback,...) network device network device network device