cpacketsctppartial-ordering

SCTP ordered message delivery


Is it possible to force SCTP to send all data completely ordered?

Let's do this experiment:

1) Take this SCTP-discard-server and this SCTP-client.

2) Let the client count to 100 a lot of times and send a byte each time respectively to the server.

for(long i=0; i< 1000000000; i++){
    char temp = (char)(i%100) + 1;
    usrsctp_sendv(
        sock, (void *)&temp, 1,
        NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0
    );
}

3) Let the server count along the same way and compare its number with the received one.

printf("%d %d\n", (int)buffer[0], (int)(test));
if ((int)test != (int)buffer[0]) break;

Some seconds later:

66 66
67 67
68 68
69 69
51 70

Voila!

I compiled this with $ gcc discard_server.c -Wall -lusrsctp using gcc7.3.0 on my Ubuntu 18.04 machine. And yes, I have already tried disabling every kind of nagel-algorithms via SCTP_NODELAY.

What did I miss? Thanks in advance for any hint.


Solution

  • I found out, that usrsctp_sendv(..) can fail, if the socket buffer is full for example. This is what happened.

    I tried while(usrsctp_sendv(..) < 0) and now client and server count along the right way.