]> git.meshlink.io Git - utcp/log
utcp
7 years agoFix a memory leak on invalid invocation of utcp_init().
Guus Sliepen [Sun, 18 Oct 2015 11:54:14 +0000 (13:54 +0200)]
Fix a memory leak on invalid invocation of utcp_init().

7 years agoAdd a receive buffer.
Guus Sliepen [Sun, 18 Oct 2015 11:53:20 +0000 (13:53 +0200)]
Add a receive buffer.

The receive buffer kicks in the moment we get a packet which is out of order.
We store the packet in the buffer, and keep track of up to 4 ranges of bytes
of received data. When retransmission fills the first gap, we send all the
buffered data (up to the second gap if applicable) to the application.

4 byte ranges seems to be a good value for up to moderate (20%) packet loss.
This algorithm greatly reduces the amount of useless packets being sent.
A future improvement is sending the SACK information in the ACK packets,
so the congestion window can be kept large while avoiding packets being
resent unnecessarily.

7 years agoFix check for return value of malloc(), allow initially zero length buffer.
Guus Sliepen [Sun, 18 Oct 2015 11:45:16 +0000 (13:45 +0200)]
Fix check for return value of malloc(), allow initially zero length buffer.

7 years agoAllow putting data in a buffer at an arbitrary offset.
Guus Sliepen [Sun, 18 Oct 2015 11:44:43 +0000 (13:44 +0200)]
Allow putting data in a buffer at an arbitrary offset.

7 years agoFix check for return value of malloc().
Guus Sliepen [Sun, 18 Oct 2015 11:43:53 +0000 (13:43 +0200)]
Fix check for return value of malloc().

7 years agoWhen debugging, set initial segment seqno to 0.
Guus Sliepen [Sun, 18 Oct 2015 11:42:36 +0000 (13:42 +0200)]
When debugging, set initial segment seqno to 0.

7 years agoShow total bytes sent/received in test program.
Guus Sliepen [Sun, 18 Oct 2015 11:41:50 +0000 (13:41 +0200)]
Show total bytes sent/received in test program.

7 years agoReset the snd.nxt pointer when starting packet retransmission.
Guus Sliepen [Sun, 11 Oct 2015 21:39:23 +0000 (23:39 +0200)]
Reset the snd.nxt pointer when starting packet retransmission.

When a packet was lost, and the send buffer contains more than two packets,
this only retransmitted the first packet from the send buffer, then when it
got acked it would continue with the tail of the buffer. Then it would have
to wait for another timeout to send the next packet from the start of the
send buffer. If the application is continuously sending data, then the send
buffer would never become empty and the problem would persist.

7 years agoFix a segfault when debugging is enabled.
Guus Sliepen [Sun, 11 Oct 2015 21:35:49 +0000 (23:35 +0200)]
Fix a segfault when debugging is enabled.

7 years agoLog timestamps during the test.
Guus Sliepen [Sun, 11 Oct 2015 21:35:14 +0000 (23:35 +0200)]
Log timestamps during the test.

7 years agoAllow dropping a selected range of packets during tests.
Guus Sliepen [Sun, 11 Oct 2015 21:35:02 +0000 (23:35 +0200)]
Allow dropping a selected range of packets during tests.

7 years agoAdd scripts testing filetransfer.
Guus Sliepen [Sun, 11 Oct 2015 15:11:13 +0000 (17:11 +0200)]
Add scripts testing filetransfer.

- txttest transfers a file into one direction.
- bidirtest transfers a file both ways simultaneously.

7 years agoHandle direction argument of utcp_shutdown().
Guus Sliepen [Sun, 11 Oct 2015 15:02:37 +0000 (17:02 +0200)]
Handle direction argument of utcp_shutdown().

For TCP, only shutting down the send direction makes sense, however to
be compatible to the BSD sockets API, keep the direction argument, and
when someone tries to shut down the receive direction, just disable the
receive callback.

Note that on most operating systems, SHUT_RD actually doesn't do
anything at all, it won't prevent reads from returning data.

Also be a bit more strict, return EINVAL or ENOTCONN when appropriate.

7 years agoDefine UTCP_SHUT_RD/WR/RDWR.
Guus Sliepen [Sun, 11 Oct 2015 15:00:17 +0000 (17:00 +0200)]
Define UTCP_SHUT_RD/WR/RDWR.

Don't rely on <sys/socket.h> for the definitions of SHUT_RD/WR/RDWR, add
our own. They should be compatible.

7 years agoAdd a function to check for active connections.
Guus Sliepen [Sun, 11 Oct 2015 14:31:59 +0000 (16:31 +0200)]
Add a function to check for active connections.

If a connection sends data in one way, then the receiver will have shut
down data in the other way, and when the sender is finished he will also
shut down his direction, so the connection looks closed to the sender,
but the receiver might actually still miss the final packets. So UTCP
should keep running until the receiver has received a FINACK and is in the
TIME_WAIT state.

We consider UTCP to be active when there is at least one connection not in
the CLOSED or TIME_WAIT state.

The test program now uses this condition, which allows a transfer of a file
to complete without missing the last few bytes.

7 years agoAllow changing the accept callbacks.
Guus Sliepen [Sun, 11 Oct 2015 14:25:31 +0000 (16:25 +0200)]
Allow changing the accept callbacks.

This is used in the test, in order to stop accepting new connections after
the first one.

7 years agoClarify read/write direction in test program.
Guus Sliepen [Sun, 11 Oct 2015 14:21:22 +0000 (16:21 +0200)]
Clarify read/write direction in test program.

7 years agoUse '== -1' to check for errors from functions.
Guus Sliepen [Sun, 11 Oct 2015 11:32:55 +0000 (13:32 +0200)]
Use '== -1' to check for errors from functions.

As made obvious by commit 123f53f, the type of ssize_t cannot be trusted
on Windows to actually be signed, so don't use '< 0', as the compiler
will optimize the test away. POSIX also specifies only that -1 signals
an error condition, not any other negative value.

Luckily, comparing an unsigned int to -1 still works as intended.

9 years agoHandle retransmissions in CLOSE_WAIT, CLOSING and LAST_ACK states.
Guus Sliepen [Wed, 10 Dec 2014 10:11:09 +0000 (11:11 +0100)]
Handle retransmissions in CLOSE_WAIT, CLOSING and LAST_ACK states.

9 years agoAdd fin_wanted() function that checks whether a FIN bit should be set on a packet.
Guus Sliepen [Wed, 10 Dec 2014 10:09:59 +0000 (11:09 +0100)]
Add fin_wanted() function that checks whether a FIN bit should be set on a packet.

9 years agoCall abort() only when debugging is enabled.
Guus Sliepen [Wed, 10 Dec 2014 09:48:02 +0000 (10:48 +0100)]
Call abort() only when debugging is enabled.

9 years agoGuard against NULL pointer dereferencing.
Guus Sliepen [Mon, 8 Dec 2014 15:37:24 +0000 (16:37 +0100)]
Guard against NULL pointer dereferencing.

9 years agoPrevent FIN bit from being sent too early.
Guus Sliepen [Mon, 8 Dec 2014 15:18:30 +0000 (16:18 +0100)]
Prevent FIN bit from being sent too early.

Due to a logic bug in ack(), the FIN bit could be set on a too early packet,
if utcp_shutdown() was called with a full send buffer.

9 years agoProperly handle arbitrary size files being piped into the test program.
Guus Sliepen [Mon, 8 Dec 2014 15:17:22 +0000 (16:17 +0100)]
Properly handle arbitrary size files being piped into the test program.

9 years agoutcp_get_sndbuf_free() should return 0 if utcp_send() would fail.
Guus Sliepen [Mon, 8 Dec 2014 15:16:34 +0000 (16:16 +0100)]
utcp_get_sndbuf_free() should return 0 if utcp_send() would fail.

9 years agoRemove unconditional debug messages.
Guus Sliepen [Fri, 5 Dec 2014 21:14:31 +0000 (22:14 +0100)]
Remove unconditional debug messages.

9 years agoRecover from dropped packets after receiving a triplicate ACK.
Guus Sliepen [Fri, 5 Dec 2014 21:12:35 +0000 (22:12 +0100)]
Recover from dropped packets after receiving a triplicate ACK.

When this happens, reset the nxt pointer so we start retransmitting from the last acknowledged
packet, at the same speed as ACKs are coming in.

9 years agoSend ACKs without a payload upon receiving an out-of-order packet.
Guus Sliepen [Fri, 5 Dec 2014 21:10:37 +0000 (22:10 +0100)]
Send ACKs without a payload upon receiving an out-of-order packet.

This is necessary so the peer can detect "triplicate ACKs", which signal dropped packets, and at the
same time keeps the TCP self-clocking active.

9 years agoChange utcp_timeout() to return a struct timeval.
Guus Sliepen [Fri, 5 Dec 2014 21:08:21 +0000 (22:08 +0100)]
Change utcp_timeout() to return a struct timeval.

This is what MeshLink uses internally as well, and prevents confusion over which units the old int
return value had.

9 years agoDon't call abort() in retransmit().
Guus Sliepen [Wed, 3 Dec 2014 12:42:27 +0000 (13:42 +0100)]
Don't call abort() in retransmit().

The retransmission timer can sometimes get called when in one of the
closing states. This is not implemented yet, but it's better to just
ignore those cases for now than to abort().

9 years agoDisable callbacks when closing a connection.
Guus Sliepen [Tue, 2 Dec 2014 16:14:13 +0000 (17:14 +0100)]
Disable callbacks when closing a connection.

When an application calls utcp_close() on a previously established
connection, the utcp_connection is kept around to handle FIN(ACK)
packets. However, the peer could still send some data, which should not
trigger the receive callback.

9 years agoRemove debugging messages.
Guus Sliepen [Tue, 2 Dec 2014 14:46:06 +0000 (15:46 +0100)]
Remove debugging messages.

9 years agoFix and refactor send buffer code.
Guus Sliepen [Tue, 2 Dec 2014 11:26:57 +0000 (12:26 +0100)]
Fix and refactor send buffer code.

Make generic buffer handling functions and use those. A problem was
found when resizing a buffer; if new data to be put into the buffer was
more than twice as large as the current buffer size, the code would not
reallocate the buffer large enough.

10 years agoFix free_connection() moving the wrong memory.
Guus Sliepen [Fri, 31 Oct 2014 16:42:06 +0000 (17:42 +0100)]
Fix free_connection() moving the wrong memory.

10 years agoOnly call the poll callback when state is ESTABLISHED or CLOSE_WAIT.
Guus Sliepen [Thu, 30 Oct 2014 13:55:07 +0000 (14:55 +0100)]
Only call the poll callback when state is ESTABLISHED or CLOSE_WAIT.

10 years agoFix retransmit().
Guus Sliepen [Mon, 27 Oct 2014 08:10:10 +0000 (09:10 +0100)]
Fix retransmit().

10 years agoDon't put a VLA in a struct, C99 does not allow it.
Guus Sliepen [Mon, 27 Oct 2014 08:06:52 +0000 (09:06 +0100)]
Don't put a VLA in a struct, C99 does not allow it.

10 years agoAdd some missing definitions for Windows.
Guus Sliepen [Sat, 25 Oct 2014 23:05:41 +0000 (01:05 +0200)]
Add some missing definitions for Windows.

10 years agoAdd a poll callback to UTCP connections.
Guus Sliepen [Wed, 1 Oct 2014 17:18:40 +0000 (19:18 +0200)]
Add a poll callback to UTCP connections.

The callback is called whenever the send buffer of a connection is more
than half empty when utcp_timeout() is called. An argument is passed to
the callee informing him of the maximum number of bytes that will be
accepted when calling utcp_send().

10 years agoSet priv field in utcp_connect().
Guus Sliepen [Sat, 13 Sep 2014 15:10:52 +0000 (17:10 +0200)]
Set priv field in utcp_connect().

10 years agoImplement slow start.
Guus Sliepen [Tue, 26 Aug 2014 12:34:17 +0000 (14:34 +0200)]
Implement slow start.

10 years agoVarious small fixes, clarifications.
Guus Sliepen [Tue, 26 Aug 2014 12:33:19 +0000 (14:33 +0200)]
Various small fixes, clarifications.

10 years agoFix memory and resource leaks.
Guus Sliepen [Thu, 21 Aug 2014 14:42:12 +0000 (16:42 +0200)]
Fix memory and resource leaks.

10 years agoSet FIN bit in ack().
Guus Sliepen [Thu, 21 Aug 2014 14:19:09 +0000 (16:19 +0200)]
Set FIN bit in ack().

10 years agoStart implementation of congestion avoidance.
Guus Sliepen [Sun, 17 Aug 2014 19:54:20 +0000 (21:54 +0200)]
Start implementation of congestion avoidance.

We try to implement RFC 2001.

10 years agoImprove Makefile.
Guus Sliepen [Sun, 17 Aug 2014 19:53:22 +0000 (21:53 +0200)]
Improve Makefile.

10 years agoAllow debug messages to be compiled out.
Guus Sliepen [Sun, 17 Aug 2014 19:52:58 +0000 (21:52 +0200)]
Allow debug messages to be compiled out.

10 years agoAdd socket option functions names similar to setsockopt()/ioctl() ones.
Guus Sliepen [Sat, 16 Aug 2014 16:31:06 +0000 (18:31 +0200)]
Add socket option functions names similar to setsockopt()/ioctl() ones.

10 years agoAdd a .gitignore file.
Guus Sliepen [Sat, 16 Aug 2014 15:48:53 +0000 (17:48 +0200)]
Add a .gitignore file.

10 years agoMove private struct declarations e.a. to utcp_priv.h.
Guus Sliepen [Sat, 16 Aug 2014 15:48:50 +0000 (17:48 +0200)]
Move private struct declarations e.a. to utcp_priv.h.

10 years agoAdd utcp_set_mtu().
Guus Sliepen [Sat, 16 Aug 2014 15:48:48 +0000 (17:48 +0200)]
Add utcp_set_mtu().

10 years agoHandle FIN_WAIT_1 state when retransmitting.
Guus Sliepen [Sat, 16 Aug 2014 15:48:45 +0000 (17:48 +0200)]
Handle FIN_WAIT_1 state when retransmitting.

10 years agoIncrease sndbuf when necessary.
Guus Sliepen [Sat, 16 Aug 2014 15:48:21 +0000 (17:48 +0200)]
Increase sndbuf when necessary.

10 years agoRedo receive logic.
Guus Sliepen [Sun, 10 Aug 2014 18:41:32 +0000 (20:41 +0200)]
Redo receive logic.

10 years agoUpdate README.
Guus Sliepen [Sun, 10 Aug 2014 12:19:06 +0000 (14:19 +0200)]
Update README.

10 years agoAllow variable packet loss rates to be set in the test program.
Guus Sliepen [Sat, 9 Aug 2014 17:15:22 +0000 (19:15 +0200)]
Allow variable packet loss rates to be set in the test program.

10 years agoPrint both incoming and outgoing packets.
Guus Sliepen [Sat, 9 Aug 2014 17:15:00 +0000 (19:15 +0200)]
Print both incoming and outgoing packets.

10 years agoUpdate snd.una when receiving an ACK in the SYN_RECEIVED state.
Guus Sliepen [Sat, 9 Aug 2014 17:14:38 +0000 (19:14 +0200)]
Update snd.una when receiving an ACK in the SYN_RECEIVED state.

10 years agoStart implementing timeout handling.
Guus Sliepen [Sat, 9 Aug 2014 16:37:10 +0000 (18:37 +0200)]
Start implementing timeout handling.

- Initial connection timeout (1 minute by default)
- Retransmission of SYN, SYNACK and normal data packets

10 years agoPass buffers as const.
Guus Sliepen [Sat, 9 Aug 2014 14:01:43 +0000 (16:01 +0200)]
Pass buffers as const.

10 years agoRename UTCP to README.
Guus Sliepen [Fri, 25 Jul 2014 12:01:12 +0000 (14:01 +0200)]
Rename UTCP to README.

10 years agoSegmentize outgoing packets.
Guus Sliepen [Fri, 25 Jul 2014 12:00:41 +0000 (14:00 +0200)]
Segmentize outgoing packets.

10 years agoDo proper modulo 2^32 comparisons of sequence numbers.
Guus Sliepen [Fri, 25 Jul 2014 11:28:43 +0000 (13:28 +0200)]
Do proper modulo 2^32 comparisons of sequence numbers.

10 years agoDo port numbers properly.
Guus Sliepen [Fri, 25 Jul 2014 11:18:58 +0000 (13:18 +0200)]
Do port numbers properly.

- Outgoing connections automatically get a port number >= 32768 assigned.
- *connect() and *accept() get a port number as argument.
- Connections are now stored in a sorted array with O(log(N)) lookup time.

10 years agoBuild both binaries.
Guus Sliepen [Fri, 25 Jul 2014 11:14:08 +0000 (13:14 +0200)]
Build both binaries.

10 years agoStart of UTCP.
Guus Sliepen [Thu, 24 Jul 2014 20:06:57 +0000 (22:06 +0200)]
Start of UTCP.