[nanomsg] Short summary of internal nanomsg architecture

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Sun, 03 Feb 2013 07:16:25 +0100

Hi all,

I though some of you may be interested in how nanomsg looks under the cover.

First, have a look at the attached diagram.

COMPONENTS
----------

Basically, there are core classes that provide scaffolding for the rest of the system, then there are transports (inproc, ipc, tcp etc.) and protocols (req/rep, pub/sub, etc.)

CORE
----

The API speaks directly to the core sock object which then dispatches appropriate calls to transports and protocols as necessary.

The core itself is a set of base classes for transports and protocols.

TRANSPORTS
----------

Transport consists endpoint objects (there's a base class nn_ep in the core to derive all endpoints from) and pipe objects (derive it from nn_pipebase core object).

Endpoint is what is created when nn_bind or nn_connect is called. It isn't necessarily a connection. For example, when you bind socket to a TCP port, endpoint "tcp://eth0:5555" is created, but there's no connection yet.

Pipe is an object that consumes and produces messages. It may correspond to e.g. TCP connection, but you are free to implement it in any way you like (reading/writing data to file, console, whatever).

PROTOCOLS
---------

Protocols are what used to be known as messaging patterns (req/rep, pub/sub etc.) I've chosen to use "protocol" name to stress the fact, that SP (as implemented in nanomsg) is a layer in network stack and thus is embodied in a set of protocols.

Theoretically there are "protocols", each of which can contain multiple "socket types". Technically, there's no need for a "protocol" object, so nanomsg defines only nn_sockbase as a base class for all socket types (req, rep, pub, sub etc.)

NOTE
----

To stress the fact that each base class has two facets, that it speaks to the transport- or protocol-specific derived class on one side and to the rest of the core on the other side, each of the baseclasses exposes two interfaces.

nn_sockbase, nn_epbase and nn_pipebase are used to communicate with the derived classes (i.e. specific transprots and protocols).

nn_sock, nn_ep and nn_pipe are used for internal communication inside the core.

Martin

Attachment: nanoarch.png
Description: PNG image

Other related posts: