-
Notifications
You must be signed in to change notification settings - Fork 269
Incorrect order of operations in CoDel control law implementation 🤦 #2478
Copy link
Copy link
Closed
Labels
Component: MainComposing the core Shadow executableComposing the core Shadow executableType: BugError or flaw producing unexpected resultsError or flaw producing unexpected results
Milestone
Description
In Shadow's implementation of the CoDel control law, the order of operations is incorrect.
The CoDel RFC defines the control law as the following function:
time_t codel_queue_t::control_law(time_t t, uint32_t count)
{
return t + INTERVAL / sqrt(count);
}The following expression is equivalent but makes the correct order of operations explicit:
return t + (INTERVAL / sqrt(count));Shadow's implementation orders things the wrong way: it does the addition operation first, and then the division:
shadow/src/main/routing/router_queue_codel.c
Lines 199 to 206 in 8581e74
| static CSimulationTime _routerqueuecodel_controlLaw(guint count, CSimulationTime ts) { | |
| CSimulationTime newTS = ts + CODEL_PARAM_INTERVAL_SIMTIME; | |
| double result = ((double)newTS) / sqrt((double)count); | |
| double rounded = round(result); | |
| return (CSimulationTime)rounded; | |
| } |
The result is that the schedule for dropping packets will be incorrect and unexpected.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Component: MainComposing the core Shadow executableComposing the core Shadow executableType: BugError or flaw producing unexpected resultsError or flaw producing unexpected results