Interprocess Communication
Prinsip berkomunikasi
Source S
generates data (text/binary) to be transmitted
Transmitter
Converts data into transmittable signals
Transmission System
Carries data
Ex: TCP/IP
Receiver
Converts C t received i d signal i li into t d data t
Destination
Takes incoming data
I t Interprocess Communication C i ti
Processes within a system may be independent or cooperating Process on different computer? Reasons for cooperating processes:
Information sharing Computation speedup Modularity Convenience
Communications in local
Karakteristik IPC
S Synchronization h i ti d dan Asynchronization A h i ti of f messages. Message destination : on Internet, using p address dan local port.
http://192.168.1.2:8081
Reliability data: validity dan integrity integrity. Ordering data: urutan paket yang dikirim Different data processing: g g marshalling/unmarshalling
Kategori IPC
Pipes : merupakan fasilitas yang menyediakan komunikasi satu arah antar proses dalam sebuah sistem atau disebut half-duplex, yaitu data mengalir h hanya t terjadi j di satu t arah. h (local (l l computer) t ) FIFO : fasilitas komunikasi secara FIFO (first in first out). Mirip dengan Pipes Message diantrikan Terjadi e jad d di local oca co computer pute Shared memory : suatu proses berbagi ruang dalam virtual address, sehingga proses manapun akan berbagi wilayah memory akan mampu menulis dan membacanya. g processing g( (local computer) ) Dalam single
Kategori IPC
Mapped memory : berhubungan dengan mapping sebuah file dalam file system sesuai dengan memory yang ada.
Konsep virtual memory Local computer
Kategori IPC
S Semaphore h : struktur t kt data d t yang di share h k ke beberapa proses untuk sinkronisasi Socket : sebagai endpoint dari komunikasi dua proses pada dua buah sistem komputer. RPC (Remote Procedure Call): adalah sebuah protokol yang memungkinkan program komputer berjalan pada satu host dan mengakibatkan k d d kode dapat t di dieksekusi k k i pada d h host t yang l lain i t tanpa kebutuhan koneksi secara eksplisit.
Ordinary Pipes
Ordinary Pipes allow communication in standard parent-child style write Producer (parent) writes to one end (the write end of the pipe) Consumer (child) reads from the other end (the read-end d d of f the h pipe) i ) Require parent-child relationship between communicating processes A parent program opens anonymous pipes, and creates a new process and communicate using these pipes, or creates several new processes and arranges them
ls -l | less
Pipe
E Example l i in UNIX
l -l ls l | less l
Named Pipes
N Named d Pi Pipes are more powerful f l than th ordinary di pipes A named pipe is one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers Multiple M lti l pipe i clients li t can use the th same named d pipe i simultaneously (system-persistent) No parent-child parent child relationship is necessary between the communicating processes Provided on both UNIX and Windows systems
Message Passing
z
Message Passing
Basic B i O Operations ti
Send > kirim message Receive R i > terima t i message
Variations
Connection-oriented C vs Connectionless C Buffered vs Unbuffered Reliable R li bl vs U Unreliable li bl
Data representation
Marshalling M h lli & unmarshalling h lli > pemformatan f t message
Communication Link
Properties of communication link
Links sa are e es established ab s ed au automatically o a ca y A link usually is associated with exactly one pair of communicating processes Between each pair there exists exactly one link The link may be unidirectional, but is usually bi di bi-directional i l
Di t C Direct Communication i ti
Processes must name each other explicitly:
send (P, message) send a message to process P receive i (Q, Q message) receive i a message f from process Q
I di t Communication Indirect C i ti
Messages are directed and received from ports
Each port has a unique id Well known ports: 0-1023 Recommended : > 1024 - 65535 Processes can communicate only if they share a port
I di t Communication Indirect C i ti
Operations
create a new/open port send and receive messages through port destroy yap port
I di t Communication Indirect C i ti
Port sharing P1, P2, and P3 share port A P1, sends; d P2 and d P3 receive i Who gets the message? Solutions S l i Allow a link to be associated with at most two processes All Allow only l one process at t a time ti to t execute t a receive i operation Allow all processes receive the message Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was was.
Asynchronous communication
Persistent Communication
Message stored until receiver can accept it Example: p Email, , Messenger g
Group Communications
z
z z
Group Communications
Komunikasi Jaringan
Remember: OSI
Data Link
Means of activating, maintaining and deactivating a reliable li bl li link k Error detection Contoh: PPP, PPP Router
Transport
Exchange of data between end systems Error free In sequence / No sequence No losses / losses No duplicates / duplicates Quality of service Contoh: TCP dan UDP
Presentation
Data formats and coding Data compression Encryption Contoh: SSL
Application
M Means f for applications li i to access OSI environment i Contoh: HTTP, FTP, SMTP
The Message
TCP
Transmission T i i C Control t lP Protocol, t l pada d t transport tl layer
Reliable connection
Adanya pengecekan error Dijaga urutan message Komunikasi duplex dua arah Segmentasi - TCP PDU
Called TCP segment Includes source and destination port
Identify applications Connection refers to pair of ports
UDP
User Datagram Protocol Not guaranteed delivery No preservation of sequence No protection against duplication Minimum overhead Adds port addressing to IP Contoh: DNS, streaming
Request / Reply
Arbitrary y failure: p proses melewatkan step p yang harus dilakukan atau membawa data yg salah
Data korup, data double
Socket
M Menyediakan di k jembatan j b t komunikasi k ik i antar t proses Komunikasi K ik i antar t proses: mengirimkan ii k pesan antar socket pada satu proses menuju sebuah socket pada proses lain Bisa menggunakan TCP/UDP
C Connection i oriented i dd dan connectionless i l oriented
socket
any port
message client other ports Internet address = 138.37.94.248 Internet address = 138.37.88.249 server
Operasi Socket
Socket dapat melakukan operasi:
Koneksi ke mesin remote Mengirim data Menerima data Mentutup koneksi Bind to a port
Masalah Socket
I Informasi f i pada d program : struktur t kt data d t Informasi pada p message g : urutan byte y Data harus dikonversi sebelum dan sesudah pengiriman agar bisa diproses dua pihak Masalah : representasi pada sistem bisa berbeda-beda
ASCII vs Unicode Big-endian vs Little-endian
Marshalling / Unmarshalling
Marshalling : proses konversi data menjadi yang g cocok/tepat p untuk transmisi bentuk y pesan antar host
Unmarshalling : proses kebalikannya
3 1934
java.lang.String
name: 6 London
place:
NEXT
Pemrograman Socket
Sumber: Su be Distributed s bu ed Sys Systems e sC Chapter ap e 4 khusus pemrograman socket, George Sumber: An introduction to network programming with Java, Jan Graba
Buatlah: B tl h
Pengertian, cara kerja Contoh program socket connection oriented + connectionless oriented