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

Single thread #339

Merged
merged 19 commits into from
Aug 12, 2019
Merged

Single thread #339

merged 19 commits into from
Aug 12, 2019

Conversation

jmillan
Copy link
Contributor

@jmillan jmillan commented Aug 7, 2019

Based on 010fcbc

@lgrahl
Copy link
Contributor

lgrahl commented Aug 7, 2019

Nit: You should probably attribute @ccaughie in the commits with git commit --author or just in the comment.

@jmillan
Copy link
Contributor Author

jmillan commented Aug 7, 2019

Nit: You should probably attribute @ccaughie in the commits with git commit --author or just in the comment.

The main commit indicates that it is based on another which is authored by @ccaughie.

I'll add him explicitly in the comment.

@weinrank
Copy link
Contributor

weinrank commented Aug 7, 2019

Please add the st_client.c program to the CMake configuration.

@jmillan
Copy link
Contributor Author

jmillan commented Aug 7, 2019

I'll add him explicitly in the comment.

Done.

Please add the st_client.c program to the CMake configuration.

Done.

@weinrank
Copy link
Contributor

weinrank commented Aug 7, 2019

Please fix compiler warning:

st_client.c: In function ‘handle_packets’:
st_client.c:82:6: error: variable ‘retval’ set but not used [-Werror=unused-but-set-variable]
  int retval;
      ^~~~~~
/bin/bash ../libtool  --tag=CC   --mode=link gcc  -g -O2 -std=c99 -pthread -D_GNU_SOURCE -pedantic -Wall -Werror -g -O0   -o test_libmgmt programs_helper.o test_libmgmt.o ../usrsctplib/libusrsctp.la 
cc1: all warnings being treated as errors
make[1]: *** [Makefile:677: st_client.o] Error 1
make[1]: *** Waiting for unfinished jobs....

@jmillan
Copy link
Contributor Author

jmillan commented Aug 7, 2019

Please fix compiler warning:

Done, I was not getting such warning.

@weinrank
Copy link
Contributor

weinrank commented Aug 7, 2019

OS: FreeBSD

st_client.c:69:17: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
        return clock() / clocks_per_msec;
                       ^ ~~~~~~~~~~~~~~~
1 error generated.
*** [st_client.o] Error code 1

OS: NetBSD & Ubuntu

/home/buildbot/bbw-weinrank/netbsd/build/usrsctplib/user_socket.c:81:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
 static void init_sync() {
             ^

OS: Windows MINGW

C:\Users\buildbot\bbw-weinrank\windows-7-cmake-MinGW-64\build\usrsctplib\user_socket.c:2426:20: error: comparison of integer expressions of different signedness: 'socklen_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare]
    if (*option_len < sizeof(int)) {
                    ^
cc1.exe: all warnings being treated as errors
``

@ibc
Copy link

ibc commented Aug 7, 2019

OS: NetBSD & Ubuntu

/home/buildbot/bbw-weinrank/netbsd/build/usrsctplib/user_socket.c:81:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
 static void init_sync() {
             ^

This should be fixed by doing:

static void init_sync(void) {

OS: Windows MINGW

C:\Users\buildbot\bbw-weinrank\windows-7-cmake-MinGW-64\build\usrsctplib\user_socket.c:2426:20: error: comparison of integer expressions of different signedness: 'socklen_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare]
    if (*option_len < sizeof(int)) {
                    ^
cc1.exe: all warnings being treated as errors
``

This should be fixed by doing:

if (*option_len < (socklen_t)(sizeof(int))) {

tuexen added a commit that referenced this pull request Aug 7, 2019
This is cherry picked from #339, since it is not related.

if ((sb->sb_flags & SB_UPCALL) && so->so_upcall != NULL)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do really not know why this change.

Copy link
Contributor Author

@jmillan jmillan Aug 7, 2019

Choose a reason for hiding this comment

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

@tuexen, as said, this is an extract from #38. I've tried to extract merely the parts related to the single thread. We've tested quite intensively and it's working as per our usage. I cannot determine the reason of such change nor whether it is necessary or not.

Please, feel free to edit the code if needed.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is not needed. We currently call the upcall after we processed the triggering event. So please remove it.

Copy link

Choose a reason for hiding this comment

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

usrsctplib/user_socket.c Outdated Show resolved Hide resolved
usrsctplib/user_socket.c Outdated Show resolved Hide resolved
usrsctplib/usrsctp.h Outdated Show resolved Hide resolved
usrsctplib/usrsctp.h Outdated Show resolved Hide resolved
usrsctplib/usrsctp.h Outdated Show resolved Hide resolved
@jmillan
Copy link
Contributor Author

jmillan commented Aug 7, 2019

OS: FreeBSD

st_client.c:69:17: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
        return clock() / clocks_per_msec;
                       ^ ~~~~~~~~~~~~~~~
1 error generated.
*** [st_client.o] Error code 1

OS: NetBSD & Ubuntu

/home/buildbot/bbw-weinrank/netbsd/build/usrsctplib/user_socket.c:81:13: error: function declaration isn't a prototype [-Werror=strict-prototypes]
 static void init_sync() {
             ^

OS: Windows MINGW

C:\Users\buildbot\bbw-weinrank\windows-7-cmake-MinGW-64\build\usrsctplib\user_socket.c:2426:20: error: comparison of integer expressions of different signedness: 'socklen_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare]
    if (*option_len < sizeof(int)) {
                    ^
cc1.exe: all warnings being treated as errors
``

@weinrank, I have a macOs in my hand, please feel free to make the required modifications to the code.

@ibc
Copy link

ibc commented Aug 7, 2019

OS: FreeBSD

st_client.c:69:17: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
        return clock() / clocks_per_msec;
                       ^ ~~~~~~~~~~~~~~~
1 error generated.
*** [st_client.o] Error code 1

No idea about how to fix this error in FreeBSD. The exact code is:

static const clock_t clocks_per_msec = CLOCKS_PER_SEC / 1000;
return clock() / clocks_per_msec;

How can it complain? CLOCKS_PER_SEC documentation:

https://en.cppreference.com/w/c/chrono/CLOCKS_PER_SEC

Perhaps #include <time.h> must be included in the usrsctp/programs/st_client.c file?:

@tuexen
Copy link
Member

tuexen commented Aug 7, 2019

OS: FreeBSD

st_client.c:69:17: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
        return clock() / clocks_per_msec;
                       ^ ~~~~~~~~~~~~~~~
1 error generated.
*** [st_client.o] Error code 1

No idea about how to fix this error in FreeBSD. The exact code is:

static const clock_t clocks_per_msec = CLOCKS_PER_SEC / 1000;
return clock() / clocks_per_msec;

How can it complain? CLOCKS_PER_SEC documentation:

https://en.cppreference.com/w/c/chrono/CLOCKS_PER_SEC

Perhaps #include <time.h> must be included in the usrsctp/programs/st_client.c file?:

The reason of the error is that on FreeBSD CLOCKS_PER_SEC is defined as 128, so clocks_per_msec is zero.
It might be better to use a function like gettimeofday().

programs/st_client.c Outdated Show resolved Hide resolved
tv.tv_sec = wait_time / 1000;
tv.tv_usec = (wait_time % 1000) * 1000;

select(1, &rfds, NULL, NULL, &tv);
Copy link
Member

Choose a reason for hiding this comment

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

Does this really work? rfds need to be setup up with

FD_ZERO(&rfds);
FD_SET(sock, &rfds);

before each select() call. You also need to use sock + 1 as its first argument.


select(1, &rfds, NULL, NULL, &tv);

length = recv(sock, buf, MAX_PACKET_SIZE, 0);
Copy link
Member

Choose a reason for hiding this comment

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

I think you only want to do this if FD_ISSET(sock, rdfs) is true. If that is not true, you can't read anything from the socket.

Copy link

Choose a reason for hiding this comment

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

Hi @tuexen. Honestly this st_client.c is at it was in the original PR. Indeed we cannot make it work. I'm adding changes told by you and also documenting into it how to use it:

/*
 * Usage: st_client local_addr local_port remote_addr remote_port remote_sctp_port
 */

I've added some prints into st_client.c to figure out what is happening:

		wait_time = next_fire_time - now;
		tv.tv_sec = wait_time / 1000;
		tv.tv_usec = (wait_time % 1000) * 1000;

		FD_ZERO(&rfds);
		FD_SET(sock, &rfds);

		if (FD_ISSET(sock, &rfds))
			printf("--- FD_ISSET(sock, &rfds): yes\n");

		printf("--- calling select()\n");

		select(sock + 1, &rfds, NULL, NULL, &tv);

		printf("--- calling recv() 2\n");

		length = recv(sock, buf, MAX_PACKET_SIZE, 0);

		printf("--- recv() returned, length:%zu\n", length);

		if (length > 0) {
			if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
				fprintf(stderr, "%s", dump_buf);
				usrsctp_freedumpbuffer(dump_buf);
			}
			usrsctp_conninput(sconn_addr, buf, (size_t)length, 0);
		}
	}

Testing it:

# run server
$ ./echo_server 11111 22222

# run client
$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 11111

It produces zero output in the server and this output in the client:

O 16:20:33.113793 0000 f9 7d 2b 67 00 00 00 00 68 43 df cd 01 00 00 56 1c ce f2 40 00 02 00 00 00 0a 08 00 08 eb c4 6b c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 f6 82 90 8c a6 0d 41 8d ef 6c 26 22 c5 43 3c ec 43 25 62 64 28 8e 77 42 de ab 4a e8 92 45 99 aa 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET
--- FD_ISSET(sock, &rfds): yes
--- calling select()
--- calling recv() 2

and it gets stuck in the length = recv(sock, buf, MAX_PACKET_SIZE, 0); line.

Copy link
Member

Choose a reason for hiding this comment

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

Try something like:

		wait_time = next_fire_time - now;
		tv.tv_sec = wait_time / 1000;
		tv.tv_usec = (wait_time % 1000) * 1000;

		FD_ZERO(&rfds);
		FD_SET(sock, &rfds);

		printf("--- calling select()\n");

		select(sock + 1, &rfds, NULL, NULL, &tv);
		if (FD_ISSET(sock, &rfds)) {
			printf("--- FD_ISSET(sock, &rfds): yes\n");

			printf("--- calling recv() 2\n");

			length = recv(sock, buf, MAX_PACKET_SIZE, 0);

			printf("--- recv() returned, length:%zu\n", length);

			if (length > 0) {
				if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
					fprintf(stderr, "%s", dump_buf);
					usrsctp_freedumpbuffer(dump_buf);
				}
				usrsctp_conninput(sconn_addr, buf, (size_t)length, 0);
			}
		} else {
			printf("--- FD_ISSET(sock, &rfds): no\n");
		}
	}

Copy link

Choose a reason for hiding this comment

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

I'm afraid it just produces this output in the client (and nothing in the server):

$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 11111

O 16:42:57.634535 0000 fd 80 2b 67 00 00 00 00 7b 61 7a 09 01 00 00 56 74 5a ce b6 00 02 00 00 00 0a 08 00 ba 43 c8 36 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 ca d1 11 0b cd 3b 90 b9 97 05 7c 28 e7 c9 b2 14 cd e1 91 be 2d 72 82 45 68 9c 1c e1 f1 17 db 56 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET
--- calling select()
--- FD_ISSET(sock, &rfds): no
--- calling select()
--- FD_ISSET(sock, &rfds): no
--- calling select()
--- FD_ISSET(sock, &rfds): no
--- calling select()
--- FD_ISSET(sock, &rfds): no
// etc etc etc

Copy link

Choose a reason for hiding this comment

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

I understand that, even if st_client command line arguments are a bit pain, I'm using them correctly (OSX):

$ lsof -i -n -P | grep -E '(echo_se|st_client)'

echo_serv 25145            ibc    4u  IPv4 0xb020ae295166cc0d      0t0  UDP *:11111
echo_serv 25145            ibc    5u  IPv6 0xb020ae2951670a95      0t0  UDP *:11111
st_client 25554            ibc    3u  IPv4 0xb020ae294236373d      0t0  UDP 127.0.0.1:22222->127.0.0.1:11111

Copy link

Choose a reason for hiding this comment

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

Somehow the echo server is not responding to the st_client:

16:52:30.607280 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100
16:52:30.607293 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100
16:52:33.610211 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100
16:52:33.610226 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100

However, it does reply to the client program:

16:53:49.217415 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 156
16:53:49.217459 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 156
16:53:49.217821 IP 127.0.0.1.11111 > 127.0.0.1.22222: UDP, length 564
16:53:49.217847 IP 127.0.0.1.11111 > 127.0.0.1.22222: UDP, length 564
16:53:49.218336 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 428
16:53:49.218366 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 428
16:53:49.221919 IP 127.0.0.1.11111 > 127.0.0.1.22222: UDP, length 16
16:53:49.221963 IP 127.0.0.1.11111 > 127.0.0.1.22222: UDP, length 16
16:53:49.222080 IP 192.168.1.55.11111 > 192.168.1.55.22222: UDP, length 56
16:53:49.222092 IP 192.168.1.55.11111 > 192.168.1.55.22222: UDP, length 56
16:53:49.222131 IP 5.5.5.5.11111 > 5.5.5.5.22222: UDP, length 56
16:53:49.222142 IP 5.5.5.5.11111 > 5.5.5.5.22222: UDP, length 56
16:53:49.222214 IP6 ::1.11111 > ::1.22222: UDP, length 56
16:53:49.222226 IP6 ::1.11111 > ::1.22222: UDP, length 56
16:53:49.223098 IP 192.168.1.55.22222 > 192.168.1.55.11111: UDP, length 56
16:53:49.223118 IP 192.168.1.55.22222 > 192.168.1.55.11111: UDP, length 56
16:53:49.223258 IP 5.5.5.5.22222 > 5.5.5.5.11111: UDP, length 56
16:53:49.223271 IP 5.5.5.5.22222 > 5.5.5.5.11111: UDP, length 56
16:53:49.223362 IP6 ::1.22222 > ::1.11111: UDP, length 56
16:53:49.223375 IP6 ::1.22222 > ::1.11111: UDP, length 56
16:53:49.224581 IP 192.168.1.55.11111 > 192.168.1.55.22222: UDP, length 56
16:53:49.224594 IP 192.168.1.55.11111 > 192.168.1.55.22222: UDP, length 56
16:53:49.224637 IP6 ::1.22222 > ::1.11111: UDP, length 56
16:53:49.224647 IP6 ::1.22222 > ::1.11111: UDP, length 56
16:53:49.225255 IP6 ::1.11111 > ::1.22222: UDP, length 56
16:53:49.225268 IP6 ::1.11111 > ::1.22222: UDP, length 56
16:53:49.225361 IP 192.168.1.55.22222 > 192.168.1.55.11111: UDP, length 56
16:53:49.225372 IP 192.168.1.55.22222 > 192.168.1.55.11111: UDP, length 56
16:53:49.225438 IP 5.5.5.5.22222 > 5.5.5.5.11111: UDP, length 56
16:53:49.225448 IP 5.5.5.5.22222 > 5.5.5.5.11111: UDP, length 56
16:53:49.225540 IP 5.5.5.5.11111 > 5.5.5.5.22222: UDP, length 56
16:53:49.225553 IP 5.5.5.5.11111 > 5.5.5.5.22222: UDP, length 56

Copy link

Choose a reason for hiding this comment

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

No sure why the server is listed twice...

Because it's listening in IPv4 and IPv6.

If you capture the traffic on the UDP interface, do you see an INIT-ACK encapsulated in UDP? If yes, then there is a problem on the client side. If no, there is a problem on the server side.
Another point: After 1 second there should be a transmission of the INIT. So a timer should run off. Does this happen?

I just see traffic from st_client to echo_server, and yes there are retransmissions (I assume it's the INIT):

// run server:
$ ./echo_server 11111 22222

// run client:
$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 11111

// stdout in client:

16:57:50.374429 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100
16:57:50.374444 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100

// after 2 seconds:
16:57:53.380791 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100
16:57:53.380814 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100

// after 2 seconds:
16:57:59.389498 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100
16:57:59.389521 IP 127.0.0.1.22222 > 127.0.0.1.11111: UDP, length 100

Not sure if relevant, but the UDP packet size in the first message (SCTP INIT) in client is 156 bytes, while in st_client it's 100 bytes.

Copy link

Choose a reason for hiding this comment

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

I'm starting to understand that both echo_server and client use:

sock = usrsctp_socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP...

while in st_client it is:

usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP...

so obviously this won't work...

Copy link

Choose a reason for hiding this comment

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

and here we go:

  • In the server:
$ ./ekr_server 127.0.0.1 11111 127.0.0.1 22222
  • In the client:
$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 11111
  • Logs in the client:
O 17:20:18.738085 0000 e6 03 2b 67 00 00 00 00 db 5e ee 70 01 00 00 56 9f 90 25 4c 00 02 00 00 00 0a 08 00 5a 3b ef b4 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 1c 50 e9 7e b2 02 5e 11 88 a4 2c 1d e8 f7 f8 63 78 2a e8 1b 29 1a 05 61 ab e7 4e d8 d0 49 92 84 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET
--- calling select()
--- FD_ISSET(sock, &rfds): yes
--- calling recv() 2
--- recv() returned, length:16
  • Logs in the server:
I 17:20:18.739651 0000 e6 03 2b 67 00 00 00 00 db 5e ee 70 01 00 00 56 9f 90 25 4c 00 02 00 00 00 0a 08 00 5a 3b ef b4 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 1c 50 e9 7e b2 02 5e 11 88 a4 2c 1d e8 f7 f8 63 78 2a e8 1b 29 1a 05 61 ab e7 4e d8 d0 49 92 84 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

O 17:20:18.746047 0000 2b 67 e6 03 9f 90 25 4c 7a a4 17 76 06 00 00 04 # SCTP_PACKET

Obviously the ekr_server is not a echo server.

Copy link

Choose a reason for hiding this comment

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

Also, st_client can talk to itself:

$ ./st_client 127.0.0.1 11111 127.0.0.1 22222 11111

and

$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 11111

Logs in the first st_client:

O 17:23:57.090391 0000 e8 07 2b 67 00 00 00 00 51 9d 2d f4 01 00 00 56 9d bf 3d d0 00 02 00 00 00 0a 08 00 ae 6b 52 c5 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 98 76 2e 70 04 b2 19 55 21 41 ac 43 5e 57 df 97 b4 08 ae f1 1c 30 5d 2d 26 c2 c7 1f 85 d6 67 41 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

I 17:23:57.091196 0000 2b 67 e8 07 9d bf 3d d0 f1 fb 6f 02 06 00 00 04 # SCTP_PACKET

Logs in the second st_client:

O 17:23:54.605069 0000 e8 e6 2b 67 00 00 00 00 e4 c2 d9 13 01 00 00 56 c4 05 38 55 00 02 00 00 00 0a 08 00 ba 1f f2 42 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 44 d4 42 93 b6 ab 94 b1 05 da 28 e9 9b 47 5d 51 c9 70 e8 a7 1b 3e 47 36 85 83 13 48 e1 23 95 ea 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

I 17:23:57.091071 0000 e8 07 2b 67 00 00 00 00 51 9d 2d f4 01 00 00 56 9d bf 3d d0 00 02 00 00 00 0a 08 00 ae 6b 52 c5 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 98 76 2e 70 04 b2 19 55 21 41 ac 43 5e 57 df 97 b4 08 ae f1 1c 30 5d 2d 26 c2 c7 1f 85 d6 67 41 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

@ibc
Copy link

ibc commented Aug 8, 2019

Thanks @tuexen.

BTW can you please double check this? By removing such a line I've seen my server fail today twice when running some SCTP test units. Then it did not happen again, but I'm a bit afraid.

@tuexen
Copy link
Member

tuexen commented Aug 8, 2019

@ibc: Can you tell me what errors you are observing? What are the failing unit tests testing?

@ibc
Copy link

ibc commented Aug 8, 2019

@tuexen: The unit tests failing are not related to usrsctp. They are unit tests in our server, in which we use node-sctp (SCTP lib for Node) to send and receive SCTP messages through our server (which integrates usrsctp in single-thread mode). Eventually it has failed this morning twice. The error is just that some messages were not received (localhost test, reliable SCTP streams). But, we were compiling and recompiling the server all the time, who knows.

I'll try to verify tomorrow whether it works fine or not and update here. Thanks.

@weinrank
Copy link
Contributor

weinrank commented Aug 9, 2019

Setting sndinfo.snd_sid = 0; did the trick. :)
I've changed the message from a lot of 'A's to 'GET /' and connected to our SCTP webserver.
It works, but I'm not sure if the output is correct.

Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.

Neither the stream (0), TSN (4170287217) nor the PPID (63) is reported correctly.
@tuexen network/host byte order modification is not needed for Stream/TSN, right?

Full output:

weinrank@Idefix3 ➜  programs git:(single) ✗ ./st_client 192.168.1.100 1988 212.201.121.80 9899 80

O 10:40:28.811241 0000 f7 8a 00 50 00 00 00 00 60 c8 89 b6 01 00 00 56 7f fb 6d 93 00 02 00 00 00 0a 08 00 bc 04 11 c3 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 63 8e a9 1f 28 f8 7c ec a8 30 56 36 6e 49 b7 6e 98 b6 19 b4 dd bf 00 7d bf 2c 39 26 f5 b0 e5 16 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

I 10:40:28.833789 0000 00 50 f7 8a 7f fb 6d 93 99 e0 72 83 02 00 01 40 72 13 8f 7c 00 1c 71 c7 00 01 00 01 49 40 37 a5 00 06 00 14 2a 02 c6 a0 40 15 00 11 00 00 00 00 00 00 00 80 00 05 00 08 d4 c9 79 50 00 07 01 10 4b 41 4d 45 2d 42 53 44 20 31 2e 31 00 00 00 00 6b c9 10 01 00 00 00 00 06 a4 00 00 00 00 00 00 60 ea 00 00 00 00 00 00 00 00 00 00 93 6d fb 7f 72 13 8f 7c b9 8f a8 7b 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 d4 c9 79 50 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 f7 8a 00 50 01 01 00 00 00 00 00 00 00 00 00 00 01 00 00 56 7f fb 6d 93 00 02 00 00 00 0a 08 00 bc 04 11 c3 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 63 8e a9 1f 28 f8 7c ec a8 30 56 36 6e 49 b7 6e 98 b6 19 b4 dd bf 00 7d bf 2c 39 26 f5 b0 e5 16 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 02 00 01 40 72 13 8f 7c 00 1c 71 c7 00 01 00 01 49 40 37 a5 00 06 00 14 2a 02 c6 a0 40 15 00 11 00 00 00 00 00 00 00 80 00 05 00 08 d4 c9 79 50 64 00 b7 b0 35 e7 96 44 bd be d1 8a a6 cf 35 3b 7a 62 70 64 # SCTP_PACKET

O 10:40:28.833949 0000 f7 8a 00 50 72 13 8f 7c 6d 4c d5 a9 0a 00 01 10 4b 41 4d 45 2d 42 53 44 20 31 2e 31 00 00 00 00 6b c9 10 01 00 00 00 00 06 a4 00 00 00 00 00 00 60 ea 00 00 00 00 00 00 00 00 00 00 93 6d fb 7f 72 13 8f 7c b9 8f a8 7b 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 d4 c9 79 50 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 f7 8a 00 50 01 01 00 00 00 00 00 00 00 00 00 00 01 00 00 56 7f fb 6d 93 00 02 00 00 00 0a 08 00 bc 04 11 c3 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 63 8e a9 1f 28 f8 7c ec a8 30 56 36 6e 49 b7 6e 98 b6 19 b4 dd bf 00 7d bf 2c 39 26 f5 b0 e5 16 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 02 00 01 40 72 13 8f 7c 00 1c 71 c7 00 01 00 01 49 40 37 a5 00 06 00 14 2a 02 c6 a0 40 15 00 11 00 00 00 00 00 00 00 80 00 05 00 08 d4 c9 79 50 64 00 b7 b0 35 e7 96 44 bd be d1 8a a6 cf 35 3b 7a 62 70 64 # SCTP_PACKET

I 10:40:28.853526 0000 00 50 f7 8a 7f fb 6d 93 c5 09 80 e2 0b 00 00 04 # SCTP_PACKET

O 10:40:28.853691 0000 f7 8a 00 50 72 13 8f 7c 8a 09 59 90 00 03 00 60 bc 04 11 c3 00 00 00 00 00 00 00 27 47 45 54 20 2f 0a 0a 00 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 # SCTP_PACKET

I 10:40:28.872697 0000 00 50 f7 8a 7f fb 6d 93 8b 21 15 cc 03 00 00 10 bc 04 11 c3 00 1c 6f 77 00 00 00 00 # SCTP_PACKET

I 10:40:28.872752 0000 00 50 f7 8a 7f fb 6d 93 18 50 a2 08 00 02 05 a0 49 40 37 a5 00 00 00 00 00 00 00 3f 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 0a 3c 68 74 6d 6c 20 6c 61 6e 67 3d 22 65 6e 22 3e 0a 0a 3c 68 65 61 64 3e 0a 20 20 3c 6d 65 74 61 20 63 68 61 72 73 65 74 3d 22 75 74 66 2d 38 22 3e 0a 20 20 3c 74 69 74 6c 65 3e 48 54 54 50 20 6f 76 65 72 20 53 43 54 50 3c 2f 74 69 74 6c 65 3e 0a 20 20 3c 6d 65 74 61 20 6e 61 6d 65 3d 22 76 69 65 77 70 6f 72 74 22 20 63 6f 6e 74 65 6e 74 3d 22 77 69 64 74 68 3d 64 65 76 69 63 65 2d 77 69 64 74 68 2c 20 69 6e 69 74 69 61 6c 2d 73 63 61 6c 65 3d 31 2e 30 22 3e 0a 20 20 3c 6c 69 6e 6b 20 72 65 6c 3d 22 73 74 79 6c 65 73 68 65 65 74 22 20 68 72 65 66 3d 22 63 73 73 2e 63 73 73 22 3e 0a 0a 3c 2f 68 65 61 64 3e 0a 0a 3c 62 6f 64 79 3e 0a 0a 20 20 3c 68 31 3e 48 54 54 50 20 6f 76 65 72 20 53 43 54 50 20 61 6e 64 20 54 43 50 3c 2f 68 31 3e 0a 0a 20 20 3c 68 33 3e 53 61 6d 70 6c 65 20 64 6f 77 6e 6c 6f 61 64 20 66 69 6c 65 73 3c 2f 68 33 3e 0a 20 20 3c 75 6c 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 35 31 32 42 22 3e 35 31 32 20 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 31 4b 22 3e 31 20 6b 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 32 4b 22 3e 32 20 6b 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 34 4b 22 3e 34 20 6b 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 31 4d 22 3e 31 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 32 4d 22 3e 32 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 34 4d 22 3e 34 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 38 4d 22 3e 38 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 31 36 4d 22 3e 31 36 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 33 32 4d 22 3e 33 32 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 36 34 4d 22 3e 36 34 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 66 69 6c 65 73 2f 31 32 38 4d 22 3e 31 32 38 20 4d 42 79 74 65 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 3c 2f 75 6c 3e 0a 0a 20 20 3c 68 33 3e 53 61 6d 70 6c 65 20 48 54 4d 4c 20 66 69 6c 65 73 3c 2f 68 33 3e 0a 20 20 3c 70 3e 54 68 65 20 73 61 6d 70 6c 65 20 48 54 4d 4c 20 66 69 6c 65 73 20 68 61 76 65 20 69 6d 67 2d 74 61 67 73 20 69 6e 63 6c 75 64 65 64 20 77 68 69 63 68 20 77 69 6c 6c 20 63 61 75 73 65 20 61 64 64 69 74 69 6f 6e 61 6c 20 47 45 54 2d 72 65 71 75 65 73 74 73 20 62 79 20 74 68 65 20 62 72 6f 77 73 65 72 3c 2f 70 3e 0a 20 20 3c 75 6c 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 73 61 6d 70 6c 65 2d 31 2e 68 74 6d 6c 22 3e 31 20 72 65 71 75 65 73 74 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 73 61 6d 70 6c 65 2d 35 2e 68 74 6d 6c 22 3e 35 20 72 65 71 75 65 73 74 73 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 73 61 6d 70 6c 65 2d 32 35 2e 68 74 6d 6c 22 3e 32 35 20 72 65 71 75 65 73 74 73 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 73 61 6d 70 6c 65 2d 31 30 30 2e 68 74 6d 6c 22 3e 31 30 30 20 72 65 71 75 65 73 74 73 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 20 20 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 63 68 75 6e 6b 73 2e 68 74 6d 6c 22 3e 6d 61 6e 79 20 72 65 71 75 65 73 74 73 20 3a 29 3c 2f 61 3e 3c 2f 6c 69 3e 0a 20 20 3c 2f 75 6c 3e 0a 0a 20 20 3c 70 3e 0a 20 20 20 20 3c 73 6d 61 6c 6c 3e 43 6f 70 79 72 69 67 68 74 20 26 63 6f 70 79 3b 20 46 61 63 68 68 6f 63 68 73 63 68 75 6c 65 20 4d 26 75 75 6d 6c 3b 6e 73 74 65 72 20 2d 20 4c 61 62 6f 72 20 66 26 75 75 6d 6c 3b 72 20 4e 65 74 7a 77 65 72 6b 70 72 6f 67 72 61 6d 6d 69 65 72 75 6e 67 20 2d 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 73 3a 2f 2f 67 69 74 68 75 62 2e 63 6f 6d 2f 6e 70 6c 61 62 2f 22 3e 40 47 69 74 48 # SCTP_PACKET

O 10:40:28.873054 0000 f7 8a 00 50 72 13 8f 7c 1b 2a 04 b5 03 00 00 10 49 40 37 a5 00 01 f9 70 00 00 00 00 # SCTP_PACKET

I 10:40:28.873096 0000 00 50 f7 8a 7f fb 6d 93 b2 b5 60 15 00 09 00 39 49 40 37 a6 00 00 00 00 00 00 00 3f 75 62 3c 2f 61 3e 3c 2f 73 6d 61 6c 6c 3e 0a 20 20 3c 2f 70 3e 0a 0a 0a 3c 2f 62 6f 64 79 3e 0a 0a 3c 2f 68 74 6d 6c 3e 0a 00 00 00 # SCTP_PACKET

O 10:40:28.873112 0000 f7 8a 00 50 72 13 8f 7c 37 2f ed c4 03 00 00 10 49 40 37 a6 00 01 f2 47 00 00 00 00 # SCTP_PACKET
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 80 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.
Msg of length 25 received via 0x7ffee3145784:80 on stream 1252 with SSN 0 and TSN 32766, PPID 0, context 1.

I 10:40:28.891994 0000 00 50 f7 8a 7f fb 6d 93 2d dd 39 b6 07 00 00 08 bc 04 11 c3 # SCTP_PACKET

O 10:40:28.892034 0000 f7 8a 00 50 72 13 8f 7c 02 b6 8b 0e 08 00 00 04 # SCTP_PACKET

I 10:40:28.910879 0000 00 50 f7 8a 7f fb 6d 93 8e 92 e7 44 0e 00 00 04 # SCTP_PACKET
socket was disconnected

@tuexen
Copy link
Member

tuexen commented Aug 10, 2019

@weinrank: I guess you need to call:

usrsctp_setsockopt(s, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int));

without that, you are displaying uninitialized memory...

Does this help?

@ibc
Copy link

ibc commented Aug 12, 2019

@weinrank: I guess you need to call:

usrsctp_setsockopt(s, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int));

without that, you are displaying uninitialized memory...

Does this help?

Hi, where should we add that line? In which file? I do not see any on variable anywhere in the programs.

@ibc
Copy link

ibc commented Aug 12, 2019

BTW sid changed to 0 in st_client.c.

@tuexen
Copy link
Member

tuexen commented Aug 12, 2019

@weinrank: I guess you need to call:

usrsctp_setsockopt(s, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int));

without that, you are displaying uninitialized memory...
Does this help?

Hi, where should we add that line? In which file? I do not see any on variable anywhere in the programs.

At line 333 in the main function should be fine. You also need a local variable being declared at the beginning of the main function using:

const int on = 1;

@ibc
Copy link

ibc commented Aug 12, 2019

In st_client.c you mean?

@tuexen
Copy link
Member

tuexen commented Aug 12, 2019

In st_client.c you mean?

Yes. I'm trying to get the client working...

@ibc
Copy link

ibc commented Aug 12, 2019

Thanks @tuexen, I've added it.

I'm still not sure what the output of st_client should be when connected to ekr_server. This is what I get:

$ ./ekr_server 127.0.0.1 11111 127.0.0.1 22222

I 13:49:25.892677 0000 cd c1 2b 67 00 00 00 00 3b 84 0b 5f 01 00 00 56 fb 1f 32 f4 00 02 00 00 00 0a 08 00 e0 ea da 9b c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 58 b8 77 ae b3 23 97 5e 08 14 6f 71 fa 85 bc a5 7e cd 93 6c 29 49 1b 4f 9f c7 74 b7 87 16 e1 8e 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

O 13:49:25.893346 0000 2b 67 cd c1 fb 1f 32 f4 16 a4 15 b5 06 00 00 04 # SCTP_PACKET
$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 11111

O 13:49:25.892035 0000 cd c1 2b 67 00 00 00 00 3b 84 0b 5f 01 00 00 56 fb 1f 32 f4 00 02 00 00 00 0a 08 00 e0 ea da 9b c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 58 b8 77 ae b3 23 97 5e 08 14 6f 71 fa 85 bc a5 7e cd 93 6c 29 49 1b 4f 9f c7 74 b7 87 16 e1 8e 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

I 13:49:25.893417 0000 2b 67 cd c1 fb 1f 32 f4 16 a4 15 b5 06 00 00 04 # SCTP_PACKET

@tuexen
Copy link
Member

tuexen commented Aug 12, 2019

If you want your client to talk to ekr_server, I think you need to use

./st_client 127.0.0.1 22222 127.0.0.1 11111 5001

That should allow an association setup...

@ibc
Copy link

ibc commented Aug 12, 2019

Oh, true. Updated logs then:

$ ./st_client 127.0.0.1 22222 127.0.0.1 11111 5001

O 14:08:16.063013 0000 c8 fe 13 89 00 00 00 00 ad 68 40 04 01 00 00 56 bc be 1e 1b 00 02 00 00 00 0a 08 00 cd 94 a8 f9 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 cc bb 77 9e dd 92 6a ca a7 64 cc ad a8 43 d1 a0 c1 94 d4 e7 4f 30 54 ce dc 3d 11 46 b2 3e 0f 28 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

I 14:08:16.064651 0000 13 89 c8 fe bc be 1e 1b 51 93 da 39 02 00 01 90 7d d3 3a ae 00 02 00 00 00 0a 08 00 db a5 e9 78 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 67 0c 3f 41 6c 20 cc 7d c8 00 76 41 ff d7 62 6e 31 97 2a a7 9e 90 bd 24 3f e4 4d 6e 52 0c 57 ad 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 00 07 01 38 4b 41 4d 45 2d 42 53 44 20 31 2e 31 00 00 00 00 b0 56 51 5d 00 00 00 00 55 fb 00 00 00 00 00 00 60 ea 00 00 00 00 00 00 00 00 00 00 1b 1e be bc 7d d3 3a ae bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 c8 fe 13 89 00 00 01 00 00 00 00 00 00 00 00 00 01 00 00 56 bc be 1e 1b 00 02 00 00 00 0a 08 00 cd 94 a8 f9 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 cc bb 77 9e dd 92 6a ca a7 64 cc ad a8 43 d1 a0 c1 94 d4 e7 4f 30 54 ce dc 3d 11 46 b2 3e 0f 28 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 02 00 01 90 7d d3 3a ae 00 02 00 00 00 0a 08 00 db a5 e9 78 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 67 0c 3f 41 6c 20 cc 7d c8 00 76 41 ff d7 62 6e 31 97 2a a7 9e 90 bd 24 3f e4 4d 6e 52 0c 57 ad 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 21 e0 42 c6 10 03 eb a3 7a 23 90 61 27 52 ac 4c 21 c7 03 97 # SCTP_PACKET

O 14:08:16.064990 0000 c8 fe 13 89 7d d3 3a ae da 99 5e 46 0a 00 01 38 4b 41 4d 45 2d 42 53 44 20 31 2e 31 00 00 00 00 b0 56 51 5d 00 00 00 00 55 fb 00 00 00 00 00 00 60 ea 00 00 00 00 00 00 00 00 00 00 1b 1e be bc 7d d3 3a ae bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 c8 fe 13 89 00 00 01 00 00 00 00 00 00 00 00 00 01 00 00 56 bc be 1e 1b 00 02 00 00 00 0a 08 00 cd 94 a8 f9 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 cc bb 77 9e dd 92 6a ca a7 64 cc ad a8 43 d1 a0 c1 94 d4 e7 4f 30 54 ce dc 3d 11 46 b2 3e 0f 28 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 02 00 01 90 7d d3 3a ae 00 02 00 00 00 0a 08 00 db a5 e9 78 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 67 0c 3f 41 6c 20 cc 7d c8 00 76 41 ff d7 62 6e 31 97 2a a7 9e 90 bd 24 3f e4 4d 6e 52 0c 57 ad 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 21 e0 42 c6 10 03 eb a3 7a 23 90 61 27 52 ac 4c 21 c7 03 97 # SCTP_PACKET

I 14:08:16.065468 0000 13 89 c8 fe bc be 1e 1b af 60 24 f1 0b 00 00 04 # SCTP_PACKET

O 14:08:16.065599 0000 c8 fe 13 89 7d d3 3a ae db 96 84 2a 00 03 00 60 cd 94 a8 f9 00 00 00 00 00 00 00 27 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 # SCTP_PACKET

I 14:08:16.065864 0000 13 89 c8 fe bc be 1e 1b af 30 4d 05 03 00 00 10 cd 94 a8 f9 00 02 00 00 00 00 00 00 # SCTP_PACKET
$ ./ekr_server 127.0.0.1 11111 127.0.0.1 22222

I 14:08:16.063672 0000 c8 fe 13 89 00 00 00 00 ad 68 40 04 01 00 00 56 bc be 1e 1b 00 02 00 00 00 0a 08 00 cd 94 a8 f9 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 cc bb 77 9e dd 92 6a ca a7 64 cc ad a8 43 d1 a0 c1 94 d4 e7 4f 30 54 ce dc 3d 11 46 b2 3e 0f 28 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 # SCTP_PACKET

O 14:08:16.064415 0000 13 89 c8 fe bc be 1e 1b 51 93 da 39 02 00 01 90 7d d3 3a ae 00 02 00 00 00 0a 08 00 db a5 e9 78 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 67 0c 3f 41 6c 20 cc 7d c8 00 76 41 ff d7 62 6e 31 97 2a a7 9e 90 bd 24 3f e4 4d 6e 52 0c 57 ad 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 00 07 01 38 4b 41 4d 45 2d 42 53 44 20 31 2e 31 00 00 00 00 b0 56 51 5d 00 00 00 00 55 fb 00 00 00 00 00 00 60 ea 00 00 00 00 00 00 00 00 00 00 1b 1e be bc 7d d3 3a ae bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 c8 fe 13 89 00 00 01 00 00 00 00 00 00 00 00 00 01 00 00 56 bc be 1e 1b 00 02 00 00 00 0a 08 00 cd 94 a8 f9 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 cc bb 77 9e dd 92 6a ca a7 64 cc ad a8 43 d1 a0 c1 94 d4 e7 4f 30 54 ce dc 3d 11 46 b2 3e 0f 28 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 02 00 01 90 7d d3 3a ae 00 02 00 00 00 0a 08 00 db a5 e9 78 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 67 0c 3f 41 6c 20 cc 7d c8 00 76 41 ff d7 62 6e 31 97 2a a7 9e 90 bd 24 3f e4 4d 6e 52 0c 57 ad 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 21 e0 42 c6 10 03 eb a3 7a 23 90 61 27 52 ac 4c 21 c7 03 97 # SCTP_PACKET

I 14:08:16.065064 0000 c8 fe 13 89 7d d3 3a ae da 99 5e 46 0a 00 01 38 4b 41 4d 45 2d 42 53 44 20 31 2e 31 00 00 00 00 b0 56 51 5d 00 00 00 00 55 fb 00 00 00 00 00 00 60 ea 00 00 00 00 00 00 00 00 00 00 1b 1e be bc 7d d3 3a ae bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 bc 65 b3 eb fe 7f 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 c8 fe 13 89 00 00 01 00 00 00 00 00 00 00 00 00 01 00 00 56 bc be 1e 1b 00 02 00 00 00 0a 08 00 cd 94 a8 f9 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 cc bb 77 9e dd 92 6a ca a7 64 cc ad a8 43 d1 a0 c1 94 d4 e7 4f 30 54 ce dc 3d 11 46 b2 3e 0f 28 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 02 00 01 90 7d d3 3a ae 00 02 00 00 00 0a 08 00 db a5 e9 78 c0 00 00 04 80 08 00 09 c0 0f c1 80 82 00 00 00 80 02 00 24 67 0c 3f 41 6c 20 cc 7d c8 00 76 41 ff d7 62 6e 31 97 2a a7 9e 90 bd 24 3f e4 4d 6e 52 0c 57 ad 80 04 00 06 00 01 00 00 80 03 00 06 80 c1 00 00 21 e0 42 c6 10 03 eb a3 7a 23 90 61 27 52 ac 4c 21 c7 03 97 # SCTP_PACKET

O 14:08:16.065421 0000 13 89 c8 fe bc be 1e 1b af 60 24 f1 0b 00 00 04 # SCTP_PACKET

I 14:08:16.065688 0000 c8 fe 13 89 7d d3 3a ae db 96 84 2a 00 03 00 60 cd 94 a8 f9 00 00 00 00 00 00 00 27 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 # SCTP_PACKET
Msg of length 80 received via 0x7ffeebb365bc:51454 on stream 0 with SSN 0 and TSN 3449071865, PPID 39, context 0.

O 14:08:16.065775 0000 13 89 c8 fe bc be 1e 1b af 30 4d 05 03 00 00 10 cd 94 a8 f9 00 02 00 00 00 00 00 00 # SCTP_PACKET

And after that there are some pings/pongs.

@tuexen
Copy link
Member

tuexen commented Aug 12, 2019

Yepp, that is expected. Both sides expect its' peer to initiate the association teardown.
This means this is working now.

Did you had a chance to revisit the situation regarding #339 (diff)? That seems to be the last open point in this PR...

@ibc
Copy link

ibc commented Aug 12, 2019

I've executed my server unit tests 2000 times and could not reproduce such a sporadic error, so I understand it happened while compiling, cleaning, etc the whole code.

@tuexen tuexen merged commit f6aa4b0 into sctplab:master Aug 12, 2019
@tuexen
Copy link
Member

tuexen commented Aug 12, 2019

Thanks to all for helping to get this in the master tree!

@ibc
Copy link

ibc commented Aug 12, 2019

Super thanks!

@ibc
Copy link

ibc commented Aug 12, 2019

BTW this PR makes usrsctp work in single thread environments by forcing the application call usrsctp_handle_timers() periodically. While it's good enough (it does work), the optimized way of doing it would be by having an API like DTLSv1_get_timeout() and DTLSv1_handle_timeout in OpenSSL and BoringSSL.

This is, the application provides an input to the lib (via usrsctp_socket(), usrsctp_close(), usrsctp_connect(), usrsctp_conninput(), etc) and retrieves from the lib (via usrsctp_get_timeout()) the time that must elapse before the lib (usrsctp) would need to do something (like sending a retransmission, a chunk or whatever). And then the app would set its own timer with that expiration value and call usrsctp_handle_timeout() when it expires.

Of course, this design would need tons of changes in the lib, as every action should recalculate the time that usrsctp_get_timeout() should return. Just wondering, would it make sense this change? or would it require too much work?

@jmillan
Copy link
Contributor Author

jmillan commented Aug 13, 2019

Also many thanks for your efforts on making this PR into master branch!

@tuexen
Copy link
Member

tuexen commented Aug 13, 2019

BTW this PR makes usrsctp work in single thread environments by forcing the application call usrsctp_handle_timers() periodically. While it's good enough (it does work), the optimized way of doing it would be by having an API like DTLSv1_get_timeout() and DTLSv1_handle_timeout in OpenSSL and BoringSSL.

This is, the application provides an input to the lib (via usrsctp_socket(), usrsctp_close(), usrsctp_connect(), usrsctp_conninput(), etc) and retrieves from the lib (via usrsctp_get_timeout()) the time that must elapse before the lib (usrsctp) would need to do something (like sending a retransmission, a chunk or whatever). And then the app would set its own timer with that expiration value and call usrsctp_handle_timeout() when it expires.

Of course, this design would need tons of changes in the lib, as every action should recalculate the time that usrsctp_get_timeout() should return. Just wondering, would it make sense this change? or would it require too much work?

If I understand you correctly, all you want is a function usrsctp_get_timeout() which gives you the number of milliseconds until the next timer runs off. Is that correct? That is not hard to implement. You just need to walk the (unordered) list of timers to compute that value. It would even be more efficient if the timer list would be ordered, but then starting a timer would be more complicated.

So if you need usrsctp_get_timeout(), please file an issue and I'll mark it as an enhancement.

@ibc
Copy link

ibc commented Aug 13, 2019

So if you need usrsctp_get_timeout(), please file an issue and I'll mark it as an enhancement.

Thanks. I've open an issue for it: #349

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.

5 participants