# Communication protocols

We already talked about ontologies, that give meaning to messages sent among agents, however, for practical reasons, the agents also need to agree on some communication protocols. These specify when can an agent send a message to another agent and what is the expected answer. A number of standards exist for multi-agent communication, however, the most well known is the FIPA standard published by the Foundation for Intelligent Physical Agents.

The FIPA standard specifies a number of protocols used for multi-agent communication and also languages that are used to encode the content of the messages and the format of the message (envelope) itself.

## FIPA ACL Message Structure

The structure of the messages is specified in the FIPA Agent Communication Language (FIPA-ACL) Message Structure Specification. This specification gives the fields that may or must present in every FIPA compliant message. There are the common fields that you can find in every message - sender, receiver, reply-to, and content. But there are also additional fields, like performative that specifies what the message is (REQUEST, QUERY, INFO, …). The perfomatives that can be used and when they can be used are actually specified by the protocols described below. The content of the message is described by other fields - ontology, language, and encoding. The ontology parameter specifies the ontology the agents use, while the language specifies which language they use (e.g. which expressions from first order logic can be used), finally, the encoding says how the messages are encoded (e.g. if the message is an XML, or something else).

There are also a few other fields in the messages that simplify the communication - conversation-id helps assigning messages to specific communications and reply-by specify how long the agent has to reply to the message.

## FIPA SL Content Language

The FIPA Semantic Language (FIPA-SL) standard specifies the language the agents use to communicate and what they can express. The languages defines the syntax of expressions that agents can send - they can contain logical connectives such as conjunction, disjunction, implication, negation, and equivalence, together with quantifiers and so called referential operators. The referential operator operator iota refers to the only value of a variable that specifies a condition, if there is no such value or if there is more than one value satisfying the expression, the value is considered not to exist (and the query for such value ends with an error). The any and all referential operators denote any object that satisfied the expression or all objects that satisfy the expression respectively.

The specification shows a few communication examples for some of the referential operators. For example the following shows a possible communication using the any referntial operator between agents a and b, assuming the agent a’s beliefs are {P(A), Q(1, A), Q(1, B)}.

(query‑ref
:sender (agent-identifier :name B)
:content
"((any (sequence ?x ?y) (q ?x ?y)))"
:language fipa-sl

(inform
:sender (agent-identifier :name A)
:content
"((= (any (sequence ?x ?y) (q ?x ?y)) (sequence 1 a)))"
:language fipa-sl


And the following shows a communication between the same two agents with the all referential operator.

(query‑ref
:sender (agent-identifier :name B)
:content
"((all (sequence ?x ?y) (q ?x ?y)))"
:language fipa-sl

(inform
:sender (agent-identifier :name A)
:content
"(( = (all (sequence ?x ?y) (q ?x ?y)) (set(sequence 1 a)(sequence 1 b))))"
:language fipa-sl


The messages have the performative inform or query-ref, then we can see a typical part of the message envelope and, finally, the content is written in the SL language. Notice that the results in the second communication is a set.

The standard also allows for other, more complex expressions. As already mentioned, we can use formulas written in modal logic. A number of modalities are allowed, namely B for beliefs, U for uncertainty, I for intentions, and PG for persistent goals. We can also express that something has just been some action has just been done or that some action is feasible.

The full FIPA-SL language may be too strong for many application, therefore the standard specifies a number of more limited languages. SL0 does not allow for any logical connectives, and therefore can express only actions and their parameters/results. SL1 contains the logical connectives from propositional logic, while SL2 allows first order predicate and modal logic, however is restricted so that all formulas are decidable.

## FIPA Communication Protocols

All FIPA Communication Protocols are in a repository on FIPA webpage.

The most basic FIPA protocol is the REQUEST one. In the Request protocol the initiator agent (the one that starts the conversation) asks the participant (the other agent) to do something. To this end, the initiator sends a message with the REQUEST performative (typically containing the action that should be performed). The participant can than answer with a message with a REFUSE or AGREE performative. If the participant agrees to perform the action, they should later send either FAILURE if the action fails for any reason or an INFORM-RESULT message with the results (on only INFORM-DONE, if there is no result). There is also Query protocol that is the same, but instead of performing an action the participant is asked to answer some query. This protocol starts with a QUERY message. The Subscribe protocol, that is used when the initiator subscribes to receive messages whenever something happens, is also very similar. The initiator uses a message with a SUBSCRIBE performative to initiate the protocol, the participant agrees or refuses and then (if the participant agreed) sends a message whenever the thing of interest happens.

The Contract-Net protocol is a little more complicated. The Initiator in this case sends a CFP (Call for Proposal) message to several Responders. This message contains the action the Responder should perform. Each Responder replies with a message (PROPOSE), in which it describes the conditions (e.g. price) for performing the action. It can also reply it will not perform the action at all (REFUSE). Initiator chooses from the replies some Responders to perform the action and sends them an ACCEPT_PROPOSAL message. It sends REJECT_PROPOSAL to the other Responders.

The first step of the protocol is the same as in the Request protocol, only the Initiator sends a CFP instead of REQUEST. This is the way, how the Responder knows it should not perform the action, but send its conditions. This also shows how important performatives are. The action is performed after the Responder receives the ACCEPT_PROPOSAL message.

There are other communication protocols, like the brokering protocol that allows an agent to ask another agent to find agents that are able to perform an action. There are also protocols implementing the English and Dutch auctions.