Skip to content
Open
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
7 changes: 5 additions & 2 deletions misc/calc-cbs-params.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def calc_class_a_credits(
# loCredit for SR class A are calculated following the
# equations L-10 and L-12, respectively.
hicredit = math.ceil(idleslope_a * frame_non_sr / link_speed)
locredit = math.ceil(sendslope_a * max_frame_size_a / link_speed)
# locredit is a negative number, because of sendslope, and thus
# we need to use math.floor() for the ceiling of a negative number
locredit = math.floor(sendslope_a * max_frame_size_a / link_speed)
return hicredit, locredit


Expand Down Expand Up @@ -61,7 +63,8 @@ def calc_class_b_credits(
((frame_non_sr / (link_speed - idleslope_a)) +
(max_frame_size_a / link_speed)))
# loCredit B is calculated following equation L-2.
locredit = math.ceil(sendslope_b * max_frame_size_b / link_speed)
# see comment in calc_class_a_credits() for why we use floor here
locredit = math.floor(sendslope_b * max_frame_size_b / link_speed)
return hicredit, locredit


Expand Down