Algorithm as in LADS 2007 article.
This version of the one-on-group communication algorithm is the algorithm from the article as presented at "LADS @ Durham Agents'007". The form of the packages used in this algorithm have the following form:
Ksource(destination,-,group,sequence,acknowlegdements,data)
The field with "-" is the checksum field which deals with transmission errors. Because the checksum is not of interest for the knowlegde-based part of the algorithm it is left out in this version of the protocol. An explanation of the fields that are used in this version of the algorithm:
source | source port where this message is sent from [S,Ri]; |
Ksource | the source who sends this message knows this message; |
destination | destination port of message [S,Ri]; |
group | group receivers to which the message is sent [RG, - ]("-" means that the sender communicates only to the destination (one-on-one communication)) |
sequence | sequence number of message from agent who sends this message; |
acknowledgement | sequence number of message from agent who sends this message; |
data | data that has to be transmitted. |
Sender (incoming packages)
1 for (i = 1 to n) do
{For all agents who sender is sending to, ... }
2 ack_Ri = seqSRi
{... initialize the acknowledgement number.}
3 end
{ack_Ri's initialized}
4 while true do
{Get ready for receiving acknowledgements from the receivers, ... [11]}
5 when received KRi(S,-,-,seqRi,seqSRi,data) do
{You have received a package. Prepare for processing, ... [10]}
6 if (seqSRi = ack_Ri + 1) do
{If this acknowledgement from Ri is equal to the next ack_Ri, ... [9]}
7 ack_Ri = seqSRi
{... this is the new current acknowledgement from Ri, ...}
8 store KSKRi(S,-,-,seqRi,seqSRi,data)
{... store that you know that Ri knows it.}
9 end
{[6] ... acknowledgement from Ri, and highest group acknowledgement updated.}
10 end
{[5] ... finished processing of incoming package.}
11 end
{... [4].}
Sender (outgoing packages)
1 for (i = 1 to n) do
{For all receiving agents.}
2 if not seqSRi do
{If S did not communicate to Ri before.}
3 seqSRi = x
{Initiate own sequence number for Ri at x.}
4 end
{seqSRi initiated.}
5 end
{seqSRi for all receiving agents initiated.}
6 while true do
{Start sending sequence of messages, ... [20]}
7 compose(data)
{... ,make up the data for this message, ...}
8 store KS(-,-,G,-,-,data)
{... and store this information in your knowledge base.}
9 while (∃ ack_Ri ≠ seqSRi) do
{While not al receivers acknowledged the package with sequence seqSRi, ...[15]}
10 for (i = 1 to n) do
{... ,and for all receiving agents, ...[14]}
11 if not KSKRi(-,-,G,seqRi + 1,seqSRi,data) do
{... check if package `seqSRi' has not been acknowledged yet by Ri, ... [13]}
12 send KS(Ri,-,G,seqSRi,seqRi,data)
{... (re)send the package to Ri.}
13 end
{[11] ... A package that was unacknowledged by Ri, has been resent.}
14 end
{[10] ... A package has been resent to all agents that didn't acknowledge it.}
15 end
{[9] ... all agents Ri have acknowledged the package with sequence number seqSRi.}
16 for (i = 1 to n) do
{For all receiving agents, ... [19]}
17 seqRi = seqRi + 1
{Sequence number of next message from Ri is known. Increment seqRi.}
18 seqSRi = seqSRi + 1
{Increment own sequence number for Ri.}
19 end
{[16] ... Sequence numbers for and from Ri updated.}
20 end
{[6].}
Receiver (incoming packages)
1 while true do
{Get ready for receiving sequence of messages, ... [5]}
2 when received KS(Ri,G,-,seqS,seqRi,data) do
{You have received a package (from S). Prepare for processing, ... [4]}
3 store KRiKS(-,-,G,seqS,seqRi,data)
{Store the received package.}
4 end
{[2] ... finished processing incoming package.}
5 end
{[1].}
Receiver (outgoing packages)
1 when KRiKS(Ri,-,G,x,∅,data)
{The first message is received.}
2 seqS = x
{The first sequence number from S ia x.}
3 seqRi = y
{Initiate own sequence number at y.}
4 while true do
{Get ready to acknowledge incoming packages, ... [11]}
5 compose(data)
{Make up the data for this message. (Possibly a request to act as initiator.)}
6 while not KRiKS(Ri,-,G,seqS+1,seqRi,data) do
{While not received package with 'seqS+1' (and 'seqRi'), ... [8]}
7 send KRi(S,-,-,seqRi,seqS,data)
{... (re)send acknowledgement.}
8 end
{[6] ... You've received message seqS+1 with acknowledgement seqRi.}
9 seqS = seqS + 1
{You now the sequence number of the next message. Increment seqS.}
10 seqRi = seqRi + 1
{Increment own sequence number, seqRi}
11 end
{[4].}