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

Improved ekr_loop logging #334

Merged
merged 27 commits into from
Aug 1, 2019
Merged
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7ee1669
be more verbose (#312)
weinrank Apr 25, 2019
e6d4743
Improve and of ICMP messages on Windows.
tuexen May 1, 2019
b8e97a7
Fix broken links, Make URLs' protocols consistent (#315)
tillz May 16, 2019
e8e39b5
Backport https://svnweb.freebsd.org/base?view=revision&revision=340783
tuexen May 19, 2019
ab105a0
Improve input validation for the IPPROTO_SCTP level socket options
tuexen May 19, 2019
8ad82a0
Allow sending on demand SCTP HEARTBEATS only in the ESTABLISHED state.
tuexen May 19, 2019
2672aab
Fix cross-build linux->mingw (#320)
orgads Jun 26, 2019
0f9b957
Merge remote-tracking branch 'upstream/master'
weinrank Jul 26, 2019
ae4dbe4
Merge branch 'master' of https://github.com/sctplab/usrsctp
weinrank Jul 28, 2019
a745d92
Merge remote-tracking branch 'upstream/master'
weinrank Jul 30, 2019
c88cf8f
ekr_loop* allowed to specify ports
weinrank Jul 30, 2019
0d057d6
Buildbot trigger
weinrank Jul 30, 2019
ed0ce75
Update ekr_loop.c
weinrank Jul 30, 2019
5dc19ed
Update ekr_loop.c
weinrank Jul 30, 2019
1fb65bb
Update ekr_loop.c
weinrank Jul 30, 2019
5d3a1ec
Update ekr_loop.c
weinrank Jul 30, 2019
7597c48
revert changes
weinrank Jul 30, 2019
de53d1c
test
weinrank Jul 30, 2019
e4b3e96
Revert changes
weinrank Jul 31, 2019
9a7098d
Merge remote-tracking branch 'upstream/master' into ekr_loop_fix
weinrank Aug 1, 2019
e668276
sync
weinrank Aug 1, 2019
9c34323
sync
weinrank Aug 1, 2019
ce01cb1
sync
weinrank Aug 1, 2019
148857d
sync
weinrank Aug 1, 2019
be2f35c
sync
weinrank Aug 1, 2019
1778c77
sync
weinrank Aug 1, 2019
88f34af
fix: i=1 --> i=0
weinrank Aug 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions programs/ekr_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ static int
receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
size_t datalen, struct sctp_rcvinfo rcv, int flags, void *ulp_info)
{
printf("Message %p received on sock = %p.\n", data, (void *)sock);
debug_printf("MSG RCV: %p received on sock = %p.\n", data, (void *)sock);
if (data) {
if ((flags & MSG_NOTIFICATION) == 0) {
printf("Messsage of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n",
debug_printf("MSG RCV: length %d, addr %p:%u, stream %u, SSN %u, TSN %u, PPID %u, context %u, %s%s.\n",
(int)datalen,
addr.sconn.sconn_addr,
ntohs(addr.sconn.sconn_port),
Expand All @@ -143,7 +143,8 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
rcv.rcv_context,
flags);
(rcv.rcv_flags & SCTP_UNORDERED) ? "unordered" : "ordered",
(flags & MSG_EOR) ? ", EOR" : "");
}
free(data);
} else {
Expand Down Expand Up @@ -172,7 +173,7 @@ print_addresses(struct socket *sock)

sin = (struct sockaddr_in *)addr;
name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
printf("%s:%d", name, ntohs(sin->sin_port));
debug_printf("%s:%d", name, ntohs(sin->sin_port));
break;
}
case AF_INET6:
Expand All @@ -183,30 +184,30 @@ print_addresses(struct socket *sock)

sin6 = (struct sockaddr_in6 *)addr;
name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
printf("%s:%d", name, ntohs(sin6->sin6_port));
debug_printf("%s:%d", name, ntohs(sin6->sin6_port));
break;
}
case AF_CONN:
{
struct sockaddr_conn *sconn;

sconn = (struct sockaddr_conn *)addr;
printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
debug_printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
break;
}
default:
printf("Unknown family: %d", addr->sa_family);
debug_printf("Unknown family: %d", addr->sa_family);
break;
}
addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
if (i != n - 1) {
printf(",");
debug_printf(",");
}
}
if (n > 0) {
usrsctp_freeladdrs(addrs);
}
printf("<->");
debug_printf("<->");
n = usrsctp_getpaddrs(sock, 0, &addrs);
addr = addrs;
for (i = 0; i < n; i++) {
Expand All @@ -219,7 +220,7 @@ print_addresses(struct socket *sock)

sin = (struct sockaddr_in *)addr;
name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
printf("%s:%d", name, ntohs(sin->sin_port));
debug_printf("%s:%d", name, ntohs(sin->sin_port));
break;
}
case AF_INET6:
Expand All @@ -230,30 +231,30 @@ print_addresses(struct socket *sock)

sin6 = (struct sockaddr_in6 *)addr;
name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
printf("%s:%d", name, ntohs(sin6->sin6_port));
debug_printf("%s:%d", name, ntohs(sin6->sin6_port));
break;
}
case AF_CONN:
{
struct sockaddr_conn *sconn;

sconn = (struct sockaddr_conn *)addr;
printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
debug_printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
break;
}
default:
printf("Unknown family: %d", addr->sa_family);
debug_printf("Unknown family: %d", addr->sa_family);
break;
}
addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
if (i != n - 1) {
printf(",");
debug_printf(",");
}
}
if (n > 0) {
usrsctp_freepaddrs(addrs);
}
printf("\n");
debug_printf("\n");
}
#endif

Expand All @@ -273,7 +274,7 @@ main(int argc, char *argv[])
#else
pthread_t tid_c, tid_s;
#endif
int i, cur_buf_size, snd_buf_size, rcv_buf_size;
int i, j, cur_buf_size, snd_buf_size, rcv_buf_size;
socklen_t opt_len;
struct sctp_sndinfo sndinfo;
char *line;
Expand All @@ -288,6 +289,8 @@ main(int argc, char *argv[])
server_port = atoi(argv[2]);
}

debug_printf("starting program\n");

#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("WSAStartup failed\n");
Expand Down Expand Up @@ -350,11 +353,11 @@ main(int argc, char *argv[])
#endif
#ifdef _WIN32
if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
printf("connect() failed with error: %d\n", WSAGetLastError());
debug_printf("connect() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
printf("connect() failed with error: %d\n", WSAGetLastError());
debug_printf("connect() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
#else
Expand Down Expand Up @@ -397,7 +400,7 @@ main(int argc, char *argv[])
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
printf("Change send socket buffer size from %d ", cur_buf_size);
debug_printf("Change send socket buffer size from %d ", cur_buf_size);
snd_buf_size = 1<<22; /* 4 MB */
if (usrsctp_setsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &snd_buf_size, sizeof(int)) < 0) {
perror("usrsctp_setsockopt");
Expand All @@ -409,7 +412,7 @@ main(int argc, char *argv[])
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
printf("to %d.\n", cur_buf_size);
debug_printf("to %d.\n", cur_buf_size);
if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd_s)) == NULL) {
perror("usrsctp_socket");
exit(EXIT_FAILURE);
Expand All @@ -420,7 +423,7 @@ main(int argc, char *argv[])
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
printf("Change receive socket buffer size from %d ", cur_buf_size);
debug_printf("Change receive socket buffer size from %d ", cur_buf_size);
rcv_buf_size = 1<<16; /* 64 KB */
if (usrsctp_setsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &rcv_buf_size, sizeof(int)) < 0) {
perror("usrsctp_setsockopt");
Expand All @@ -432,7 +435,7 @@ main(int argc, char *argv[])
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
printf("to %d.\n", cur_buf_size);
debug_printf("to %d.\n", cur_buf_size);
/* Bind the client side. */
memset(&sconn, 0, sizeof(struct sockaddr_conn));
sconn.sconn_family = AF_CONN;
Expand Down Expand Up @@ -487,24 +490,29 @@ main(int argc, char *argv[])
sndinfo.snd_ppid = htonl(DISCARD_PPID);
sndinfo.snd_context = 0;
sndinfo.snd_assoc_id = 0;

for (i = 1; i < NUMBER_OF_STEPS; i++) {
weinrank marked this conversation as resolved.
Show resolved Hide resolved
j = 0;
if (i % 2) {
sndinfo.snd_flags = SCTP_UNORDERED;
} else {
sndinfo.snd_flags = 0;
}
/* Send a 1 MB ordered message */
/* Send a 1 MB message */
debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, ++j, sndinfo.snd_flags);
if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
(socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
perror("usrsctp_sendv");
exit(EXIT_FAILURE);
}
/* Send a 1 MB ordered message */
/* Send a 1 MB message */
debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, ++j, sndinfo.snd_flags);
if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
(socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
perror("usrsctp_sendv");
exit(EXIT_FAILURE);
}
debug_printf("Sending done, sleeping\n");
#ifdef _WIN32
Sleep(1000);
#else
Expand All @@ -527,11 +535,11 @@ main(int argc, char *argv[])
TerminateThread(tid_s, 0);
WaitForSingleObject(tid_s, INFINITE);
if (closesocket(fd_c) == SOCKET_ERROR) {
printf("closesocket() failed with error: %d\n", WSAGetLastError());
debug_printf("closesocket() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
if (closesocket(fd_s) == SOCKET_ERROR) {
printf("closesocket() failed with error: %d\n", WSAGetLastError());
debug_printf("closesocket() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
WSACleanup();
Expand Down