From: Jay Vosburgh <jay.vosburgh@canonical.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org, netem@lists.linux-foundation.org
Subject: [PATCH iproute2] tc/netem: loss gemodel options fixes
Date: Sat, 10 May 2014 13:34:58 -0700 [thread overview]
Message-ID: <29682.1399754098@localhost.localdomain> (raw)
First, the default value for 1-k is documented as being 0, but is
currently being set to 1. (100%). This causes all packets to be dropped
in the good state if 1-k is not explicitly specified. Fix this by setting
the default to 0.
Second, the 1-h option is parsed correctly, however, the kernel is
expecting "h", not 1-h. Fix this by inverting the "1-h" percentage before
sending to and after receiving from the kernel. This does change the
behavior, but makes it consistent with the netem documentation and the
literature on the Gilbert-Elliot model, which refer to "1-h" and "1-k,"
not "h" or "k" directly.
Last, fix a minor formatting issue for the options reporting.
Signed-off-by: Jay Vosburgh <jay.vosburgh@canonical.com>
---
tc/q_netem.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tc/q_netem.c b/tc/q_netem.c
index c83e301..8abe07f 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -307,7 +307,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
/* set defaults */
set_percent(&gemodel.r, 1.);
set_percent(&gemodel.h, 0);
- set_percent(&gemodel.k1, 1.);
+ set_percent(&gemodel.k1, 0);
loss_type = NETEM_LOSS_GE;
if (!NEXT_IS_NUMBER())
@@ -325,6 +325,10 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
explain1("loss gemodel h");
return -1;
}
+ /* netem option is "1-h" but kernel
+ * expects "h".
+ */
+ gemodel.h = max_percent_value - gemodel.h;
if (!NEXT_IS_NUMBER())
continue;
@@ -625,10 +629,11 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
}
if (gemodel) {
- fprintf(f, "loss gemodel p %s",
+ fprintf(f, " loss gemodel p %s",
sprint_percent(gemodel->p, b1));
fprintf(f, " r %s", sprint_percent(gemodel->r, b1));
- fprintf(f, " 1-h %s", sprint_percent(gemodel->h, b1));
+ fprintf(f, " 1-h %s", sprint_percent(max_percent_value -
+ gemodel->h, b1));
fprintf(f, " 1-k %s", sprint_percent(gemodel->k1, b1));
}
--
1.8.3.2
next reply other threads:[~2014-05-10 20:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-10 20:34 Jay Vosburgh [this message]
[not found] ` <CAPh34mf4ahPyTDf-tEhsNKSFBL6GYjES9+TTvDjhMf2YLTr04Q@mail.gmail.com>
2014-05-15 19:46 ` [PATCH iproute2] tc/netem: loss gemodel options fixes Jay Vosburgh
2014-08-04 19:37 ` Stephen Hemminger
2014-08-05 8:09 ` Hagen Paul Pfeifer
2014-08-05 18:29 ` Jay Vosburgh
2014-08-05 21:25 ` Hagen Paul Pfeifer
2014-05-15 21:03 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=29682.1399754098@localhost.localdomain \
--to=jay.vosburgh@canonical.com \
--cc=netdev@vger.kernel.org \
--cc=netem@lists.linux-foundation.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).