summaryrefslogtreecommitdiffstats
path: root/tc
diff options
context:
space:
mode:
authorosdl.net!shemminger <osdl.net!shemminger>2004-07-01 11:02:04 +0000
committerosdl.net!shemminger <osdl.net!shemminger>2004-07-01 11:02:04 +0000
commitffb79d06915fe3b1ee5d2e4e37c1db67c3c06cdf (patch)
tree26490de30551686d5128f92cc200dcf6915b3ba4 /tc
parent9615dc1da4ce4cefff0cf605eab800c62a51e7ff (diff)
Add new rate and duplicate arguments.
(Logical change 1.41)
Diffstat (limited to 'tc')
-rw-r--r--tc/q_netem.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 7815f2ce..2c952530 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -25,8 +25,10 @@
static void explain(void)
{
- fprintf(stderr, "Usage: ... netem latency TIME rate KBPS [ mtu BYTES ]\n");
- fprintf(stderr, " [ limit BYTES]\n");
+ fprintf(stderr,
+"Usage: ... netem latency TIME [ gap PACKETS] \n" \
+" [ loss PERCENT ] [ duplicate PERCENT ]\n" \
+" [ rate KBPS ] [ limit BYTES]\n");
}
static void explain1(const char *arg)
@@ -40,18 +42,14 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
struct tc_netem_qopt opt;
- unsigned mtu=1500, rate=0;
int ok = 0;
memset(&opt, 0, sizeof(opt));
+ opt.limit = 1000;
while (argc > 0) {
if (matches(*argv, "limit") == 0) {
NEXT_ARG();
- if (opt.limit || rate) {
- fprintf(stderr, "Double \"limit/rate\" spec\n");
- return -1;
- }
if (get_size(&opt.limit, *argv)) {
explain1("limit");
return -1;
@@ -80,21 +78,17 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
return -1;
}
ok++;
- } else if (matches(*argv, "rate") == 0) {
+ } else if (matches(*argv, "duplicate") == 0) {
NEXT_ARG();
- if (rate) {
- fprintf(stderr, "Double \"rate\" spec\n");
- return -1;
- }
- if (get_rate(&rate, *argv)) {
- explain1("rate");
+ if (get_percent(&opt.duplicate, *argv)) {
+ explain1("duplicate");
return -1;
}
ok++;
- } else if (strcmp(*argv, "mtu") == 0) {
+ } else if (matches(*argv, "rate") == 0) {
NEXT_ARG();
- if (get_size(&mtu, *argv)) {
- explain1("mtu");
+ if (get_rate(&opt.rate, *argv)) {
+ explain1("rate");
return -1;
}
ok++;
@@ -109,19 +103,8 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
argc--; argv++;
}
- if (!ok)
- return 0;
-
- if (!opt.limit && !rate) {
- fprintf(stderr, "Either \"limit\" or \"rate\" are required.\n");
- return -1;
- }
-
- /* Compute netem bandwith product as limit */
- if (opt.limit == 0)
- opt.limit = ((double)rate * (double)opt.latency/1000000.);
-
- addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
+ if (ok)
+ addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
return 0;
}