# HG changeset patch # User Alexander Krotov # Date 1481824263 -10800 # Thu Dec 15 20:51:03 2016 +0300 # Node ID 436f90b0e9bcae5c204a304740555ab647bbe83c # Parent f883d71c975eefb1f53b5e8d4604266c20358250 lte: Turn commented code into assertion Assertion fails as binary search is not implemented correctly. One case when it fails is B1=32, C=1. In this case KplusId should be 0, but it ends up being 1. diff -r f883d71c975e -r 436f90b0e9bc src/lte/model/lte-mi-error-model.cc --- a/src/lte/model/lte-mi-error-model.cc Thu Dec 15 16:44:18 2016 +0300 +++ b/src/lte/model/lte-mi-error-model.cc Thu Dec 15 20:51:03 2016 +0300 @@ -601,15 +601,6 @@ B1 = B + C * L; } // first segmentation: K+ = minimum K in table such that C * K >= B1 -// uint i = 0; -// while (B1 > cbSizeTable[i] * C) -// { -// // NS_LOG_INFO (" K+ " << cbSizeTable[i] << " means " << cbSizeTable[i] * C); -// i++; -// } -// uint16_t KplusId = i; -// Kplus = cbSizeTable[i]; - // implement a modified binary search int min = 0; int max = 187; @@ -649,6 +640,17 @@ uint16_t KplusId = mid; Kplus = cbSizeTable[mid]; +#ifdef NS3_BUILD_PROFILE_DEBUG + { + uint i = 0; + while (B1 > cbSizeTable[i] * C) + { + i++; + } + NS_ASSERT_MSG (i == KplusId, "For B1 = " << B1 << ", C = " << C << " K+ index is " << KplusId << " instead of " << i); + + } +#endif if (C==1) {