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

Implement UDP #5697

Merged
merged 2 commits into from
Feb 12, 2014
Merged

Implement UDP #5697

merged 2 commits into from
Feb 12, 2014

Conversation

Keno
Copy link
Member

@Keno Keno commented Feb 6, 2014

@StefanKarpinski I figured it'd be faster if I did it myself. This needs some more tests and documentation (if you wouldn't mind taking care of that), but other than that this is good to go.

@@ -1102,6 +1105,7 @@ export
write,
writecsv,
writedlm,
UdpSocket,
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks strange. UDP is an acronym so shouldn't it be all caps UDPSocket. (also, why is it TcpServer, not TCPServer, etc?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for more consistent use of caps

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, I did it for consistency with TCP, I'd vote for leaving this as is for this PR and then if we decide to rename, we can do that in one commit for both.

@staticfloat
Copy link
Sponsor Member

+1 for TCPxxx and UDPxxx, although that will be a breaking change.

c_free(buf_addr)
notify_error(sock.recvnotify,"Partial message received")
end
buf = pointer_to_array(convert(Ptr{Uint8},buf_addr),int(buf_size),true)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use int(nread) here and avoid the extra copy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I suppose that's a good idea.

@G3UKB
Copy link

G3UKB commented Feb 7, 2014

As I started this I guess I should give some input. I'm no expert, just a user, but having used this protocol for the same application in a few different languages (last one was go) here is what I would need. I've added the relevant code in go syntax.

  1. Listen on all adapters.
    udpAddr, err := net.ResolveUDPAddr("up4", ":0")
    conn, err = net.ListenUDP("udp", udpAddr)
  2. Set buffers. This is essential to stop overflow (real-time data) and be able to buffer a number of messages. Messages are 1032 bytes and I want to block on writing.
    conn.SetReadBuffer(103200)
    conn.SetWriteBuffer(1032)
  3. I then need to send a broadcast message.
    dst, err := net.ResolveUDPAddr("udp", "255.255.255.255:1024")
    conn.WriteTo(msg, dst)
  4. Finally listen for broadcast responses with a timeout.
    set_timeout(conn, 5e9)
    n, peer, err := conn.ReadFrom(resp)
  5. I'm then into straight forward data exchanges reading, processing and outputting 1032 byte messages.

I would just add that I believe its normal to do ones own management so I would not for example expect an error to be thrown if a packet is dropped nor get partial packets. I have sequence numbers in all packets so I detect dropped and out of sequence packets. I don't know if this is standard but it seems logical to me on an unreliable connection.

--bob

@StefanKarpinski
Copy link
Sponsor Member

That is informative. I would still like to try raising an error by default and seeing how that goes. I suspect this doesn't happen much in practice.

@Keno
Copy link
Member Author

Keno commented Feb 8, 2014

Alright, let's leave it like this then.

@bass3m
Copy link

bass3m commented Feb 11, 2014

Any updates on when this will get merged ? For what it's worth, i've been playing around with @loladiro's patch and it works great.

@Keno
Copy link
Member Author

Keno commented Feb 11, 2014

As soon as somebody writes documentation and a few more tests. I'll get to it eventually, but am quite busy at the moment. Feel free to tackle that though.

@bass3m
Copy link

bass3m commented Feb 11, 2014

@loladiro sounds good, i'll see what i can do for some tests and documentation.

@StefanKarpinski
Copy link
Sponsor Member

Shall we merge it and open an issue for documentation and testing? Otherwise someone would have to make a pull request against your pull request...

StefanKarpinski added a commit that referenced this pull request Feb 12, 2014
@StefanKarpinski StefanKarpinski merged commit 6585e3d into master Feb 12, 2014
@StefanKarpinski StefanKarpinski deleted the kf/udp branch February 12, 2014 02:41
@Keno
Copy link
Member Author

Keno commented Feb 12, 2014

Shall we merge it and open an issue for documentation and testing?

Why do I have a feeling that questionmark was rhetorical? ;)

@StefanKarpinski
Copy link
Sponsor Member

Yeah, I realized right after posting that I should just do it instead of suggesting it and waiting for someone else to do it.

@Keno
Copy link
Member Author

Keno commented Feb 12, 2014

That's how things get done.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 12, 2014

I would do that with #3796, but somehow I feel that's how things get un-done. Unless someone else was to merge it, like Stefan did here...

@StefanKarpinski
Copy link
Sponsor Member

That's a little different – #3796 might break everything. This is quite safe as long as you don't use the new functionality and there's at least one report that the new functionality works nicely.

@StefanKarpinski
Copy link
Sponsor Member

But I am somewhat inclined at this point to just merge it and see what happens.

@bass3m
Copy link

bass3m commented Feb 12, 2014

Thanks for merging it, this will make things easier.

@danluu
Copy link
Contributor

danluu commented Sep 15, 2014

Looks like I'm late to the party here, but I wanted to echo @Bob-C's comment above. I'm not a networking expert, but I've spent some time with UDP and implementing protocols on top of UDP, and I find it pretty surprising that the UDP API throws an exception on a partial packet instead of just dropping it.

Unless you have what is, by non-HPC standards, a fairly exotic setup, packets are expected to get dropped all the time, and throwing an exception on some drops doesn't seem particularly helpful. And if if you have a lossless fabric with a setup that isn't expected to drop anything, it would be pretty unorthodox to use libuv or something that wraps libuv.

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

Successfully merging this pull request may close these issues.

None yet

8 participants