0% found this document useful (0 votes)
117 views17 pages

Request-Reply Protocol

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
117 views17 pages

Request-Reply Protocol

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 17

REQUEST-REPLY Dr.

Kumudha Raimond
PROTOCOL
Request-Reply Communication

• This form of communication support the roles and message exchanges in


typical client-server interactions.
• In the normal case, request-reply communication is synchronous
• Asynchronous request-reply communication is an alternative where clients
can afford to retrieve replies later
• This request-reply protocol matches requests to replies. It may be designed
to provide certain delivery guarantees.
• If UDP datagrams are used, the delivery guarantees must be provided by the
request-reply protocol, which may use the server reply message as an
acknowledgement of the client request message.
Request-Reply Communication
CLIENT SERVER
COMMUNICATION PRIMITIVES
Client
Side
public byte[] doOperation (RemoteRef s, int operationId, byte[]
arguments)
The doOperation method is used by clients to invoke remote operations.
Its arguments specify the remote server and which operation to invoke, together with
additional information (arguments) required by the operation.
sends a request message to the remote object and returns the reply
First argument - instance of the class RemoteRef, which represents references for
remote servers.
This class provides methods for getting the Internet address and port of the associated
server.

After sending the request message, doOperation invokes receive to get a reply
message, from which it extracts the result and returns it to the caller.

The caller of doOperation is blocked until the server performs the requested
operation and transmits a reply message to the client process.
When the reply message is received by the client the original doOperation is unblocked
and execution of the client program continues.
CLIENT SERVER
COMMUNICATION
Server
Side
public byte[] getRequest ();
⚫ getRequest() is used by a server process to acquire a client request via
the server port

public void sendReply (byte[] reply, InetAddress clientHost, int


clientPort);
⚫ When the server has invoked the specified operation, it then uses
sendReply to send the reply message to the client.
REQUEST-REPLY MESSAGE
STRUCTURE
(THE INFORMATION TO BE TRANSMITTED IN A
REQUEST MESSAGE OR A REPLY MESSAGE)

messageTyp int (0=Request, 1=


e Reply)
requestI int Unique message identifier
d
objectReferen RemoteObject
ce
methodI Ref
int or
d Method
argument array of
s bytes
When the value of the requestId reaches the maximum value for
an unsigned integer (for example, 2 32 – 1) it is reset to zero.
REQUEST-REPLY MESSAGE
STRUCTURE
(THE INFORMATION TO BE TRANSMITTED IN A
REQUEST MESSAGE OR A REPLY MESSAGE)

messageTyp int (0=Request, 1=


e Reply)
requestI int Unique message identifier
d
objectReferen RemoteObject
ce
methodI Ref
int or
d Method
argument array of
s bytes
A doOperation generates a requestId for each request message, and the server
copies these IDs into the corresponding reply messages.

RequestId, contains a message identifier.


Each message have a unique message identifier by which it may be referenced
REQUEST-REPLY MESSAGE
STRUCTURE
messageTyp int (0=Request, 1=
e Reply)
requestI int
d
objectReferen RemoteObject
ce
methodI Ref
int or
d Method
argument array of
s bytes

A message identifier consists of two parts:


1. a requestId, which is taken from an increasing sequence of integers
by the sending process (unique to the sender)
2. an identifier for the sender process, for example, its port and
Internet address (unique in the distributed system)
FAILURE MODEL OF
REQUEST/REPLY PROTOCOL
If the three primitives doOperation, getRequest and sendReply are
implemented over UDP datagrams, then they suffer from the same
communication failures. That is:
• They suffer from omission failures.
• Messages are not guaranteed to be delivered in sender order

In addition, the protocol can suffer from the failure of processes


TIMEOUT OF REQUEST/REPLY
PROTOCOL
Timeout
When a server has failed or a request or reply message is dropped,
doOperation uses a timeout when it is waiting to get the server’s reply
message.

What doOperation can do after a timeout?


Solution
1. The simplest option is to return immediately from doOperation with
an indication to the client that the doOperation has failed - not the
usual approach
2. doOperation sends the request message repeatedly until either it
gets a reply or it is reasonably sure that the delay is due to lack of
response from the server rather than to lost messages
TIMEOUT OF REQUEST/REPLY
PROTOCOL
Discarding duplicate request messages
When the request message is retransmitted, the server may receive it
more than once.
Issue
Server may be executing an operation more than once for the same
request
Solution
• Protocol is designed to recognize successive messages (from the same
client) with the same request identifier and to filter out duplicates.

• If the server has not yet sent the reply, it need take no special action –
it will transmit the reply when it has finished executing the operation
TIMEOUT OF REQUEST/REPLY
PROTOCOL
Lost reply messages
COMMUNICATION
PROTOCOLS FOR RPC
Several communication protocols have been proposed based on the needs
of different systems
Type of Protocols
• Reply Protocol
• Request/Reply Protocol
• Request/Reply/Acknowledge-Reply Protocol
COMMUNICATION
PROTOCOLS FOR RPC
Request (R) Protocol
• It is used when the called procedure has nothing to return and the
client requires no confirmation that the procedure has been executed
• Only one msg/call is transmitted
• Client proceeds immediately after sending the request message
• This protocol is implemented over UDP datagrams and therefore suffers
from the same communication failures.
COMMUNICATION
PROTOCOLS
Request /Reply (RR) Protocol
FOR RPC
• The RR protocol is useful for most Client Server
client-server exchanges because it is
based on the request-reply protocol.
Request Msg
• Special acknowledgement messages
Procedure
are not required, because a server’s execution
reply message is regarded as an
acknowledgement of the client’s Reply Msg
request message. Also serves as an ack for the
• Similarly, a subsequent call from a request msg

client may be regarded as an


acknowledgement of a server’s reply
message.
COMMUNICATION
PROTOCOLS FOR
Request /Reply/Acknowledge-Reply (RRA) Protocol
RPC
Client Server

Request –Reply Message Structure


Request Msg Message Type 0-Request, 1-Reply
Procedure
execution RequestID int
Object Remote object Reference
Reply Msg
Reference
Reply ack msg
Request Msg MethodId Int / Method
Arguments Array of bytes
Procedure
execution
Reply Msg
Reply ack msg
SPECIAL TYPES OF RPCS
Callback RPC : Peer-Peer process
Broadcast RPC : A client’s request is broadcast on the network and is
processed by all the servers that have the concerned procedure for
processing that request – may wait for 0, 1, m out of n replies depends on
the reliability desired
Batch Mode RPC : It is used to queue separate RPC requests in a
transmission buffer on the client side and then send them over the network
in one batch to the server – reduced the overhead in sending each RPC
request independently

You might also like