| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/docs.R |
| 3 |
\name{protocols} |
| 4 |
\alias{protocols} |
| 5 |
\title{Protocols (Documentation)} |
| 6 |
\description{ |
| 7 |
Protocols implemented by \pkg{nanonext}. |
| 8 |
|
| 9 |
For an authoritative guide please refer to the online documentation for the |
| 10 |
NNG library at \url{https://nng.nanomsg.org/man/}. |
| 11 |
} |
| 12 |
\section{Bus (mesh networks)}{ |
| 13 |
|
| 14 |
|
| 15 |
\strong{[protocol, bus]} The bus protocol is useful for routing applications or |
| 16 |
for building mesh networks where every peer is connected to every other peer. |
| 17 |
|
| 18 |
In this protocol, each message sent by a node is sent to every one of its |
| 19 |
directly-connected peers. This protocol may be used to send and receive |
| 20 |
messages. Sending messages will attempt to deliver to each directly connected |
| 21 |
peer. Indirectly-connected peers will not receive messages. When using this |
| 22 |
protocol to build mesh networks, it is therefore important that a |
| 23 |
fully-connected mesh network be constructed. |
| 24 |
|
| 25 |
All message delivery in this pattern is best-effort, which means that peers |
| 26 |
may not receive messages. Furthermore, delivery may occur to some, all, or |
| 27 |
none of the directly connected peers (messages are not delivered when peer |
| 28 |
nodes are unable to receive). Hence, send operations will never block; |
| 29 |
instead if the message cannot be delivered for any reason it is discarded. |
| 30 |
} |
| 31 |
|
| 32 |
\section{Pair (two-way radio)}{ |
| 33 |
|
| 34 |
|
| 35 |
\strong{[protocol, pair]} This is NNG's pair v0. The pair protocol implements a |
| 36 |
peer-to-peer pattern, where relationships between peers are one-to-one. Only |
| 37 |
one peer may be connected to another peer at a time, but both may send and |
| 38 |
receive messages freely. |
| 39 |
|
| 40 |
Normally, this pattern will block when attempting to send a message if no |
| 41 |
peer is able to receive the message. |
| 42 |
} |
| 43 |
|
| 44 |
\section{Poly (one-to-one of many)}{ |
| 45 |
|
| 46 |
|
| 47 |
\strong{[protocol, poly]} This is NNG's pair v1 polyamorous mode. It allows a |
| 48 |
socket to communicate with multiple directly-connected peers. |
| 49 |
|
| 50 |
If no remote peer is specified by the sender, then the protocol willselect |
| 51 |
any available connected peer. |
| 52 |
|
| 53 |
If the peer on the given pipe is not able to receive (or the pipe is no |
| 54 |
longer available, such as if the peer has disconnected), then the message |
| 55 |
will be discarded with no notification to the sender. |
| 56 |
} |
| 57 |
|
| 58 |
\section{Push/Pull (one-way pipeline)}{ |
| 59 |
|
| 60 |
|
| 61 |
In the pipeline pattern, pushers distribute messages to pullers, hence useful |
| 62 |
for solving producer/consumer problems. |
| 63 |
|
| 64 |
If multiple peers are connected, the pattern attempts to distribute fairly. |
| 65 |
Each message sent by a pusher will be sent to one of its peer pullers, chosen |
| 66 |
in a round-robin fashion. This property makes this pattern useful in |
| 67 |
load-balancing scenarios. |
| 68 |
|
| 69 |
\strong{[protocol, push]} The push protocol is one half of a pipeline pattern. |
| 70 |
The other side is the pull protocol. |
| 71 |
|
| 72 |
\strong{[protocol, pull]} The pull protocol is one half of a pipeline pattern. |
| 73 |
The other half is the push protocol. |
| 74 |
} |
| 75 |
|
| 76 |
\section{Publisher/Subscriber (topics & broadcast)}{ |
| 77 |
|
| 78 |
|
| 79 |
In a publisher/subscriber pattern, a publisher sends data, which is broadcast |
| 80 |
to all subscribers. The subscriber only see the data to which they have |
| 81 |
subscribed. |
| 82 |
|
| 83 |
\strong{[protocol, pub]} The pub protocol is one half of a publisher/subscriber |
| 84 |
pattern. This protocol may be used to send messages, but is unable to receive |
| 85 |
them. |
| 86 |
|
| 87 |
\strong{[protocol, sub]} The sub protocol is one half of a publisher/subscriber |
| 88 |
pattern. This protocol may be used to receive messages, but is unable to send |
| 89 |
them. |
| 90 |
} |
| 91 |
|
| 92 |
\section{Request/Reply (RPC)}{ |
| 93 |
|
| 94 |
|
| 95 |
In a request/reply pattern, a requester sends a message to one replier, who |
| 96 |
is expected to reply with a single answer. This is used for synchronous |
| 97 |
communications, for example remote procedure calls (RPCs). |
| 98 |
|
| 99 |
The request is resent automatically if no reply arrives, until a reply is |
| 100 |
received or the request times out. |
| 101 |
|
| 102 |
\strong{[protocol, req]} The req protocol is one half of a request/reply |
| 103 |
pattern. This socket may be used to send messages (requests), and then to |
| 104 |
receive replies. Generally a reply can only be received after sending a |
| 105 |
request. |
| 106 |
|
| 107 |
\strong{[protocol, rep]} The rep protocol is one half of a request/reply |
| 108 |
pattern. This socket may be used to receive messages (requests), and then to |
| 109 |
send replies. Generally a reply can only be sent after receiving a request. |
| 110 |
} |
| 111 |
|
| 112 |
\section{Surveyor/Respondent (voting & service discovery)}{ |
| 113 |
|
| 114 |
|
| 115 |
In a survey pattern, a surveyor sends a survey, which is broadcast to all |
| 116 |
peer respondents. The respondents then have a chance to reply (but are not |
| 117 |
obliged). The survey itself is a timed event, so that responses received |
| 118 |
after the survey has finished are discarded. |
| 119 |
|
| 120 |
\strong{[protocol, surveyor]} The surveyor protocol is one half of a survey |
| 121 |
pattern. This protocol may be used to send messages (surveys), and then to |
| 122 |
receive replies. A reply can only be received after sending a survey. A |
| 123 |
surveyor can normally expect to receive at most one reply from each responder |
| 124 |
(messages may be duplicated in some topologies, so there is no guarantee of |
| 125 |
this). |
| 126 |
|
| 127 |
\strong{[protocol, respondent]} The respondent protocol is one half of a survey |
| 128 |
pattern. This protocol may be used to receive messages, and then to send |
| 129 |
replies. A reply can only be sent after receiving a survey, and generally the |
| 130 |
reply will be sent to the surveyor from which the last survey was received. |
| 131 |
} |
| 132 |
|