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 indices calculation for congestion control. #1268

Merged
merged 2 commits into from
Jan 3, 2019

Conversation

kurnevsky
Copy link

@kurnevsky kurnevsky commented Nov 20, 2018

Fixes:

  • It seems the second index for sum calculated in a wrong way:

    (long signed int)conn->last_sendqueue_size[(pos - (CONGESTION_QUEUE_ARRAY_SIZE - 1)) % CONGESTION_QUEUE_ARRAY_SIZE];

    pos is a value between 0 and CONGESTION_QUEUE_ARRAY_SIZE. So the value pos - (CONGESTION_QUEUE_ARRAY_SIZE - 1) is likely to be overflowed. It's unsigned so it won't lead to out-of-bounds access but incorrect value will be taken instead.

  • Move incrementing of last_sendqueue_counter - it seems pretty illogical that it's used before and after incrementing:

    unsigned int pos = conn->last_sendqueue_counter % CONGESTION_QUEUE_ARRAY_SIZE;

    unsigned int n_p_pos = conn->last_sendqueue_counter % CONGESTION_LAST_SENT_ARRAY_SIZE;

  • Take remainder of the division so that last_sendqueue_counter won't be overflowed.

Also I can't understand the meaning of this comparison:

if (send_array_ratio > SEND_QUEUE_RATIO && CRYPTO_MIN_QUEUE_LENGTH < npackets) {

Does somebody know what it means? It seams send_array_ratio variable means the time that is required to send all packets from the send queue with the current calculated speed. And if it's higher than 2 seconds the packet_send_rate will be reduced. Why? There comments says:

/* If the send queue is SEND_QUEUE_RATIO times larger than the
 * calculated link speed the packet send speed will be reduced
 * by a value depending on this number.
 */

But how the send queue size and the link speed can be compared? They have different units of measurement. Or do I miss something?


This change is Reviewable

@codecov
Copy link

codecov bot commented Nov 21, 2018

Codecov Report

Merging #1268 into master will increase coverage by <.1%.
The diff coverage is 83.6%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1268     +/-   ##
========================================
+ Coverage    83.3%   83.3%   +<.1%     
========================================
  Files          82      82             
  Lines       14827   14867     +40     
========================================
+ Hits        12361   12398     +37     
- Misses       2466    2469      +3
Impacted Files Coverage Δ
auto_tests/encryptsave_test.c 95.7% <100%> (+0.6%) ⬆️
toxcore/net_crypto.c 95.2% <100%> (-0.1%) ⬇️
toxcore/crypto_core.c 91.4% <72.4%> (-8.6%) ⬇️
toxav/toxav.c 67.3% <0%> (-0.9%) ⬇️
toxcore/Messenger.c 86.7% <0%> (-0.1%) ⬇️
toxav/msi.c 65% <0%> (+0.5%) ⬆️
toxcore/friend_connection.c 95.7% <0%> (+0.8%) ⬆️
toxcore/LAN_discovery.c 85.8% <0%> (+1.8%) ⬆️
auto_tests/toxav_many_test.c 96.6% <0%> (+4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72ef085...e532057. Read the comment docs.

@iphydf iphydf added this to the v0.2.x milestone Nov 22, 2018
@zugz
Copy link

zugz commented Nov 24, 2018 via email

@hugbubby hugbubby force-pushed the congestion_fixes branch 2 times, most recently from 33b3a48 to 0e2155e Compare December 13, 2018 00:32
@hugbubby hugbubby changed the title Fix indices calculation for congestion control. WIP: Fix indices calculation for congestion control. Dec 13, 2018
@hugbubby hugbubby changed the title WIP: Fix indices calculation for congestion control. Fix indices calculation for congestion control. Dec 13, 2018
@hugbubby hugbubby changed the title Fix indices calculation for congestion control. WIP: Fix indices calculation for congestion control. Dec 13, 2018
@hugbubby hugbubby changed the title WIP: Fix indices calculation for congestion control. Fix indices calculation for congestion control. Dec 13, 2018
zoff99 and others added 2 commits January 3, 2019 11:13
Also added and used the new crypto_malloc and crypto_free.

The latter also zeroes out the memory safely. The former only exists for
symmetry (static analysis can detect asymmetric usages).
@iphydf iphydf merged commit e532057 into TokTok:master Jan 3, 2019
@robinlinden robinlinden modified the milestones: v0.2.x, v0.2.9 Jan 3, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants