Skip to content

Commit e71471b

Browse files
committed
Add new option ZMQ_MULTICAST_MAXTPDU to set PGM_MTU.
Fixes zeromq#1646
1 parent 5d04dc3 commit e71471b

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

doc/zmq_getsockopt.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,21 @@ Default value:: 1
410410
Applicable socket types:: all, when using multicast transports
411411

412412

413+
ZMQ_MULTICAST_MAXTPDU: Maximum transport data unit size for multicast packets
414+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415+
The 'ZMQ_MULTICAST_MAXTPDU' option shall retrieve the maximum transport
416+
data unit size used for outbound multicast packets.
417+
418+
This must be set at or below the minimum Maximum Transmission Unit (MTU) for
419+
all network paths over which multicast reception is required.
420+
421+
[horizontal]
422+
Option value type:: int
423+
Option value unit:: bytes
424+
Default value:: 1500
425+
Applicable socket types:: all, when using multicast transports
426+
427+
413428
ZMQ_PLAIN_PASSWORD: Retrieve current password
414429
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415430
The 'ZMQ_PLAIN_PASSWORD' option shall retrieve the last password set for

doc/zmq_setsockopt.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,21 @@ Default value:: 1
434434
Applicable socket types:: all, when using multicast transports
435435

436436

437+
ZMQ_MULTICAST_MAXTPDU: Maximum transport data unit size for multicast packets
438+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439+
Sets the maximum transport data unit size used for outbound multicast
440+
packets.
441+
442+
This must be set at or below the minimum Maximum Transmission Unit (MTU) for
443+
all network paths over which multicast reception is required.
444+
445+
[horizontal]
446+
Option value type:: int
447+
Option value unit:: bytes
448+
Default value:: 1500
449+
Applicable socket types:: all, when using multicast transports
450+
451+
437452
ZMQ_PLAIN_PASSWORD: Set PLAIN security password
438453
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439454
Sets the password for outgoing connections over TCP or IPC. If you set this

include/zmq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ ZMQ_EXPORT uint32_t zmq_msg_routing_id (zmq_msg_t *msg);
325325
#define ZMQ_THREAD_SAFE 81
326326
#define ZMQ_TCP_RECV_BUFFER 82
327327
#define ZMQ_TCP_SEND_BUFFER 83
328+
#define ZMQ_MULTICAST_MAXTPDU 84
328329

329330
/* Message options */
330331
#define ZMQ_MORE 1

src/config.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ namespace zmq
8484
// possible latencies.
8585
clock_precision = 1000000,
8686

87-
// Maximum transport data unit size for PGM (TPDU).
88-
pgm_max_tpdu = 1500,
89-
9087
// On some OSes the signaler has to be emulated using a TCP
9188
// connection. In such cases following port is used.
9289
// If 0, it lets the OS choose a free port without requiring use of a

src/options.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ zmq::options_t::options_t () :
4141
rate (100),
4242
recovery_ivl (10000),
4343
multicast_hops (1),
44+
multicast_maxtpdu (1500),
4445
sndbuf (-1),
4546
rcvbuf (-1),
4647
tos (0),
@@ -211,6 +212,13 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
211212
}
212213
break;
213214

215+
case ZMQ_MULTICAST_MAXTPDU:
216+
if (is_int && value > 0) {
217+
multicast_maxtpdu = value;
218+
return 0;
219+
}
220+
break;
221+
214222
case ZMQ_RCVTIMEO:
215223
if (is_int && value >= -1) {
216224
rcvtimeo = value;
@@ -735,6 +743,13 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
735743
}
736744
break;
737745

746+
case ZMQ_MULTICAST_MAXTPDU:
747+
if (is_int) {
748+
*value = multicast_maxtpdu;
749+
return 0;
750+
}
751+
break;
752+
738753
case ZMQ_RCVTIMEO:
739754
if (is_int) {
740755
*value = rcvtimeo;

src/options.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ namespace zmq
7979
// Sets the time-to-live field in every multicast packet sent.
8080
int multicast_hops;
8181

82+
// Sets the maximum transport data unit size in every multicast
83+
// packet sent.
84+
int multicast_maxtpdu;
85+
8286
// SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
8387
int sndbuf;
8488
int rcvbuf;

src/pgm_socket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
209209
goto err_abort;
210210
}
211211

212-
const int max_tpdu = (int) pgm_max_tpdu;
212+
const int max_tpdu = (int) options.multicast_maxtpdu;
213213
if (!pgm_setsockopt (sock, IPPROTO_PGM, PGM_MTU, &max_tpdu,
214214
sizeof (max_tpdu)))
215215
goto err_abort;
216216
}
217217

218218
if (receiver) {
219219
const int recv_only = 1,
220-
rxw_max_tpdu = (int) pgm_max_tpdu,
220+
rxw_max_tpdu = (int) options.multicast_maxtpdu,
221221
rxw_sqns = compute_sqns (rxw_max_tpdu),
222222
peer_expiry = pgm_secs (300),
223223
spmr_expiry = pgm_msecs (25),
@@ -250,7 +250,7 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
250250
else {
251251
const int send_only = 1,
252252
max_rte = (int) ((options.rate * 1000) / 8),
253-
txw_max_tpdu = (int) pgm_max_tpdu,
253+
txw_max_tpdu = (int) options.multicast_maxtpdu,
254254
txw_sqns = compute_sqns (txw_max_tpdu),
255255
ambient_spm = pgm_secs (30),
256256
heartbeat_spm[] = { pgm_msecs (100),

0 commit comments

Comments
 (0)