SlideShare a Scribd company logo
API for Internet Protocols
Unit - II
API for Internet Protocols
• Characteristics of Interprocess Communication
• Sockets
• UDP Datagram Communication
• TCP Stream Communication
Characteristics of Interprocess Communication
• Message passing between a pair of processes can be supported by two message
communication operations, send and receive, defined in terms of destinations and
messages.
• To communicate, one process sends a message (a sequence of bytes) to a
destination and another process at the destination receives the message.
• It involves synchronization of two processes
• Characteristics
• Synchronous and Asynchronous communication
• Message Destination
• Reliability
• Ordering
Characteristics of Interprocess Communication
• Synchronous and Asynchronous Communication
• A queue is associated with each message destination.
• Sending processes cause messages to be added to remote queues and receiving processes
remove messages from local queues.
• Communication between the sending and receiving processes may be either synchronous or
asynchronous.
• In the synchronous form of communication
• the sending and receiving processes synchronize at every message.
• Both send and receive process are blocking operations.
• Whenever a send is issued the sending process (or thread) is blocked until the corresponding
receive is issued.
• Whenever a receive is issued by a process (or thread), it blocks until a message arrives.
Characteristics of Interprocess Communication
• In Asynchronous form of communication
• the send operation is nonblocking
• the sending process is allowed to proceed as soon as the message has been
copied to a local buffer, and the transmission of the message proceeds in
parallel with the sending process.
• The receive operation can have blocking and non-blocking variants.
• In the non-blocking variant, the receiving process proceeds with its program
after issuing a receive operation, which provides a buffer to be filled in the
background, but it must separately receive notification that its buffer has been
filled, by polling or interrupt.
Characteristics of Interprocess Communication
• Message Destinations
• In Internet protocols, messages are sent to (Internet address, local port) pairs.
• A local port is a message destination within a computer, specified as an integer.
• A port has exactly one receiver but can have many senders.
• Processes may use multiple ports to receive messages.
• Reliability
• Reliable communication in terms of validity and integrity
• Validity – point to point message service
• Integrity – messages must arrive uncorrupted and without duplication
• Ordering
• Applications require that messages delivered in sender order
Sockets
• Both TCP and UDP Communication uses Socket Abstraction
• Provide communication endpoint between processes
• For a process to receive messages, its socket must be bound to a local port and
one of the Internet addresses of the computer on which it runs.
• Messages sent to a particular Internet address and port number can be received
only by a process whose socket is associated with that Internet address and port
number.
Sockets
• Java API for Internet Address
• Java provides a class, InetAddress, that represents Internet addresses.
• Users of this class refer to computers by Domain Name System (DNS)
hostnames.
InetAddress aComputer = InetAddress.getByName("bruno.dcs.qmul.ac.uk");
• instances of InetAddress that contain Internet addresses can be created by
calling a static method of InetAddress, giving a DNS hostname as the argument.
• The method uses the DNS to get the corresponding Internet address.
• the class encapsulates the details of the representation of Internet addresses.
• the interface for this class is not dependent on the number of bytes needed to
represent Internet addresses – 4 bytes in IPv4 and 16 bytes in IPv6.
UDP Datagram Communication
• A datagram sent by UDP is transmitted from a sending process to a
receiving process without acknowledgement or retries.
• To send or receive messages a process must first create a socket bound
to an Internet address of the local host and a local port.
• A server will bind its socket to a server port which makes known to
clients so that they can send messages to it.
• A client binds its socket to any free local port.
• The receive method returns the Internet address and port of the sender,
in addition to the message, allowing the recipient to send a reply.
UDP Datagram Communication
• Issues related to Datagram Communication
• Message Size
• If the message is too big on its array, it will be truncated on arrival
• Blocking
• Sockets provide non-blocking sends and blocking receives datagram communication
• The send operation returns when it has handed the message to the underlying UDP and IP protocols,
which are responsible for transmitting it to its destination.
• On arrival, the message is placed in a queue for the socket that is bound to the destination port.
• The message can be collected from the queue by an outstanding or future invocation of receive on that
socket.
• Messages are discarded at the destination if no process already has a socket bound to the destination port.
• Timeouts
• Receive form any
UDP Datagram Communication
• Failure Model for UDP Datagram
• Omission Failures
• Messages may be dropped occasionally, either because of a checksum error or because no buffer
space is available at the source or destination.
• Ordering
• Messages can sometimes be delivered out of sender order.
• Use of UDP Datagram
• Voice over IP (VOIP) runs over UDP
• Sources of overhead
• the need to store state information at the source and destination
• the transmission of extra messages
• latency for the sender.
UDP Datagram Communication
• Java API for UDP Datagram
• Communication by means of two classes - DatagramPacket and DatagramSocket
• An instance of DatagramPacket may be transmitted between processes when
one process sends it and another receives it.
• This class provides another constructor for use when receiving a message.
• A received message is put in the DatagramPacket together with its length and the
Internet address and port of the sending socket.
• The message can be retrieved from the DatagramPacket by means of the method
getData.
• The methods getPort and getAddress access the port and Internet address.
UDP Datagram Communication
• Java API for UDP Datagram - DatagramPacket
UDP client sends a message to
the server and gets a reply
UDP Datagram Communication
• Java API for UDP Datagram – DatagramSocket
• This class supports sockets for sending and receiving UDP datagrams.
• It provides a constructor that takes a port number as its argument, for use by processes that need to use a particular port.
• It also provides a no-argument constructor that allows the system to choose a free local port.
• Methods
• send and receive
• These methods are for transmitting datagrams between a pair of sockets.
• The argument of send is an instance of DatagramPacket containing a message and its destination.
• The argument of receive is an empty DatagramPacket in which to put the message, its length and its origin.
• setSoTimeout
• This method allows a timeout to be set.
• connect
• This method is used for connecting to a particular remote port and Internet address, in which case the socket
is only able to send messages to and receive messages from that address.
UDP Datagram Communication
• Java API for UDP Datagram - DatagramSocket
UDP server repeatedly receives a
request and sends it back to the client
TCP Stream Communication
• abstraction of a stream of bytes to which data may be written and from which data may be read.
• characteristics of the network are hidden by the stream abstraction:
• Message sizes
• The application can choose how much data it writes to a stream or reads from it.
• It may deal in very small or very large sets of data.
• Lost messages
• The TCP protocol uses an acknowledgement scheme.
• Flow control
• The TCP protocol attempts to match the speeds of the processes that read from and write to a stream.
• Message duplication and ordering
• Message identifiers are associated with each IP packet, which enables the recipient to detect and reject duplicates, or to reorder
messages that do not arrive in sender order.
• Message destinations
• A pair of communicating processes establish a connection before they can communicate over a stream.
• Once a connection is established, the processes simply read from and write to the stream without needing to use Internet
addresses and ports.
TCP Stream Communication
• The client role involves creating a stream socket bound to any port and then
making a connect request asking for a connection to a server at its server port.
• The server role involves creating a listening socket bound to a server port and
waiting for clients to request connections.
• The listening socket maintains a queue of incoming connection requests.
• In the socket model, when the server accepts a connection, a new stream socket
is created for the server to communicate with a client, meanwhile retaining its
socket at the server port for listening for connect requests from other clients.
• The pair of sockets in the client and server are connected by a pair of streams,
one in each direction.
• Thus each socket has an input stream and an output stream.
TCP Stream Communication
• Issues related to Stream Communication
• Matching of Data items
• Two communicating processes need to agree as to the contents of the data transmitted over a
stream
• Blocking
• The data written to a stream is kept in a queue at the destination socket.
• When a process attempts to read data from an input channel, it will get data from the queue or
it will block until data becomes available.
• The process that writes data to a stream may be blocked by the TCP flow-control mechanism.
• Threads
• When a server accepts a connection, it generally creates a new thread in which to
communicate with the new client.
TCP Stream Communication
• Failure Model for TCP Stream Communication
• To satisfy the integrity property,
• use checksums to detect and reject corrupt packets
• sequence numbers to detect and reject duplicate packets
• For the sake of the validity property,
• use timeouts and retransmissions to deal with lost packets
• When a connection is broken, the side effects are
• The processes using the connection cannot distinguish between network failure and failure of the process at the
other end of the connection.
• The communicating processes cannot tell whether the messages they have sent recently have been received or
not.
• Use of TCP Stream
• HTTP - communication between web browsers and web servers
• FTP - allows directories on a remote computer to be browsed
• Telnet - access by means of a terminal session to a remote computer.
• SMTP - to send mail between computers.
TCP Stream Communication
• Java API for TCP Communication
• Communication by means of two classes – ServerSocket and Socket
• ServerSocket
• This class is intended for use by a server to create a socket at a server port for
listening for connect requests from clients.
• Its accept method gets a connect request from the queue or, if the queue is empty,
blocks until one arrives.
• The result of executing accept is an instance of Socket – a socket to use for
communicating with the client.
TCP Stream Communication
TCP client makes
connection to server, sends
request and receives reply
TCP Stream Communication
• Java API for TCP Communication
• Socket
• This class is for use by a pair of processes with a connection.
• The client uses a constructor to create a socket, specifying the DNS hostname and port of
a server.
• This constructor not only creates a socket associated with a local port but also connects it
to the specified remote computer and port number.
• It can throw an UnknownHostException if the hostname is wrong or an IOException if
an IO error occurs.
• The Socket class provides the methods getInputStream and getOutputStream for
accessing the two streams associated with a socket.
• The return types of these methods are InputStream and OutputStream, respectively –
abstract classes that define methods for reading and writing bytes.
TCP Stream Communication
TCP server makes a
connection for each client and
then echoes the client’s request
Ad

More Related Content

Similar to Distributed Computing - API for Internet Protocols (20)

chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhj
AmitDeshai
 
Unit 6 NAHI aa rha hai na ki koi baat nhi hai
Unit 6 NAHI aa rha hai na ki koi baat nhi haiUnit 6 NAHI aa rha hai na ki koi baat nhi hai
Unit 6 NAHI aa rha hai na ki koi baat nhi hai
swapnilyadav3165
 
Transport Layer In Computer Network
Transport Layer In Computer NetworkTransport Layer In Computer Network
Transport Layer In Computer Network
Destro Destro
 
Unit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxUnit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptx
DESTROYER39
 
Unit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxUnit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptx
sarosh32
 
Unit-4 (1).pptx
Unit-4 (1).pptxUnit-4 (1).pptx
Unit-4 (1).pptx
poonamsngr
 
TCP/IP(networking)
TCP/IP(networking)TCP/IP(networking)
TCP/IP(networking)
welcometofacebook
 
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Dhivyaa C.R
 
Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...
smitha273566
 
Transport protocols
Transport protocolsTransport protocols
Transport protocols
Online
 
Lecture set 7
Lecture set 7Lecture set 7
Lecture set 7
Gopi Saiteja
 
lecturer3.pptx
lecturer3.pptxlecturer3.pptx
lecturer3.pptx
MdFarabiHasan
 
Learn TransportLayer of the OSI model to day with me.
Learn TransportLayer of the OSI model to day with me.Learn TransportLayer of the OSI model to day with me.
Learn TransportLayer of the OSI model to day with me.
SilasHAKUZWIMANA
 
INTERNET PROGRAMMING unit1 web essential
INTERNET PROGRAMMING unit1  web essentialINTERNET PROGRAMMING unit1  web essential
INTERNET PROGRAMMING unit1 web essential
psaranya21
 
New udp
New udpNew udp
New udp
Nitesh Singh
 
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
Waqas Ahmed Nawaz
 
TRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptxTRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptx
utkarshlodhi4
 
Transport layer.pptx
Transport layer.pptxTransport layer.pptx
Transport layer.pptx
MohammedAnas871930
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
Esubesisay
 
Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Networking in python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
chapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhjchapter-4-networking hjgjjgj did hfhhfhj
chapter-4-networking hjgjjgj did hfhhfhj
AmitDeshai
 
Unit 6 NAHI aa rha hai na ki koi baat nhi hai
Unit 6 NAHI aa rha hai na ki koi baat nhi haiUnit 6 NAHI aa rha hai na ki koi baat nhi hai
Unit 6 NAHI aa rha hai na ki koi baat nhi hai
swapnilyadav3165
 
Transport Layer In Computer Network
Transport Layer In Computer NetworkTransport Layer In Computer Network
Transport Layer In Computer Network
Destro Destro
 
Unit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxUnit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptx
DESTROYER39
 
Unit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxUnit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptx
sarosh32
 
Unit-4 (1).pptx
Unit-4 (1).pptxUnit-4 (1).pptx
Unit-4 (1).pptx
poonamsngr
 
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Inter process communication by Dr.C.R.Dhivyaa, Assistant Professor,Kongu Engi...
Dhivyaa C.R
 
Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...
smitha273566
 
Transport protocols
Transport protocolsTransport protocols
Transport protocols
Online
 
Learn TransportLayer of the OSI model to day with me.
Learn TransportLayer of the OSI model to day with me.Learn TransportLayer of the OSI model to day with me.
Learn TransportLayer of the OSI model to day with me.
SilasHAKUZWIMANA
 
INTERNET PROGRAMMING unit1 web essential
INTERNET PROGRAMMING unit1  web essentialINTERNET PROGRAMMING unit1  web essential
INTERNET PROGRAMMING unit1 web essential
psaranya21
 
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
Waqas Ahmed Nawaz
 
TRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptxTRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptx
utkarshlodhi4
 
Networking.pptx
Networking.pptxNetworking.pptx
Networking.pptx
Esubesisay
 

More from nirmalanr2 (10)

External Data Representation and Marshalling
External Data Representation and MarshallingExternal Data Representation and Marshalling
External Data Representation and Marshalling
nirmalanr2
 
Distributed Computing - Examples of Distributed System
Distributed Computing - Examples of Distributed SystemDistributed Computing - Examples of Distributed System
Distributed Computing - Examples of Distributed System
nirmalanr2
 
Distributed Computing - Trends in Distributed System
Distributed Computing - Trends in Distributed SystemDistributed Computing - Trends in Distributed System
Distributed Computing - Trends in Distributed System
nirmalanr2
 
Distributed Computing - System Models.pptx
Distributed Computing - System Models.pptxDistributed Computing - System Models.pptx
Distributed Computing - System Models.pptx
nirmalanr2
 
Resource Sharing and Challenges - Distributed Computing
Resource Sharing and Challenges - Distributed ComputingResource Sharing and Challenges - Distributed Computing
Resource Sharing and Challenges - Distributed Computing
nirmalanr2
 
Databases Comparison in nosql databases.
Databases Comparison in nosql databases.Databases Comparison in nosql databases.
Databases Comparison in nosql databases.
nirmalanr2
 
2_From Business Problems to Data Mining Tasks.pptx
2_From Business Problems to Data Mining Tasks.pptx2_From Business Problems to Data Mining Tasks.pptx
2_From Business Problems to Data Mining Tasks.pptx
nirmalanr2
 
Ontological Representation of Social Individuals.pptx
Ontological Representation of Social Individuals.pptxOntological Representation of Social Individuals.pptx
Ontological Representation of Social Individuals.pptx
nirmalanr2
 
2. Business Data Analytics and Technology.pptx
2. Business Data Analytics and Technology.pptx2. Business Data Analytics and Technology.pptx
2. Business Data Analytics and Technology.pptx
nirmalanr2
 
1. Managing Business Analytics Personnel.pdf
1. Managing Business Analytics Personnel.pdf1. Managing Business Analytics Personnel.pdf
1. Managing Business Analytics Personnel.pdf
nirmalanr2
 
External Data Representation and Marshalling
External Data Representation and MarshallingExternal Data Representation and Marshalling
External Data Representation and Marshalling
nirmalanr2
 
Distributed Computing - Examples of Distributed System
Distributed Computing - Examples of Distributed SystemDistributed Computing - Examples of Distributed System
Distributed Computing - Examples of Distributed System
nirmalanr2
 
Distributed Computing - Trends in Distributed System
Distributed Computing - Trends in Distributed SystemDistributed Computing - Trends in Distributed System
Distributed Computing - Trends in Distributed System
nirmalanr2
 
Distributed Computing - System Models.pptx
Distributed Computing - System Models.pptxDistributed Computing - System Models.pptx
Distributed Computing - System Models.pptx
nirmalanr2
 
Resource Sharing and Challenges - Distributed Computing
Resource Sharing and Challenges - Distributed ComputingResource Sharing and Challenges - Distributed Computing
Resource Sharing and Challenges - Distributed Computing
nirmalanr2
 
Databases Comparison in nosql databases.
Databases Comparison in nosql databases.Databases Comparison in nosql databases.
Databases Comparison in nosql databases.
nirmalanr2
 
2_From Business Problems to Data Mining Tasks.pptx
2_From Business Problems to Data Mining Tasks.pptx2_From Business Problems to Data Mining Tasks.pptx
2_From Business Problems to Data Mining Tasks.pptx
nirmalanr2
 
Ontological Representation of Social Individuals.pptx
Ontological Representation of Social Individuals.pptxOntological Representation of Social Individuals.pptx
Ontological Representation of Social Individuals.pptx
nirmalanr2
 
2. Business Data Analytics and Technology.pptx
2. Business Data Analytics and Technology.pptx2. Business Data Analytics and Technology.pptx
2. Business Data Analytics and Technology.pptx
nirmalanr2
 
1. Managing Business Analytics Personnel.pdf
1. Managing Business Analytics Personnel.pdf1. Managing Business Analytics Personnel.pdf
1. Managing Business Analytics Personnel.pdf
nirmalanr2
 
Ad

Recently uploaded (20)

Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Ad

Distributed Computing - API for Internet Protocols

  • 1. API for Internet Protocols Unit - II
  • 2. API for Internet Protocols • Characteristics of Interprocess Communication • Sockets • UDP Datagram Communication • TCP Stream Communication
  • 3. Characteristics of Interprocess Communication • Message passing between a pair of processes can be supported by two message communication operations, send and receive, defined in terms of destinations and messages. • To communicate, one process sends a message (a sequence of bytes) to a destination and another process at the destination receives the message. • It involves synchronization of two processes • Characteristics • Synchronous and Asynchronous communication • Message Destination • Reliability • Ordering
  • 4. Characteristics of Interprocess Communication • Synchronous and Asynchronous Communication • A queue is associated with each message destination. • Sending processes cause messages to be added to remote queues and receiving processes remove messages from local queues. • Communication between the sending and receiving processes may be either synchronous or asynchronous. • In the synchronous form of communication • the sending and receiving processes synchronize at every message. • Both send and receive process are blocking operations. • Whenever a send is issued the sending process (or thread) is blocked until the corresponding receive is issued. • Whenever a receive is issued by a process (or thread), it blocks until a message arrives.
  • 5. Characteristics of Interprocess Communication • In Asynchronous form of communication • the send operation is nonblocking • the sending process is allowed to proceed as soon as the message has been copied to a local buffer, and the transmission of the message proceeds in parallel with the sending process. • The receive operation can have blocking and non-blocking variants. • In the non-blocking variant, the receiving process proceeds with its program after issuing a receive operation, which provides a buffer to be filled in the background, but it must separately receive notification that its buffer has been filled, by polling or interrupt.
  • 6. Characteristics of Interprocess Communication • Message Destinations • In Internet protocols, messages are sent to (Internet address, local port) pairs. • A local port is a message destination within a computer, specified as an integer. • A port has exactly one receiver but can have many senders. • Processes may use multiple ports to receive messages. • Reliability • Reliable communication in terms of validity and integrity • Validity – point to point message service • Integrity – messages must arrive uncorrupted and without duplication • Ordering • Applications require that messages delivered in sender order
  • 7. Sockets • Both TCP and UDP Communication uses Socket Abstraction • Provide communication endpoint between processes • For a process to receive messages, its socket must be bound to a local port and one of the Internet addresses of the computer on which it runs. • Messages sent to a particular Internet address and port number can be received only by a process whose socket is associated with that Internet address and port number.
  • 8. Sockets • Java API for Internet Address • Java provides a class, InetAddress, that represents Internet addresses. • Users of this class refer to computers by Domain Name System (DNS) hostnames. InetAddress aComputer = InetAddress.getByName("bruno.dcs.qmul.ac.uk"); • instances of InetAddress that contain Internet addresses can be created by calling a static method of InetAddress, giving a DNS hostname as the argument. • The method uses the DNS to get the corresponding Internet address. • the class encapsulates the details of the representation of Internet addresses. • the interface for this class is not dependent on the number of bytes needed to represent Internet addresses – 4 bytes in IPv4 and 16 bytes in IPv6.
  • 9. UDP Datagram Communication • A datagram sent by UDP is transmitted from a sending process to a receiving process without acknowledgement or retries. • To send or receive messages a process must first create a socket bound to an Internet address of the local host and a local port. • A server will bind its socket to a server port which makes known to clients so that they can send messages to it. • A client binds its socket to any free local port. • The receive method returns the Internet address and port of the sender, in addition to the message, allowing the recipient to send a reply.
  • 10. UDP Datagram Communication • Issues related to Datagram Communication • Message Size • If the message is too big on its array, it will be truncated on arrival • Blocking • Sockets provide non-blocking sends and blocking receives datagram communication • The send operation returns when it has handed the message to the underlying UDP and IP protocols, which are responsible for transmitting it to its destination. • On arrival, the message is placed in a queue for the socket that is bound to the destination port. • The message can be collected from the queue by an outstanding or future invocation of receive on that socket. • Messages are discarded at the destination if no process already has a socket bound to the destination port. • Timeouts • Receive form any
  • 11. UDP Datagram Communication • Failure Model for UDP Datagram • Omission Failures • Messages may be dropped occasionally, either because of a checksum error or because no buffer space is available at the source or destination. • Ordering • Messages can sometimes be delivered out of sender order. • Use of UDP Datagram • Voice over IP (VOIP) runs over UDP • Sources of overhead • the need to store state information at the source and destination • the transmission of extra messages • latency for the sender.
  • 12. UDP Datagram Communication • Java API for UDP Datagram • Communication by means of two classes - DatagramPacket and DatagramSocket • An instance of DatagramPacket may be transmitted between processes when one process sends it and another receives it. • This class provides another constructor for use when receiving a message. • A received message is put in the DatagramPacket together with its length and the Internet address and port of the sending socket. • The message can be retrieved from the DatagramPacket by means of the method getData. • The methods getPort and getAddress access the port and Internet address.
  • 13. UDP Datagram Communication • Java API for UDP Datagram - DatagramPacket UDP client sends a message to the server and gets a reply
  • 14. UDP Datagram Communication • Java API for UDP Datagram – DatagramSocket • This class supports sockets for sending and receiving UDP datagrams. • It provides a constructor that takes a port number as its argument, for use by processes that need to use a particular port. • It also provides a no-argument constructor that allows the system to choose a free local port. • Methods • send and receive • These methods are for transmitting datagrams between a pair of sockets. • The argument of send is an instance of DatagramPacket containing a message and its destination. • The argument of receive is an empty DatagramPacket in which to put the message, its length and its origin. • setSoTimeout • This method allows a timeout to be set. • connect • This method is used for connecting to a particular remote port and Internet address, in which case the socket is only able to send messages to and receive messages from that address.
  • 15. UDP Datagram Communication • Java API for UDP Datagram - DatagramSocket UDP server repeatedly receives a request and sends it back to the client
  • 16. TCP Stream Communication • abstraction of a stream of bytes to which data may be written and from which data may be read. • characteristics of the network are hidden by the stream abstraction: • Message sizes • The application can choose how much data it writes to a stream or reads from it. • It may deal in very small or very large sets of data. • Lost messages • The TCP protocol uses an acknowledgement scheme. • Flow control • The TCP protocol attempts to match the speeds of the processes that read from and write to a stream. • Message duplication and ordering • Message identifiers are associated with each IP packet, which enables the recipient to detect and reject duplicates, or to reorder messages that do not arrive in sender order. • Message destinations • A pair of communicating processes establish a connection before they can communicate over a stream. • Once a connection is established, the processes simply read from and write to the stream without needing to use Internet addresses and ports.
  • 17. TCP Stream Communication • The client role involves creating a stream socket bound to any port and then making a connect request asking for a connection to a server at its server port. • The server role involves creating a listening socket bound to a server port and waiting for clients to request connections. • The listening socket maintains a queue of incoming connection requests. • In the socket model, when the server accepts a connection, a new stream socket is created for the server to communicate with a client, meanwhile retaining its socket at the server port for listening for connect requests from other clients. • The pair of sockets in the client and server are connected by a pair of streams, one in each direction. • Thus each socket has an input stream and an output stream.
  • 18. TCP Stream Communication • Issues related to Stream Communication • Matching of Data items • Two communicating processes need to agree as to the contents of the data transmitted over a stream • Blocking • The data written to a stream is kept in a queue at the destination socket. • When a process attempts to read data from an input channel, it will get data from the queue or it will block until data becomes available. • The process that writes data to a stream may be blocked by the TCP flow-control mechanism. • Threads • When a server accepts a connection, it generally creates a new thread in which to communicate with the new client.
  • 19. TCP Stream Communication • Failure Model for TCP Stream Communication • To satisfy the integrity property, • use checksums to detect and reject corrupt packets • sequence numbers to detect and reject duplicate packets • For the sake of the validity property, • use timeouts and retransmissions to deal with lost packets • When a connection is broken, the side effects are • The processes using the connection cannot distinguish between network failure and failure of the process at the other end of the connection. • The communicating processes cannot tell whether the messages they have sent recently have been received or not. • Use of TCP Stream • HTTP - communication between web browsers and web servers • FTP - allows directories on a remote computer to be browsed • Telnet - access by means of a terminal session to a remote computer. • SMTP - to send mail between computers.
  • 20. TCP Stream Communication • Java API for TCP Communication • Communication by means of two classes – ServerSocket and Socket • ServerSocket • This class is intended for use by a server to create a socket at a server port for listening for connect requests from clients. • Its accept method gets a connect request from the queue or, if the queue is empty, blocks until one arrives. • The result of executing accept is an instance of Socket – a socket to use for communicating with the client.
  • 21. TCP Stream Communication TCP client makes connection to server, sends request and receives reply
  • 22. TCP Stream Communication • Java API for TCP Communication • Socket • This class is for use by a pair of processes with a connection. • The client uses a constructor to create a socket, specifying the DNS hostname and port of a server. • This constructor not only creates a socket associated with a local port but also connects it to the specified remote computer and port number. • It can throw an UnknownHostException if the hostname is wrong or an IOException if an IO error occurs. • The Socket class provides the methods getInputStream and getOutputStream for accessing the two streams associated with a socket. • The return types of these methods are InputStream and OutputStream, respectively – abstract classes that define methods for reading and writing bytes.
  • 23. TCP Stream Communication TCP server makes a connection for each client and then echoes the client’s request
  翻译: