420 likes | 607 Views
Sistem. terdistribusi. 3. Interprocess Communication. Prinsip B erkomunikasi. • Source. – generates data (text/binary) to be transmitted Transmitter. •. – Converts data Transmission – Carries data – Ex: TCP/IP Receiver. into transmittable signals System. •. •.
E N D
Sistem terdistribusi 3 InterprocessCommunication
Prinsip Berkomunikasi • Source –generatesdata (text/binary)to be transmitted Transmitter • –Convertsdata Transmission –Carriesdata –Ex:TCP/IP Receiver intotransmittablesignals System • • –Convertsreceivedsignal Destination –Takes incomingdata into data •
Interprocess Communication Processeswithin a system may be independent or cooperating • • independent cooperating • Processondifferentcomputer? • Reasonsforcooperatingprocesses: • Informationsharing • Computationspeedup Modularity Convenience • • Cooperatingprocessesneedinterprocesscommunication(IPC) TwomodelsofIPC • • Sharedmemor • Sharedmemory • Messagepassing
Communications in local
Karakteristik IPC A h i ti •SynchronizationdanAsynchronizationof messages. • Messagedestination: onInternet, addressdanlocalport. using • http://192.168.1.2:8081 • Reliabilitydata:validitydanintegrity. • • Orderingdata: urutanpaketyangdikirim Differentdataprocessing: marshalling/unmarshalling
Kategori IPC : merupakanfasilitasyangmenyediakan • Pipes: merupakanfasilitasyangmenyediakan sistem atau disebuthalf-duplex, yaitu data mengalir • FIFO: fasilitaskomunikasisecaraFIFO(first infirst out). • MiripdenganPipes • Messagediantrikan • Terjadidilocalcomputer • Shared memory : suatuprosesberbagiruangdalam wilayahmemoryakanmampumenulisdan • Dalamsingleprocessing(localcomputer) komunikasisatu arahantarprosesdalam sebuah hanya terjadisatu arah.(localcomputer) h t jdi t h virtual address,sehinggaprosesmanapun akanberbagi wilayahmemoryakanmampumenulisdan membacanya.
Kategori IPC • Mappedmemory : berhubungandengan mapping sebuah file dalam file systemsesuai denganmemoryyangada. Konsepvirtualmemory Localcomputer – – • MessageQueues:mengirim pesansecara asynchronous. – Asynchronousberartiprosespengirimandata berlanjutdisertaisebuaheksekusitanpaharus menunggupenerimamenerimaataumengenal informasitersebut.
Kategori IPC t kt d t di h k • Semaphore : struktur data yang di share ke • Socket : sebagaiendpointdari komunikasidua • RPC (RemoteProcedure Call): adalahsebuah berjalan pada satu host dan mengakibatkan beberapaprosesuntuk sinkronisasi Socket proses pada dua buah sistem komputer. protokol yangmemungkinkanprogramkomputer kode dapat dieksekusi padahost yang laintanpa kebutuhan koneksi secara eksplisit.
Ordinary Pipes Ordinary Pipes allow communication in • Ordinary Pipes standard parent-child style • Producer (parent) writes to one end (the write- • Consumer (child)reads from the other end (the • Require parent-child relationship between end of the pipe) read-end of the pipe) d fh i communicating processes A parent program opens anonymous pipes, and • creates a new processand communicateusing these pipes, or creates several new processes and arranges them
Pipe UsingFIFOas queuescheme l Examplein UNIX ls -l |less
Message Passing z Maybeprovidelatency,incompatibilities latencyincompatibilities
Message Passing BasicOperations –Send > kirim message • R i –Receive> terimamessage • Variations –Connection-orientedvs Connectionless –Buffered vs Unbuffered C –Reliablevs Unreliable • Data representation & hlli f t –Marshalling& unmarshalling> pemformatanmessage
Communication Link Propertiesof communicationlink –Links are established automatically • –A link usually is associated with exactlyone pair of communicatingprocesses –Between each pair there existsexactly one link –The link may be unidirectional, but is usually bi-directional link di i l
Direct Communication Processesmustnameeachotherexplicitly: • send(P,message)–sendamessageto processP • i Q i f Q • receive(Q,message)–receiveamessagefromprocessQ • Propertiesof directcommunication • Linksareestablishedautomatically • Alinkisassociatedwithexactlyonepairofcommunicating processes • Betweeneachpairthereexistsexactlyonelink • Thelinkmaybeunidirectional,butisusuallybi-directional Li k
Indirect Communication Messagesaredirectedandreceivedfromports • Eachporthasauniqueid • Wellknownports:0-1023 Recommended:> 1024-65535 • • Processescancommunicateonlyif theyshareaport • • shareaport • Propertiesof indirectcommunicationlink • Linkestablishedonlyif processesshareacommonport • Alinkmaybeassociatedwithmanyprocesses • Eachpairofprocessesmayshareseveralcommunicationlinks • Linkmaybeunidirectional orbi-directional Linkestablishedonlyifprocesses acommonport
Indirect Communication • Operations createanew/openport send andreceivemessagesthroughport destroya port • • • • Primitivesare definedas: • send(A, message)– senda messageto portA • receive(A,message)– receiveamessagefrom port A
Indirect Communication • Port sharing P1,P2, and P3share portA • P P P • P1,sends; P2andP3receive • Who gets themessage? • Solutions • Allowa linkto be associatedwith at most twoprocesses • Allowonlyoneprocess ata time to execute areceive operation • Allowallprocesses receive the message • Allowthesystemtoselectarbitrarily the receiver. • Senderis notifiedwho thereceiver was. S l i l Allow processes receive the message
Model comm: Syn & Asyn S h • Synchronouscommunication –Acknowledgemust bereceived –Blockingcommunication –Sender/Recipientmustbothactive –Example:Registrationsystem / Chatting • Asynchronouscommunication –No acknowledgeneeded –Non-blockingcommunication Bl ki i ti / Chatting N k l d dd –Messagemaybe queued –Example: Email/ Instant Messenger
Transient & Persistent Comm. • TransientCommunication – Message discardedif failed to delivered immediately –Example: HTTP Request •PersistentCommunication – – Message Example: stored until receiver can accept Email, Messenger it
Group Communications z Multicast:sentto specificgroup :sentto specific z Sender tidak tahu identitas penerima dan berapa yang menerima z Broadcast:sentto everyone z Usedfor z Replication of services/data z Service discovery f / z Eventnotification
Group Communications
Komunikasi Jaringan
Remember: OSI
OSI Layers (1) Ph i l • Physical –Physicalinterfacebetweendevices • Mechanical • • Electrical Functional •Procedural – Contoh:EthernetCARD • Data Link –Meansof activating, maintaining anddeactivating a li bl lik reliablelink –Error detection –Contoh:PPP,Router Contoh:PPP
OSI Layers (2) N t k • Network –Transportofinformation –Contoh:VirtualCircuit&InternetProtocol • Transport –Exchangeof databetweenendsystems –Error free –In sequence/ No sequence –No losses / losses No duplicates/duplicates –No duplicates/duplicates –Quality of service –Contoh: TCP danUDP
OSI Layers (3) S i • Session –Controlof dialoguesbetweenapplications –Recovery • Presentation –Data formatsandcoding –Data compression –Encryption –Contoh:SSL Application • M f li i OSI i –Meansfor applicationsto accessOSIenvironment –Contoh:HTTP,FTP,SMTP
The Message
Konsep Pengiriman Data • • Datadikirimdalambentukpaket Setiap paketmemilikiheaderuntuk keperluanadministrasirouting •Datadisimpandalambodysebuahpaket •Ukuranpaketsangatbervariasi –Ethernet:64 – 1518 byte •BisadikirimkandenganTCP/UDP b d Bi dikii k d
TCP dan UDP • • Duaprotokolpadatransport layer Menggunakankonsepport(16bit) untuk membedakanaplikasi –HTTP: 80, HTTPS: 443, FTP: 21, ...... –Port1-1023: well-knownport HTTP 80 HTTPS 443FTP21 –Port1024-49151:registered port –Portlainbisa digunaka secarabebas –Di Linux: /etc/services
TCP TransmissionControlProtocol, –Reliableconnection Adanyapengecekanerror • pada transport layer • • Dijagaurutanmessage • Komunikasiduplex– duaarah • Segmentasi- TCP PDU –CalledTCPsegment –Includessourceanddestination • Identifyapplications port • Connectionrefersto pairofports • TCPtrackssegmentsbetweenentitiesoneach connection
UDP UserDatagramProtocol Notguaranteeddelivery • • •Nopreservationof sequence • • Noprotectionagainstduplication Minimumoverhead •Addsportaddressingto IP • Contoh:DNS, streaming
Request / Reply
Review Failure model • Processfailure: crash • Deteksi dgn timeout •Communicationfailure: messagedrop • Karena: transmission error, buffer overflow • Arbitraryfailure: prosesmelewatkanstep yangharusdilakukanataumembawadata ygsalah •Data korup, data double
Mekanisme handle failure dapat Timeout, method jika tidak balasan, mengirim • doOperation akan terusrequestmessagesampaitimeout. • Duplicaterequestmessage,server menerimalebihdarisekalirequest • server messagesehinggamemprosesnya berulangkali. solusi : request identifier & filter out duplicate. –
Failure Model of IPC Lostreply message, serverdapat menyimpan hasilproses requestmessage,jikaadarequest message yangsama tidak perlu diproses ulang,servermengirimreplymessage berupahasilprosesdarirequest • • tl hdii message yangtelahdisimpan. • History, server menyimpan struktur rekamanreplymessageyangtelah dikirim.
Sockets Menyediakanjembatankomunikasiantar proses • K ik i t ii k •Komunikasiantarproses:mengirimkan pesanantarsocketpadasatuproses menujusebuahsocketpadaproseslain • BisamenggunakanTCP/UDP C i i dd i l • Connection orienteddan connectionless •Melakukanbindingkesebuahport oriented bi di tertentu
Sockets and ports socket client socket message server anyport agreedport otherports Internetaddress= 138.37.94.248 Internetaddress= 138.37.88.249
Operasi Socket • Socketdapat melakukan operasi: – – – – – Di Koneksikemesinremote Mengirimdata Menerimadata Mentutupkoneksi Bind to a port • tiap mesin yang saling berinterkoneksi, harus terpasang socket. • Hard coded
Masalah Socket t kt dt •Informasipadaprogram : strukturdata •Informasipadamessage: urutanbyte • Dataharusdikonversi sebelumdan sesudahpengirimanagarbisadiproses duapihak • Masalah: representasipadasistem bisa berbeda-beda –ASCIIvsUnicode
Marshalling / Unmarshalling • Marshalling: proseskonversidatamenjadi bentukyangcocok/tepatuntuk transmisi pesanantarhost –Unmarshalling: proseskebalikannya •Pendekatanyangumumdigunakan: Unmarshalling: proses kebalikannya –CORBA dan RMI Marshalling –Java serialization –XML – XML RPC, Web Services