Compare commits

...

161 Commits

Author SHA1 Message Date
e4988b9e9c switch to libsodium implementation of aegis256 2020-06-09 20:59:55 +02:00
0183b35acf remove aegis256 submodule 2020-06-09 20:44:38 +02:00
Adrien Gallouët
faeb599a19 Rework mud_set_conf()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-04-17 21:25:08 +00:00
Adrien Gallouët
a4e72918df Inline and move some functions
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-04-03 08:32:20 +00:00
Adrien Gallouët
d7e8dbe0e7 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-30 20:43:49 +00:00
Adrien Gallouët
71d16f25ff Don't use a static mtid
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-26 22:31:33 +00:00
Adrien Gallouët
c426cef08b Fix non little endian arch
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 20:43:54 +00:00
Adrien Gallouët
bda2c6eaa7 Wait a few packets before computing the loss
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-07 15:13:37 +00:00
Adrien Gallouët
d68aee8249 Allow a different loss_limit per path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-07 14:27:47 +00:00
Adrien Gallouët
2f966bb365 Fix fixed rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-29 09:57:08 +00:00
Adrien Gallouët
4a7740f70f Fix beat conf
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-21 16:37:04 +00:00
Adrien Gallouët
5be4096452 Add a stupid dynamic rate limiter
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-05 14:00:41 +00:00
Adrien Gallouët
3747aa7abd Add a global mud_set_conf()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-16 17:34:31 +00:00
Adrien Gallouët
e3eb1f96a5 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-11 09:52:39 +00:00
Adrien Gallouët
2f5e346532 Add keepalive
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-11 09:08:04 +00:00
Adrien Gallouët
a9fdd76fa3 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-10 09:56:13 +00:00
Adrien Gallouët
0a9a139409 Fix a bad typo
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-09 22:25:00 +00:00
Adrien Gallouët
2811e2383f Compute rate/loss only when mtu is ok
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-09 17:39:42 +00:00
Adrien Gallouët
ed6cc0e6f6 Degrade lossy path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-08 14:35:25 +00:00
Adrien Gallouët
487474a80e Update loss computing
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-08 14:34:47 +00:00
Adrien Gallouët
edb86d27ad Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-08 13:10:39 +00:00
Adrien Gallouët
c0d2118a77 Use fixed rate by default
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 12:44:29 +00:00
Adrien Gallouët
70e80f76e0 Add a fixed rate mode
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 11:07:13 +00:00
Adrien Gallouët
e4092ebebd Cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 10:24:58 +00:00
Adrien Gallouët
2330e6470e Remove useless conversions
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 10:24:01 +00:00
Adrien Gallouët
7d59eedd39 Sanitize mud_decrypt_msg()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-07 10:01:15 +00:00
Adrien Gallouët
c536bef802 Force MTU sync
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 16:15:18 +00:00
Adrien Gallouët
23a5cdfe31 Remove probe, let the system take its time
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 13:00:29 +00:00
Adrien Gallouët
6894867b9f Limit tx.rate to tx_max_rate...
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 12:38:14 +00:00
Adrien Gallouët
8f11ffa5a4 Slow down internal rate on dead paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 12:33:25 +00:00
Adrien Gallouët
1f18b731c4 Prepare the way before you run away
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-04 12:08:54 +00:00
Adrien Gallouët
e3689d29b7 Return MTU probing status in mud_update()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 21:50:59 +00:00
Adrien Gallouët
2a812f332f Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 15:55:07 +00:00
Adrien Gallouët
b16a754713 Update LICENSE
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 15:51:02 +00:00
Adrien Gallouët
b6238c939e Count backup path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 15:15:29 +00:00
Adrien Gallouët
6e8a3cef1e Update protocol
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-03 13:53:08 +00:00
Adrien Gallouët
e56abf5eaa Reimplement backup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 19:27:57 +00:00
Adrien Gallouët
6b1881e94c Send msg_timeout to the server
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 17:43:54 +00:00
Adrien Gallouët
7ff46e742b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 15:07:28 +00:00
Adrien Gallouët
a87a277701 Cleanup path after a 1min silence
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-01-02 15:04:40 +00:00
Adrien Gallouët
ef41aa28ce Update now after mud_send_msg()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-31 15:09:04 +00:00
Adrien Gallouët
d5322e187d Use EAFNOSUPPORT when necessary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-28 22:05:27 +00:00
Adrien Gallouët
0a2b23bb88 Fix (and refactor) keyx with low timeout
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-28 13:24:21 +00:00
Adrien Gallouët
3a30c63eff God doesn't care about endianness
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-28 11:57:00 +00:00
Adrien Gallouët
9c27f92f9d Remove old keyx stuff
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-27 17:29:58 +00:00
Adrien Gallouët
9e3e2b358b Use the full 8bits range for loss
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 16:56:59 +00:00
Adrien Gallouët
a6acb8736c Increase MUD_MSG_SENT_MAX
This allows to support paths of <=500ms as written in
the glorytun README.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 15:02:53 +00:00
Adrien Gallouët
3d4e3a8fbe Burst shouldn't depend on MUD_MSG_TIMEOUT
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 15:01:51 +00:00
Adrien Gallouët
97407b2527 Reintroduce failover (and make it a little faster)
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-26 14:57:08 +00:00
Adrien Gallouët
dc22121739 Compute a global window for all paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-24 14:18:27 +00:00
Adrien Gallouët
06c0945ac5 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-24 12:49:15 +00:00
Adrien Gallouët
2b19c80ae3 Fix tx_max_rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-24 12:33:05 +00:00
Adrien Gallouët
21b15727c5 Don't wait unnecessarily to compute RTT
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-23 10:57:50 +00:00
Adrien Gallouët
569e712248 Probe MTU before sending real packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-22 01:46:12 +00:00
Adrien Gallouët
8c033a12a1 Fix build
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 19:47:25 +00:00
Adrien Gallouët
6b58ebb993 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 16:12:16 +00:00
Adrien Gallouët
7179de77da Small useless opt
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 16:08:25 +00:00
Adrien Gallouët
e6a8c8e013 Compute loss with packets (not bytes)
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-17 14:03:59 +00:00
Adrien Gallouët
137971e957 Apply TC on all packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-16 15:59:34 +00:00
Adrien Gallouët
9abb50a7e2 Clear path->msg on reset
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-16 10:40:11 +00:00
Adrien Gallouët
2766a94e3b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-16 09:43:36 +00:00
Adrien Gallouët
c420e9494a First draft on the new protocol
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-15 21:30:44 +00:00
Adrien Gallouët
407db114c6 Use mem*() when touching sin{,6}_port
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-12-12 09:50:04 +00:00
Adrien Gallouët
0537b01d4b This commit doesn't exist
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-19 11:56:36 +00:00
Adrien Gallouët
79dc61e7dc Decrease rate instead of degrading the path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-05 17:52:18 +00:00
Adrien Gallouët
67a660117e Setup rate_max
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-05 10:43:00 +00:00
Adrien Gallouët
831714e07f Force update after mud_reset_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 15:01:31 +00:00
Adrien Gallouët
f047af8148 Remove useless call to mud_reset_path()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 15:00:37 +00:00
Adrien Gallouët
8948d00545 Reorder
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 15:00:03 +00:00
Adrien Gallouët
2e8a13f135 Clear deleted paths
This should fix #5

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-11-04 13:50:02 +00:00
Adrien Gallouët
f647519e1c Take the time to check loss before enabling a path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-23 14:15:33 +00:00
Adrien Gallouët
94ae912138 Update mud.h
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-23 13:28:27 +00:00
Adrien Gallouët
e3b56376dc Naively degrade path with loss > loss_limit
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-22 15:54:48 +00:00
Adrien Gallouët
8c88934763 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-22 13:12:27 +00:00
Adrien Gallouët
d0dc6076c8 Add mud_get_bad()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-15 14:11:07 +00:00
Adrien Gallouët
842dadad94 Call unmapv4 only when it is necessary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-15 12:21:38 +00:00
Adrien Gallouët
d086d7869d Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-14 13:50:03 +00:00
Adrien Gallouët
d4d97177eb Fix test.c
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-14 13:50:03 +00:00
Adrien Gallouët
7254e15a02 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-08 08:51:09 +00:00
Adrien Gallouët
ee4b484a38 Get loss_rx from peer
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-07 14:01:27 +00:00
Adrien Gallouët
9a378aea99 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 15:21:07 +00:00
Adrien Gallouët
3db88eb23c Add .gitignore
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 15:15:40 +00:00
Adrien Gallouët
c4d2ef7d97 Add a simple test.c with a Makefile
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 14:36:31 +00:00
Adrien Gallouët
00f18733d8 Compute loss for each path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-10-05 09:46:14 +00:00
Adrien Gallouët
4d14689ff1 Update aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-24 09:56:57 +00:00
Adrien Gallouët
027196026b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-20 08:19:43 +00:00
Adrien Gallouët
b59ab48407 Update rate every ms
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-19 08:12:26 +00:00
Adrien Gallouët
181e22011d Update README.md
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-17 08:28:16 +00:00
Adrien Gallouët
0397bc63e7 Import and use aegis256
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-17 08:21:25 +00:00
Adrien Gallouët
a6befda070 Use CLOCK_REALTIME if available
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-17 08:07:56 +00:00
Adrien Gallouët
5aeaf9e512 Revert "Block on sendmsg() for now"
This reverts commit 2c9d971437.
2019-09-16 10:37:19 +00:00
Adrien Gallouët
2c9d971437 Block on sendmsg() for now
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-09 16:08:21 +00:00
Adrien Gallouët
6623be1e69 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-09-03 16:56:21 +00:00
Adrien Gallouët
67a7c91220 Remove old code
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-22 13:07:50 +00:00
Adrien Gallouët
a91f8e2971 DEGRADED/DOWN paths are useless server side
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-19 13:20:26 +00:00
Adrien Gallouët
b2ff2b6276 Use an adjusted monotonic clock
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-19 12:55:55 +00:00
Adrien Gallouët
0ae6656bdb Remove down paths after 10s of inactivity
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-17 14:59:28 +00:00
Adrien Gallouët
14893f9ea9 Move MUD_PATH_MAX in mud.h
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-07-17 14:29:08 +00:00
Adrien Gallouët
06e165e664 Explicit conversions
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-04-03 09:25:22 +00:00
Adrien Gallouët
a2106c248d Remove useless code
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-04-01 15:37:28 +00:00
Adrien Gallouët
7a5bb0690e Remove mud_sync()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-09 15:03:47 +00:00
Adrien Gallouët
f67a5b4fed Don't wake up without paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-09 14:37:32 +00:00
Adrien Gallouët
eab4cdb1ad Update LICENSE
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-05 21:56:07 +00:00
Adrien Gallouët
bb60f5f15f Merge MTU probing with failover
This commit also fixes MTU probing in some corner cases.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-03-05 11:05:36 +00:00
Adrien Gallouët
adf3bf6710 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 19:31:08 +00:00
Adrien Gallouët
bf75ac9cd9 One sec failover
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 19:29:00 +00:00
Adrien Gallouët
cef20db3c7 Correctly handle high latency paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 17:27:50 +00:00
Adrien Gallouët
40983ee4f1 Compute path->ok both sides
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-15 09:35:24 +00:00
Adrien Gallouët
9eac498d81 Rework failover with new proto
New proto totally destroy old failover.
This is a hack to improve the current situation waiting
for a better solution.

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-10 21:14:20 +00:00
Adrien Gallouët
0b1793a93f Update mud->window when updating path->window
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-10 16:11:32 +00:00
Adrien Gallouët
5f86acee91 Fix build
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-09 16:17:07 +00:00
Adrien Gallouët
e47db2ea47 Use new proto (with static rate) and cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2019-02-09 15:58:29 +00:00
Adrien Gallouët
4030b4370b Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-02 15:56:18 +00:00
Adrien Gallouët
72019786eb Update path->window directly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-02 09:32:33 +00:00
Adrien Gallouët
b732cb1b69 Skip down paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-02 08:27:41 +00:00
Adrien Gallouët
00c30c4fdf Remove mud->send_timeout
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 15:04:17 +00:00
Adrien Gallouët
1d4b06abda Boost boost 2018-12-01 15:01:41 +00:00
Adrien Gallouët
d74228e4a9 Be more aggressive about stats
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:22:49 +00:00
Adrien Gallouët
be5020cbae Rename mud_value to mud_stat
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:20:17 +00:00
Adrien Gallouët
6494b95700 Add a boost factor to estimate send.ratemax
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:17:39 +00:00
Adrien Gallouët
ff0c10b66c Send dt directly instead of sending lat/latmin
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-12-01 11:11:43 +00:00
Adrien Gallouët
79688de09e Use lowbw scheduler and clean old unused stuff
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-29 22:21:07 +00:00
Adrien Gallouët
b5289a8472 Re-estimate latmin when rate is low
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-09 17:57:11 +00:00
Adrien Gallouët
ff55d6a173 New scheduler and cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-08 17:40:38 +00:00
Adrien Gallouët
ccaac70a04 Simplify rate as MUD_STAT_TIMEOUT is const
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-11-05 11:14:43 +00:00
Adrien Gallouët
7f5c063ffb Allow bad use of mud_get_fd()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-10-21 08:37:53 +00:00
Adrien Gallouët
1e7e8722ee Compute map directly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-10-18 08:15:31 +00:00
Adrien Gallouët
2dd31a5f96 Trust compilers and cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-10-09 16:55:42 +00:00
Adrien Gallouët
5b9b3d5709 Remove duplicated checks
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-08-16 12:58:46 +00:00
Adrien Gallouët
22e065e5cb Add mud_sync()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-06-15 10:05:42 +00:00
Adrien Gallouët
03be90b606 Update mud.h
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-06-05 13:56:15 +00:00
Adrien Gallouët
6ebda9368c Add mud_get_sync_elapsed_msec()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-06-03 18:00:17 +00:00
Adrien Gallouët
964672adb5 Be nice with old good path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 19:34:52 +00:00
Adrien Gallouët
1988ee1d78 Rework internal proto
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 12:54:22 +00:00
Adrien Gallouët
3668a2f9af Don't send packets to DOWN paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 12:50:31 +00:00
Adrien Gallouët
db7f48890a Fix mud_update_map()
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-05-05 12:49:53 +00:00
Adrien Gallouët
c8d949733a Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-27 15:29:42 +00:00
Adrien Gallouët
81afe325f6 Update ratemax softly
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-26 20:20:28 +00:00
Adrien Gallouët
04fc9b2894 Force update when creating a new path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 20:58:18 +00:00
Adrien Gallouët
d896f9ff3c Don't touch a path if we don't have to
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 20:54:33 +00:00
Adrien Gallouët
c8b07c6edb Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 20:52:39 +00:00
Adrien Gallouët
9f38b7b6e0 Compute a pseudo ratevar to help bw probing
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-25 09:10:01 +00:00
Adrien Gallouët
ba9bef6268 Add a new rate based scheduler
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-23 20:52:31 +00:00
Adrien Gallouët
b2e4bc1b8f Compute latency-smoothed maximum rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-21 12:25:52 +00:00
Adrien Gallouët
a7044db87c Compute rate
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-18 16:35:27 +00:00
Adrien Gallouët
8e2b35525c Remove MUD_EPOCH and compute durations modulo 2^48
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-18 09:54:52 +00:00
Adrien Gallouët
875533a65f Recover lost connection slightly faster
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-07 16:43:46 +00:00
Adrien Gallouët
1f25f12e4a Compute rttvar for the next voip scheduler
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-06 16:46:09 +00:00
Adrien Gallouët
7fde67f3d3 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-06 10:11:00 +00:00
Adrien Gallouët
2f304c1afc Set state to MUD_UP by default
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-05 15:52:29 +00:00
Adrien Gallouët
e0d7494a71 Don't inline
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-05 09:07:28 +00:00
Adrien Gallouët
1e9bb89764 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-04 08:58:10 +00:00
Adrien Gallouët
e7851fa29d Compute RTT for each internal packet
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-04 08:52:01 +00:00
Adrien Gallouët
0c11ce5785 Add number of packets per path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-03 09:02:02 +00:00
Adrien Gallouët
6d5738b931 Don't try to send something without path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-02 08:50:42 +00:00
Adrien Gallouët
dcfaca04a5 Limit number of paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-04-02 08:44:59 +00:00
Adrien Gallouët
c63c94d7c8 Simplify MTU setup and allow big packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-26 13:03:27 +00:00
Adrien Gallouët
09acdee3e1 Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-25 14:48:59 +00:00
Adrien Gallouët
c2eb3e4095 Refuse truncated packets
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-25 14:22:52 +00:00
Adrien Gallouët
54bac4fcf6 Don't produce/reply to bad pubkeys
AFAIK, this should be useless as libsodium use constant-time code
But small order are rejected and so we don't want to produce one.

This commit does not improve security.
2018-03-19 22:28:03 +00:00
Adrien Gallouët
9a626f2889 Reset mtu in all paths
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2018-03-17 13:51:54 +00:00
7 changed files with 1092 additions and 768 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.deps
.dirstamp
*.[ios]
test

View File

@@ -1,4 +1,4 @@
Copyright (c) 2016, angt
Copyright (c) 2016-2020, Adrien Gallouët <adrien@gallouet.fr>
All rights reserved.
Redistribution and use in source and binary forms, with or without

8
Makefile Normal file
View File

@@ -0,0 +1,8 @@
CFLAGS=-march=native -O2
LDLIBS=-lsodium
test:
.PHONY: clean
clean:
rm -f test

View File

@@ -1,23 +1,22 @@
# MUD
MUD is a secure, connectionless network protocol over UDP.
It enables the distribution of packets on multiple paths while maintaining a low latency (the bandwidth is sacrificed in favor of latency).
MUD is a secure, multipath network protocol over UDP.
See [glorytun](https://github.com/angt/glorytun) for details.
### Compatibility
Linux is the platform of choice but it was successfully ported to OpenBSD and OSX.
### Dependencies
* A recent version of GCC or Clang.
* [libsodium](https://github.com/jedisct1/libsodium).
### Security
MUD uses [libsodium](https://github.com/jedisct1/libsodium) for all cryptographic operations.
Encryption (and authentication) is done with AES256-GCM when aesni is available otherwise ChaCha20-Poly1305 is used.
Encryption and authentication is done with AEGIS256 when aesni is available otherwise ChaCha20-Poly1305 is used.
The Diffie-Hellman function X25519 is used for key exchange.
### Performance
The scheduler is still in development but you will find some measurements to give you an idea of the performance [here](https://github.com/angt/mud/wiki/Perf).
### Issues
For feature requests and bug reports, please create an [issue](https://github.com/angt/mud/issues).

1558
mud.c

File diff suppressed because it is too large Load Diff

96
mud.h
View File

@@ -4,7 +4,8 @@
#include <inttypes.h>
#include <sys/socket.h>
#define MUD_KISS_SIZE (8U)
#define MUD_PATH_MAX (32U)
#define MUD_PUBKEY_SIZE (32U)
struct mud;
@@ -15,56 +16,91 @@ enum mud_state {
MUD_UP,
};
struct mud_stat {
uint64_t val;
uint64_t var;
int setup;
};
struct mud_conf {
uint64_t keepalive;
uint64_t timetolerance;
uint64_t kxtimeout;
int tc;
};
struct mud_path {
enum mud_state state;
struct sockaddr_storage local_addr, addr, r_addr;
unsigned char kiss[MUD_KISS_SIZE];
struct mud_stat rtt;
struct {
uint64_t send_time;
int remote;
} conf;
uint64_t send_max;
uint64_t send_max_time;
uint64_t recv_max;
uint64_t recv_max_time;
uint64_t rtt;
uint64_t rst;
uint64_t r_rst;
uint64_t r_rms;
uint64_t r_rmt;
uint64_t limit;
uint64_t recv_time;
uint64_t send_time;
uint64_t stat_time;
struct {
size_t ok;
size_t probe;
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t rate;
uint64_t loss;
} tx, rx;
struct {
struct {
uint64_t total;
uint64_t bytes;
uint64_t time;
uint64_t acc;
uint64_t acc_time;
} tx, rx;
uint64_t time;
uint64_t sent;
uint64_t set;
} msg;
struct {
size_t min;
size_t max;
size_t probe;
size_t last;
size_t ok;
} mtu;
struct {
uint64_t tx_max_rate;
uint64_t rx_max_rate;
uint64_t beat;
unsigned char fixed_rate;
unsigned char loss_limit;
} conf;
uint64_t idle;
unsigned char ok;
};
struct mud_bad {
struct {
struct sockaddr_storage addr;
uint64_t time;
uint64_t count;
} decrypt, difftime, keyx;
};
struct mud *mud_create (struct sockaddr *);
void mud_delete (struct mud *);
int mud_update (struct mud *);
int mud_send_wait (struct mud *);
int mud_get_fd (struct mud *);
size_t mud_get_mtu (struct mud *);
int mud_get_bad (struct mud *, struct mud_bad *);
int mud_set_key (struct mud *, unsigned char *, size_t);
int mud_get_key (struct mud *, unsigned char *, size_t *);
void mud_set_mtu (struct mud *, size_t);
size_t mud_get_mtu (struct mud *);
int mud_set_send_timeout (struct mud *, unsigned long);
int mud_set_time_tolerance (struct mud *, unsigned long);
int mud_set_keyx_timeout (struct mud *, unsigned long);
int mud_set_tc (struct mud *, int);
int mud_set_aes (struct mud *);
int mud_set_conf (struct mud *, struct mud_conf *);
int mud_set_state (struct mud *, struct sockaddr *, enum mud_state);
int mud_set_state (struct mud *, struct sockaddr *, enum mud_state,
unsigned long, unsigned long, unsigned long,
unsigned char, unsigned char);
int mud_peer (struct mud *, struct sockaddr *);
int mud_recv (struct mud *, void *, size_t);
int mud_send (struct mud *, const void *, size_t, int);
int mud_send (struct mud *, const void *, size_t);
struct mud_path *mud_get_paths(struct mud *, unsigned *);

121
test.c Normal file
View File

@@ -0,0 +1,121 @@
#include "mud.c"
#include <stdio.h>
#include <poll.h>
int
main(int argc, char **argv)
{
if (argc > 2)
return -1;
int client = argc == 2;
struct sockaddr_in local = {
.sin_family = AF_INET,
.sin_port = htons(client + 20000),
.sin_addr = {
.s_addr = htonl(INADDR_LOOPBACK),
},
};
struct mud *mud = mud_create((struct sockaddr *)&local);
if (!mud) {
perror("mud_create");
return -1;
}
unsigned char key[] = "0123456789ABCDEF0123456789ABCDEF";
if (mud_set_key(mud, key, sizeof(key))) {
perror("mud_set_key");
return -1;
}
// client is little harder to setup
if (client) {
struct sockaddr_in remote = {
.sin_family = AF_INET,
.sin_port = htons(20000),
.sin_addr = {
.s_addr = htonl(INADDR_LOOPBACK),
},
};
// we are going to connect to remote...
if (mud_peer(mud, (struct sockaddr *)&remote)) {
perror("mud_peer");
return -1;
}
// ...from loopback at 1MBps (not 1Mbps)
if (mud_set_state(mud, (struct sockaddr *)&local,
MUD_UP, 1000 * 1000, 1000 * 1000, 0, 0, 0)) {
perror("mud_set_state");
return -1;
}
}
unsigned char buf[1500];
for (;;) {
// mandatory, mud have lot of work to do.
if (mud_update(mud))
usleep(100000); // don't use all the cpu
if (client) {
// when there is data, mud_recv() is mandatory
struct pollfd pollfd = {
.fd = mud_get_fd(mud),
.events = POLLIN,
};
switch (poll(&pollfd, 1, 0)) {
case -1:
perror("poll");
return -1;
case 1:
if (mud_recv(mud, buf, sizeof(buf)) == -1) {
perror("mud_recv");
return -1;
}
}
// we can safely call mud_send()
// even if the link is not ready
int r = mud_send(mud, argv[1], strlen(argv[1]));
if (r == -1) {
if (errno == EAGAIN)
continue;
perror("mud_send");
return -1;
}
// we sent everything, bye :)
if (r)
break;
} else {
int r = mud_recv(mud, buf, sizeof(buf));
if (r == -1) {
if (errno == EAGAIN)
continue;
perror("mud_recv");
return -1;
}
if (r) {
buf[r] = 0;
printf("%s\n", buf);
}
}
}
mud_delete(mud);
return 0;
}