This allows the application to send packets of arbitrary size (up to 64 kiB)
without worrying about the path MTU to the destination node, which might
vary, especially at the start of a connection.
If the application doesn't want packets to fragment, it should use
meshlink_channel_get_mss() to query the maximum size for unfragmented
packets.
-Subproject commit 134cccee1441033ad5bcb736a689a3a7481886d8
+Subproject commit a7d31e61566f0d2e6cb0821fcdaf74ccfc1f8f64
meshlink_handle_t *mesh;
meshlink_channel_t *channel;
size_t received;
meshlink_handle_t *mesh;
meshlink_channel_t *channel;
size_t received;
};
static void server_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
};
static void server_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
(void)data;
// We expect always the same amount of data from the server.
(void)data;
// We expect always the same amount of data from the server.
assert(mesh->priv);
struct client *client = mesh->priv;
assert(mesh->priv);
struct client *client = mesh->priv;
+ assert(len == 512 || len == 2000);
+
+ if(len == 2000) {
+ client->got_large_packet = true;
+ }
}
static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
}
static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
assert(clients[i].channel);
}
assert(clients[i].channel);
}
+ // Send a packet larger than the MTU
+
+ char large_data[2000] = "";
+
+ for(int i = 0; i < 3; i++) {
+ assert(meshlink_channel_send(server, channels[i], large_data, sizeof(large_data)) == sizeof(large_data));
+ }
+
+ // Assert that packets larger than 64 kiB are not allowed
+
+ assert(meshlink_channel_send(server, channels[0], large_data, 65537) == -1);
+
// Stream packets from server to clients for 5 seconds at 40 Mbps (1 kB * 500 Hz)
// Stream packets from server to clients for 5 seconds at 40 Mbps (1 kB * 500 Hz)
memset(data, 'U', sizeof(data));
for(int j = 0; j < 2500; j++) {
memset(data, 'U', sizeof(data));
for(int j = 0; j < 2500; j++) {
}
for(int i = 0; i < 3; i++) {
}
for(int i = 0; i < 3; i++) {
- assert(clients[i].received >= 2400000);
- assert(clients[i].received <= 2500000);
+ assert(clients[i].received >= 1000000);
+ assert(clients[i].received <= 1282000);
+ assert(clients[i].got_large_packet);