-
Notifications
You must be signed in to change notification settings - Fork 384
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
L2CAP: static size of BLE_L2CAP_COC_MTU inefficient?! #301
Comments
@haukepetersen I guess you have issue when testing against 2 devices using Nimble, is this correct? Anyway, I don't know why it is 100 but note that L2CAP can take Could you do such a patch? |
yes, 5-10 devices running Nimble :-)
But did I understand correctly, that the MSYS buffers are ordered by their block size, with MSYS_1 having the smallest block size? So that would mean that setting it at least to MSYS_1_BLOCK_SIZE would indeed make sense.
I can certainly for the RIOT port, but I am not sure if I sufficient enough with mynewt to include such a fix into the rest of the code tree. But I guess I can at least give it a try :-) |
So here is my try: #315 |
Lately, I was playing with some stress-tests for sending data over raw l2cap connection oriented channels, and I had a lot of trouble with overflowing buffers. It took me a while to understand NimBLE's internal buffering for l2cap, but I think I have it figured out...
However, when looking more closely into the code, I found that
BLE_L2CAP_COC_MTU
inble_l2cap_coc_priv.h
is statically set to100
. If I understand it correctly, this value is only used for the computation of the initial credits for a connection (inble_l2cap_coc_chan_alloc()
). These credits then define the maximum number of 'mbuf's, that are allocated in a row from themsys
pool, whenble_l2cap_coc_continue_tx()
is called.Example:
(5000 + (BLE_L2CAP_COC_MTU - 1)) / BLE_L2CAP_COC_MTU
mbuf
poolble_l2cap_send()
ble_l2cap_coc_continue_tx()
is called. This function will allocate 50mbuf
s from themsys
pool, puttingBLE_L2CAP_COC_MTU -> 100
byte of user data into eachmbuf
-> on RIOT,
MYNEWT_VAL_MSYS_1_BLOCK_SIZE
is per default set to292
. This leads to a lot of wasted memory, as each of the 50mbuf
s allocated above uses only 100 of these 292 byes, leaving 50 * ~190 byte -> ~9.5kb of RAM unusedSo is there any reason I missed for setting
BLE_L2CAP_COC_MTU
statically to100
? I would suggest to set it simply to the value ofMYNEWT_VAL_MSYS_1_BLOCK_SIZE
, possibly minus a little overhead. Would that make sense?The text was updated successfully, but these errors were encountered: