Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP support #807

Closed
LindleyF opened this issue Jan 4, 2014 · 36 comments
Closed

UDP support #807

LindleyF opened this issue Jan 4, 2014 · 36 comments

Comments

@LindleyF
Copy link

LindleyF commented Jan 4, 2014

Moving the issue from JIRA:
https://zeromq.jira.com/browse/LIBZMQ-589

The problem: In an environment when messages have a very short time-of-usefulness, it is sometimes necessary to sacrifice reliability for absolutely minimum latency. It's okay if messages are occasionally dropped or occasionally arrive too late, but this percentage should be kept as low as possible, and as close to i.i.d. as possible.
With a protocol like TCP, a dropped packet requires retransmission after a delay. Not only the dropped packet but all later packets are therefore delayed. In the messaging world, this means the dropping of one message could negatively affect the latency of later, unrelated messages, and the distribution of delayed messages is not i.i.d. This is undesirable in latency-critical applications.
While NACK-based protocols like PGM may provide somewhat better behavior in this regard, they still use bandwidth to attempt to restore lost messages without regard to whether or not those messages are still useful. A completely unreliable messaging transport is therefore desirable.
Another advantage of UDP transport is the ability to operate over one-way physical links, such as radio links where the transmitters on one end are much more powerful than the transmitters on the other end.
The UDP transport layer should minimally support IPv4 and IPv6 UDP unicast. IPv4 and IPv6 multicast, as well as IPv4 broadcast and subnet broadcast support, are desirable.
Some work was done on a UDP transport for the Crossroads IO library forked from 0MQ some time ago. I believe this code is a good place to start, although it will require some adaptations to reverse Crossroads-specific changes and implement 0MQ-specific changes since the fork.

I've pushed the changes:
https://github.com/LindleyF/libzmq
Note that this just builds---I doubt very much that it works yet.
Here are the changes so far:
LindleyF@c5f576e
I wasn't sure what to do about the copyright notice so I left the Crossroads text mostly in place, with a note that I modified it for 0MQ.

@hintjens
Copy link
Member

hintjens commented Jan 5, 2014

Mato has kindly said we could use our standard file header. He's already in AUTHORS.

@hoffmabc
Copy link

hoffmabc commented Nov 2, 2014

Have there been any updates on this, specifically unicast UDP support?

@ghost
Copy link

ghost commented Nov 12, 2014

I am also interested in unicast UDP support. Is anyone working on this capability?

@pwm1234
Copy link

pwm1234 commented Oct 27, 2015

I have to add a "me too!" to this issue. I have a need to pub/sub messages where an undelivered message will be out of date and superseded by the next message. Any attempt at adding reliability will result in unnecessary and undesired latency. This is especially true for low-bandwidth and sometimes flaky radio networks. Of course, other networks and scenarios will call for normal zeromq "tcp://" sockets. So I would really like to be able to have an zeromq api that handles both "tcp:" and "udp:" sockets similarly.

Is this still an open issue because a properly "tuned epgm" usage provides the same functionality?

@hintjens
Copy link
Member

I'd love a UDP transport... without the epgm reliability layer, and for
pub/sub.

On Tue, Oct 27, 2015 at 11:21 PM, Phil notifications@github.com wrote:

I have to add a "me too!" to this issue. I have a need to pub/sub messages
where an undelivered message will be out of date and superseded by the next
message. Any attempt at adding reliability will result in unnecessary and
undesired latency. This is especially true for low-bandwidth and sometimes
flaky radio networks. Of course, other networks and scenarios will call for
normal zeromq "tcp://" sockets. So I would really like to be able to have
an zeromq api that handles both "tcp:" and "udp:" sockets similarly.

Is this still an open issue because a properly "tuned epgm" usage provides
the same functionality?


Reply to this email directly or view it on GitHub
#807 (comment).

@ferologics
Copy link

bump

@hintjens
Copy link
Member

I'm closing this issue because, guess what... @somdoron built UDP support into the new RADIO / DISH socket types. Go ahead, play with it, see what it feels like... :)

@AnCaPepe
Copy link
Contributor

AnCaPepe commented Apr 28, 2016

Great ! Is there any available documentation for it yet ?

@hitstergtd
Copy link
Member

@Bitiquinho, et. al. -
Yes it is definitely great. There are no manual pages as of yet, I am guessing @somdoron or someone will cough something up in the near future. However, there is a test program called test_udp.cpp which is fairly self explanatory.

PR #1737 is a good place to look at as well, since it is recent and outlines how the support was added. UDP support works with the Radio/Dish socket types; it is similar to Pub/Sub but with thread-safety. Support for the UDP transport via Radio/Dish was also subsequently added into CZMQ.

Hope that helps.

@AnCaPepe
Copy link
Contributor

@hitstergtd, that helps a lot. Thank you !

@somdoron
Copy link
Member

@Bitiquinho I just sent a pull request with docs:

#1934

@AnCaPepe
Copy link
Contributor

@somdoron Really nice ! Thanks a lot !

@hitstergtd
Copy link
Member

@somdoron,
I have updated the ZeroMQ features page as well, it now reads:

libzmq can talk over TCP, IPC (on POSIX), inproc, TIPC (a nice protocol from Ericsson), PGM (reliable multicast), NORM (another reliable multicast protocol), and SOCKS5, so presumably it can also run over Tor. The majority of other ZeroMQ engines focus on TCP, the lingua franca of distributed computing. Since version 4.2, libzmq also has UDP support in unicast and multicast modes.

Hope that is OK.

@somdoron
Copy link
Member

Great, which page is that? Im trying to find how to update the zeromq.org
with latest docs.
On Apr 29, 2016 17:18, "Hitster GTD" notifications@github.com wrote:

@somdoron https://github.com/somdoron,
I have updated the ZeroMQ features page as well, it now reads:

libzmq can talk over TCP, IPC (on POSIX), inproc, TIPC (a nice protocol
from Ericsson), PGM (reliable multicast), NORM (another reliable multicast
protocol), and SOCKS5, so presumably it can also run over Tor. The majority
of other ZeroMQ engines focus on TCP, the lingua franca of distributed
computing. Since version 4.2, libzmq also has UDP support in unicast and
multicast modes
.

Hope that is OK.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#807 (comment)

@hitstergtd
Copy link
Member

hitstergtd commented Apr 29, 2016

It is:
http://zeromq.org/docs:features

You will need to register as a user with wikidot.com first, but that's a painless process, and then it is just a matter of opening the aforementioned page and clicking Edit at the bottom.

I have also noticed that other parts of the site need to be updated as well with regard to stuff in 4.2/master but have not managed to make a list of them as of yet. I will get to that sometime next week.

@somdoron
Copy link
Member

I think there is a way to automatic generate the zeromq.org docs from
source. @hintjens?
On Apr 29, 2016 17:44, "Hitster GTD" notifications@github.com wrote:

It is:
http://zeromq.org/docs:features

You will need to register as a user with wikidot.com first, but that's a
painless process, and then it is just a matter of opening the
aforementioned page and clicking Edit at the bottom. I noticed that other
parts of the site need to be updated as well with regard to stuff in
4.2/master but have not managed to make a list of them as of yet. I will
get to that sometime next week.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#807 (comment)

@hitstergtd
Copy link
Member

hitstergtd commented Apr 29, 2016

I think that is just for the API and the ZGuide, which both can be updated in GitHub and I think PH triggered a site update manually for them. That process probably needs to be handed over too.

The ZeroMQ.org site itself is based on WikiDot.

@hintjens
Copy link
Member

not the wiki, its made by hand.
On 29 Apr 2016 16:49, "Doron Somech" notifications@github.com wrote:

I think there is a way to automatic generate the zeromq.org docs from
source. @hintjens?
On Apr 29, 2016 17:44, "Hitster GTD" notifications@github.com wrote:

It is:
http://zeromq.org/docs:features

You will need to register as a user with wikidot.com first, but that's a
painless process, and then it is just a matter of opening the
aforementioned page and clicking Edit at the bottom. I noticed that other
parts of the site need to be updated as well with regard to stuff in
4.2/master but have not managed to make a list of them as of yet. I will
get to that sometime next week.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#807 (comment)


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#807 (comment)

@ziadkassam
Copy link

Hello,
I downloaded the latest version of ZMQ, and I want to use the UDP feature (C++), anyone can help me please?!

@ziadkassam
Copy link

error: ‘ZMQ_RADIO’ was not declared in this scope
zmq::socket_t socket (context, ZMQ_RADIO);

@jamesdillonharvey
Copy link
Contributor

jamesdillonharvey commented Oct 10, 2018 via email

@ziadkassam
Copy link

Yes, but is it right like that:

server.cpp:
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_DISH);
socket.bind ("udp://*:5557");

client.cpp:
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_RADIO);
std::cout << "Connecting to hello world server..." << std::endl;
socket.connect ("udp://localhost:5557");

@jamesdillonharvey
Copy link
Contributor

jamesdillonharvey commented Oct 10, 2018 via email

@ziadkassam
Copy link

How can I do this?

@ziadkassam
Copy link

I put this at the beginning of the code:
#ifdef ZMQ_BUILD_DRAFT_API

//DRAFT Socket types.                                                       

#define ZMQ_SERVER 12
#define ZMQ_CLIENT 13
#define ZMQ_RADIO 14
#define ZMQ_DISH 15
#define ZMQ_GATHER 16
#define ZMQ_SCATTER 17
#define ZMQ_DGRAM 18
#endif

@jamesdillonharvey
Copy link
Contributor

jamesdillonharvey commented Oct 10, 2018 via email

@ziadkassam
Copy link

still the error

@ziadkassam
Copy link

#define ZMQ_BUILD_DRAFT_API
#include <zmq.hpp>
#include
#include

int main ()
{

//  Prepare our context and socket
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_RADIO);

std::cout << "Connecting to hello world server..." << std::endl;
socket.connect ("udp://localhost:5557");

@ziadkassam
Copy link

I put this part:
#ifdef ZMQ_BUILD_DRAFT_API

//DRAFT Socket types.
#define ZMQ_SERVER 12
#define ZMQ_CLIENT 13
#define ZMQ_RADIO 14
#define ZMQ_DISH 15
#define ZMQ_GATHER 16
#define ZMQ_SCATTER 17
#define ZMQ_DGRAM 18
#endif

Compiled normally, but the following error appears:
terminate called after throwing an instance of 'zmq::error_t'
what(): Invalid argument
Aborted (core dumped)

@jamesdillonharvey
Copy link
Contributor

jamesdillonharvey commented Oct 10, 2018 via email

@ziadkassam
Copy link

  1. make sure you have configured (then compiled) libzmq with --enable-drafts
    "Please can you tell me these steps?"
    I made them like that:
    ./autogen.sh
    ./configure && make check
    sudo make install
    sudo ldconfig

  2. When you compile your code give g++ the option -DZMQ_BUILD_DRAFT_API=1
    I put the following code in the client.cpp header:
    // These functions are DRAFT and disabled in stable releases, and subject to
    // change at ANY time until declared stable.
    #ifdef ZMQ_BUILD_DRAFT_API

    //DRAFT Socket types.
    #define ZMQ_SERVER 12
    #define ZMQ_CLIENT 13
    #define ZMQ_RADIO 14
    #define ZMQ_DISH 15
    #define ZMQ_GATHER 16
    #define ZMQ_SCATTER 17
    #define ZMQ_DGRAM 18
    #endif

@ziadkassam
Copy link

If that doesn't work then try using pkg-config as bluca suggest in the
issue I linked earlier.
How can I do this?

@somdoron
Copy link
Member

Run the following in the libzmq lib (assuming you already run ./autogen.sh)

./configure  --enable-drafts
make
sudo make install

Do one of the following, depending on your build system

  • Before including zmq.h do #define ZMQ_BUILD_DRAFT_API 1.
  • Add the following argument when running gcc -DZMQ_BUILD_DRAFT_API=1
  • Use your build system to define the flag ZMQ_BUILD_DRAFT_API.

@ziadkassam
Copy link

still not working:

error: ‘ZMQ_DISH’ was not declared in this scope
zmq::socket_t socket (context, ZMQ_DISH);

@ziadkassam
Copy link

But when I put on top of the code server.cpp and client.cpp, the compile works correctly, but I receive the error:
terminate called after throwing an instance of 'zmq::error_t'
what(): Invalid argument
Aborted (core dumped)

@ussefdesouky
Copy link

I'm closing this issue because, guess what... @somdoron built UDP support into the new RADIO / DISH socket types. Go ahead, play with it, see what it feels like... :)

Is it supported in zmqpp or it is supported in the cppzmq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests