[gnutls-help] DTLS and retransmission and reordering

Joke de Buhr joke at seiken.de
Wed Apr 10 23:10:02 CEST 2013


On Wednesday 10 April 2013 22:20:23 Nikos Mavrogiannopoulos wrote:
> On 04/10/2013 06:07 PM, Joke de Buhr wrote:
> > yes i'm using the non-blocking mode. for client and server sesssion.
> > 
> >   gnutls_init(&session_, GNUTLS_DATAGRAM | GNUTLS_NONBLOCK | ...);
> > 
> > here is a stack trace where the pull function is called:
> > 
> > #0 _gnutls_io_check_recv() at /lib/gnutls_buffers.c:677
> > #1 _dtls_wait_and_retransmit() at /lib/gnutls_dtls.c:414
> > #2 _gnutls_recv_handshake_final() at /lib/gnutls_handshake.c:2883
> > #3 _gnutls_handshake_client() at /lib/gnutls_handshake.c:2730
> > #4 gnutls_handshake() at /lib/gnutls_handshake.c:2450
> > #5 session<server::gateway<server::server<boost::asio::ip::udp> >
> > 
> >> ::handshake() at /home/joke/Projects/vpn/src/session.t++:175
> > 
> > the pull timeout function returns GNUTLS_E_AGAIN.
> > but _dtls_retransmit is called only if the return value was
> > GNUTLS_E_TIMEDOUT.
> That's pretty correct. _gnutls_io_check_recv() returns
> GNUTLS_E_TIMEDOUT, zero or fatal error values.
> 
> Your pull timeout function should return 0 on timeout, a positive number
> if data can be received and -1 on error. I'll make the documentation
> more clear on that, but in your case you should have returned zero
> instead of EAGAIN.

i see the point especially if i would use a traditional select based approach 
while waiting for a timeout.


but let's assume:

the handshake timeout isn't set at all. my pull timeout function should never 
block. 

as a consequence the pull_timeout_function() will always get called with an 
timeout value of 0. should i return 0 or set gnutls EAGAIN value and return -1 
if no new data is available? i can't wait using select. the function can't 
block. if data is available handshake() or receive() will be called.


now the handshake() will return a value of GNUTLS_EAGAIN and i use 
gnutls_dtls_get_timeout() and set a timer waiting for this particular session 
to run out while in the mean time i handle other session. if the timer for 
this particular session runs out the handshake function is called again.


regards
joke

> regards,
> Nikos



More information about the Gnutls-help mailing list