zmq_pgm.txt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. zmq_pgm(7)
  2. ==========
  3. NAME
  4. ----
  5. zmq_pgm - 0MQ reliable multicast transport using PGM
  6. SYNOPSIS
  7. --------
  8. PGM (Pragmatic General Multicast) is a protocol for reliable multicast
  9. transport of data over IP networks.
  10. DESCRIPTION
  11. -----------
  12. 0MQ implements two variants of PGM, the standard protocol where PGM datagrams
  13. are layered directly on top of IP datagrams as defined by RFC 3208 (the 'pgm'
  14. transport) and "Encapsulated PGM" or EPGM where PGM datagrams are encapsulated
  15. inside UDP datagrams (the 'epgm' transport).
  16. The 'pgm' and 'epgm' transports can only be used with the 'ZMQ_PUB' and
  17. 'ZMQ_SUB' socket types.
  18. Further, PGM sockets are rate limited by default. For details, refer to the
  19. 'ZMQ_RATE', and 'ZMQ_RECOVERY_IVL' options documented in
  20. linkzmq:zmq_setsockopt[3].
  21. CAUTION: The 'pgm' transport implementation requires access to raw IP sockets.
  22. Additional privileges may be required on some operating systems for this
  23. operation. Applications not requiring direct interoperability with other PGM
  24. implementations are encouraged to use the 'epgm' transport instead which does
  25. not require any special privileges.
  26. ADDRESSING
  27. ----------
  28. A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an
  29. 'address'. The 'transport' specifies the underlying protocol to use. The
  30. 'address' specifies the transport-specific address to connect to.
  31. For the PGM transport, the transport is `pgm`, and for the EPGM protocol the
  32. transport is `epgm`. The meaning of the 'address' part is defined below.
  33. Connecting a socket
  34. ~~~~~~~~~~~~~~~~~~~
  35. When connecting a socket to a peer address using _zmq_connect()_ with the 'pgm'
  36. or 'epgm' transport, the 'endpoint' shall be interpreted as an 'interface'
  37. followed by a semicolon, followed by a 'multicast address', followed by a colon
  38. and a port number.
  39. An 'interface' may be specified by either of the following:
  40. * The interface name as defined by the operating system.
  41. * The primary IPv4 address assigned to the interface, in its numeric
  42. representation.
  43. NOTE: Interface names are not standardised in any way and should be assumed to
  44. be arbitrary and platform dependent. On Win32 platforms no short interface
  45. names exist, thus only the primary IPv4 address may be used to specify an
  46. 'interface'. The 'interface' part can be omitted, in that case the default one
  47. will be selected.
  48. A 'multicast address' is specified by an IPv4 multicast address in its numeric
  49. representation.
  50. WIRE FORMAT
  51. -----------
  52. Consecutive PGM datagrams are interpreted by 0MQ as a single continuous stream
  53. of data where 0MQ messages are not necessarily aligned with PGM datagram
  54. boundaries and a single 0MQ message may span several PGM datagrams. This stream
  55. of data consists of 0MQ messages encapsulated in 'frames' as described in
  56. linkzmq:zmq_tcp[7].
  57. PGM datagram payload
  58. ~~~~~~~~~~~~~~~~~~~~
  59. The following ABNF grammar represents the payload of a single PGM datagram as
  60. used by 0MQ:
  61. ....
  62. datagram = (offset data)
  63. offset = 2OCTET
  64. data = *OCTET
  65. ....
  66. In order for late joining consumers to be able to identify message boundaries,
  67. each PGM datagram payload starts with a 16-bit unsigned integer in network byte
  68. order specifying either the offset of the first message 'frame' in the datagram
  69. or containing the value `0xFFFF` if the datagram contains solely an
  70. intermediate part of a larger message.
  71. Note that offset specifies where the first message begins rather than the first
  72. message part. Thus, if there are trailing message parts at the beginning of
  73. the packet the offset ignores them and points to first initial message part
  74. in the packet.
  75. The following diagram illustrates the layout of a single PGM datagram payload:
  76. ....
  77. +------------------+----------------------+
  78. | offset (16 bits) | data |
  79. +------------------+----------------------+
  80. ....
  81. The following diagram further illustrates how three example 0MQ frames are laid
  82. out in consecutive PGM datagram payloads:
  83. ....
  84. First datagram payload
  85. +--------------+-------------+---------------------+
  86. | Frame offset | Frame 1 | Frame 2, part 1 |
  87. | 0x0000 | (Message 1) | (Message 2, part 1) |
  88. +--------------+-------------+---------------------+
  89. Second datagram payload
  90. +--------------+---------------------+
  91. | Frame offset | Frame 2, part 2 |
  92. | 0xFFFF | (Message 2, part 2) |
  93. +--------------+---------------------+
  94. Third datagram payload
  95. +--------------+----------------------------+-------------+
  96. | Frame offset | Frame 2, final 8 bytes | Frame 3 |
  97. | 0x0008 | (Message 2, final 8 bytes) | (Message 3) |
  98. +--------------+----------------------------+-------------+
  99. ....
  100. CONFIGURATION
  101. -------------
  102. The PGM is protocol is capable of multicasting data at high rates (500Mbps+)
  103. with large messages (1MB+), however it requires setting the relevent ZMQ socket
  104. options that are documented in linkzmq:zmq_setsockopt[3]:
  105. * The 'ZMQ_RATE' should be set sufficiently high, e.g. 1Gbps
  106. * The 'ZMQ_RCVBUF' should be increased on the subscriber, e.g. 4MB
  107. * The 'ZMQ_SNDBUF' should be increased on the publisher, e.g. 4MB
  108. It's important to note that the 'ZMQ_RCVBUF' and 'ZMQ_SNDBUF' options are
  109. limited by the underlying host OS tx/rx buffer size limit. On linux, these can
  110. be increased for the current session with the following commands:
  111. ....
  112. # set tx/rx buffers to 4MB (default can also be read as the initial buffer size)
  113. sudo sysctl -w net.core.rmem_max=4194304
  114. sudo sysctl -w net.core.wmem_max=4194304
  115. sudo sysctl -w net.core.rmem_default=4194304
  116. sudo sysctl -w net.core.wmem_default=4194304
  117. ....
  118. EXAMPLE
  119. -------
  120. .Connecting a socket
  121. ----
  122. // Connecting to the multicast address 239.192.1.1, port 5555,
  123. // using the first Ethernet network interface on Linux
  124. // and the Encapsulated PGM protocol
  125. rc = zmq_connect(socket, "epgm://eth0;239.192.1.1:5555");
  126. assert (rc == 0);
  127. // Connecting to the multicast address 239.192.1.1, port 5555,
  128. // using the network interface with the address 192.168.1.1
  129. // and the standard PGM protocol
  130. rc = zmq_connect(socket, "pgm://192.168.1.1;239.192.1.1:5555");
  131. assert (rc == 0);
  132. ----
  133. SEE ALSO
  134. --------
  135. linkzmq:zmq_connect[3]
  136. linkzmq:zmq_setsockopt[3]
  137. linkzmq:zmq_tcp[7]
  138. linkzmq:zmq_ipc[7]
  139. linkzmq:zmq_inproc[7]
  140. linkzmq:zmq_vmci[7]
  141. linkzmq:zmq[7]
  142. AUTHORS
  143. -------
  144. This page was written by the 0MQ community. To make a change please
  145. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.