-/* FIXME: Figure out where to enforce GRD. */
-#if 0
- for (i = 0; i < ident->num_slices; i++){
-
- sprintf(cmd, "/sbin/tc qdisc change dev eth0 parent 1:1%x handle 1%x netem loss %.4f delay 40ms",
- ident->xids[i],ident->xids[i], (100*ident->localdropprob));
-
+ for (i = 0; i < ident->leaf_count; ++i) {
+ if (ident->drop_prob >= ident->leaves[i]->drop_prob) {
+ /* The new drop probability for this identity is greater
+ * than or equal to the leaf's current drop probability.
+ * We can safely use the larger value at this leaf
+ * immediately. */
+ ident->leaves[i]->drop_prob = ident->drop_prob;
+ } else if (ident->last_drop_prob < ident->leaves[i]->drop_prob) {
+ /* The old drop probability for this identity is less than
+ * the leaf's current drop probability. This means that
+ * this identity couldn't have been the limiting ident,
+ * so nothing needs to be done because the old limiting
+ * ident is still the limiting factor. */
+
+ /* Intentionally blank. */
+ } else {
+ /* If neither of the above are true, then...
+ * 1) The new drop probability for the identity is less
+ * than what it previously was, and
+ * 2) This ident may have had the maximum drop probability
+ * of all idents limiting this leaf, and therefore we need
+ * to follow the leaf's parents up to the root to find the
+ * new leaf drop probability safely. */
+ ident->leaves[i]->drop_prob =
+ find_leaf_drop_prob(ident->leaves[i]);
+ }
+
+ /* Make the call to tc. */
+#ifdef DELAY40MS
+ snprintf(cmd, CMD_BUFFER_SIZE,
+ "/sbin/tc qdisc change dev eth0 parent 1:1%x handle 1%x netem loss %.4f delay 40ms",
+ ident->leaves[i]->xid, ident->leaves[i]->xid,
+ (100 * ident->leaves[i]->drop_prob));
+#else
+ snprintf(cmd, CMD_BUFFER_SIZE,
+ "/sbin/tc qdisc change dev eth0 parent 1:1%x handle 1%x netem loss %.4f delay 0ms",
+ ident->leaves[i]->xid, ident->leaves[i]->xid,
+ (100 * ident->leaves[i]->drop_prob));
+#endif