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

Fix zenoh mtu #524

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions src/protocol/definitions/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ _z_transport_message_t _z_t_msg_make_init_syn(z_whatami_t whatami, _z_id_t zid)
msg._body._init._zid = zid;
msg._body._init._seq_num_res = Z_SN_RESOLUTION;
msg._body._init._req_id_res = Z_REQ_RESOLUTION;
msg._body._init._batch_size = (Z_BATCH_UNICAST_SIZE + _Z_MSG_LEN_ENC_SIZE > UINT16_MAX)
? Z_BATCH_UNICAST_SIZE
: Z_BATCH_UNICAST_SIZE + _Z_MSG_LEN_ENC_SIZE;
msg._body._init._batch_size = Z_BATCH_UNICAST_SIZE;
_z_slice_reset(&msg._body._init._cookie);

if ((msg._body._init._batch_size != _Z_DEFAULT_UNICAST_BATCH_SIZE) ||
Expand Down
23 changes: 6 additions & 17 deletions src/transport/unicast/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,16 @@ int8_t _z_unicast_transport_create(_z_transport_t *zt, _z_link_t *zl, _z_transpo

// Initialize the read and write buffers
if (ret == _Z_RES_OK) {
uint16_t mtu = (zl->_mtu < Z_BATCH_UNICAST_SIZE) ? zl->_mtu : Z_BATCH_UNICAST_SIZE;
uint16_t mtu = (zl->_mtu < param->_batch_size) ? zl->_mtu : param->_batch_size;
size_t dbuf_size = 0;
size_t wbuf_size = 0;
size_t zbuf_size = 0;
size_t wbuf_size = mtu;
size_t zbuf_size = param->_batch_size;
_Bool expandable = false;

switch (zl->_cap._flow) {
case Z_LINK_CAP_FLOW_STREAM:
// Add stream length field to buffer size
wbuf_size = mtu + _Z_MSG_LEN_ENC_SIZE;
zbuf_size = Z_BATCH_UNICAST_SIZE + _Z_MSG_LEN_ENC_SIZE;
expandable = true;
break;
case Z_LINK_CAP_FLOW_DATAGRAM:
default:
wbuf_size = mtu;
zbuf_size = Z_BATCH_UNICAST_SIZE;
expandable = false;
break;
// Set expandable on stream link
if (zl->_cap._flow == Z_LINK_CAP_FLOW_STREAM) {
expandable = true;
}

#if Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION == 0
expandable = false;
dbuf_size = Z_FRAG_MAX_SIZE;
Expand Down
Loading