Lines Matching +full:p1 +full:- +full:burst +full:- +full:params

1 /*-
7 * Implemented by Rasool Al-Saadi <ralsaadi@swin.edu.au>
9 * Copyright (c) 2002-2003,2010 Luigi Rizzo
57 { "dst-ip", TOK_DSTIP },
58 { "src-ip", TOK_SRCIP },
59 { "dst-port", TOK_DSTPORT },
60 { "src-port", TOK_SRCPORT },
75 { "fq_codel", TOK_FQ_CODEL}, /* FQ-Codel */
77 { "fq_pie", TOK_FQ_PIE}, /* FQ-PIE */
90 { "flow-id", TOK_FLOWID},
91 { "dst-ipv6", TOK_DSTIP6},
92 { "dst-ip6", TOK_DSTIP6},
93 { "src-ipv6", TOK_SRCIP6},
94 { "src-ip6", TOK_SRCIP6},
96 { "burst", TOK_BURST},
97 { "dummynet-params", TOK_NULL },
132 oid->len = len;
133 oid->type = type;
134 oid->subtype = 0;
135 oid->id = id;
184 * returns -1 if s is not a valid time, otherwise, return time in us
194 return -1;
198 return -1;
204 return -1;
218 return -1;
237 oid_fill(&ep->oid, l, DN_CMD_GET, DN_API_VERSION);
238 ep->oid.len = l;
239 ep->oid.subtype = subtype;
240 ep->nr = nr;
242 ret = do_cmd(-IP_DUMMYNET3, ep, (uintptr_t)&l);
250 if( !strcasecmp(ep->name, "codel")) {
251 us_to_time(ep->par[0], strt1);
252 us_to_time(ep->par[1], strt2);
255 if (ep->par[2] & CODEL_ECN_ENABLED)
259 } else if( !strcasecmp(ep->name, "pie")) {
260 us_to_time(ep->par[0], strt1);
261 us_to_time(ep->par[1], strt2);
262 us_to_time(ep->par[2], strt3);
267 ep->par[4] / (float) PIE_SCALE,
268 ep->par[5] / (float) PIE_SCALE,
270 ep->par[3] / (float) PIE_SCALE
273 if (ep->par[6] & PIE_ECN_ENABLED)
277 if (ep->par[6] & PIE_CAPDROP_ENABLED)
281 if (ep->par[6] & PIE_ON_OFF_MODE_ENABLED)
283 if (ep->par[6] & PIE_DEPRATEEST_ENABLED)
287 if (ep->par[6] & PIE_DERAND_ENABLED)
295 if (!strcasecmp(ep->name,"FQ_CODEL")) {
296 us_to_time(ep->par[0], strt1);
297 us_to_time(ep->par[1], strt2);
301 (intmax_t) ep->par[3],
302 (intmax_t) ep->par[4],
303 (intmax_t) ep->par[5]
305 if (ep->par[2] & CODEL_ECN_ENABLED)
310 } else if (!strcasecmp(ep->name,"FQ_PIE")) {
311 us_to_time(ep->par[0], strt1);
312 us_to_time(ep->par[1], strt2);
313 us_to_time(ep->par[2], strt3);
319 ep->par[4] / (float) PIE_SCALE,
320 ep->par[5] / (float) PIE_SCALE,
322 ep->par[3] / (float) PIE_SCALE,
323 (intmax_t) ep->par[7],
324 (intmax_t) ep->par[8],
325 (intmax_t) ep->par[9]
328 if (ep->par[6] & PIE_ECN_ENABLED)
332 if (ep->par[6] & PIE_CAPDROP_ENABLED)
336 if (ep->par[6] & PIE_ON_OFF_MODE_ENABLED)
338 if (ep->par[6] & PIE_DEPRATEEST_ENABLED)
342 if (ep->par[6] & PIE_DERAND_ENABLED)
361 int field = rev ? -co.do_sort : co.do_sort;
368 res = a->len - b->len;
371 res = a->len_bytes - b->len_bytes;
375 res = a->tot_pkts - b->tot_pkts;
379 res = a->tot_bytes - b->tot_bytes;
383 res = -1;
386 return (int)(rev ? res : -res);
396 "mask: %s 0x%02x 0x%08x/0x%04x -> 0x%08x/0x%04x\n",
397 id->extra ? "queue," : "",
398 id->proto,
399 id->src_ip, id->src_port,
400 id->dst_ip, id->dst_port);
404 id->extra ? "queue," : "",
405 id->proto, id->flow_id6);
406 inet_ntop(AF_INET6, &(id->src_ip6), buf, sizeof(buf));
407 printf("%s/0x%04x -> ", buf, id->src_port);
408 inet_ntop(AF_INET6, &(id->dst_ip6), buf, sizeof(buf));
409 printf("%s/0x%04x\n", buf, id->dst_port);
421 printf("BKT ___Prot___ _flow-id_ "
433 struct ipfw_flow_id *id = &ni->fid;
435 pe = getprotobynumber(id->proto);
437 bprintf(bp, "%3u%c", (ni->oid.id) & 0xff,
438 id->extra ? '*' : ' ');
441 bprintf(bp, "%-4s ", pe->p_name);
443 bprintf(bp, "%4u ", id->proto);
444 ina.s_addr = htonl(id->src_ip);
445 bprintf(bp, "%15s/%-5d ",
446 inet_ntoa(ina), id->src_port);
447 ina.s_addr = htonl(id->dst_ip);
448 bprintf(bp, "%15s/%-5d ",
449 inet_ntoa(ina), id->dst_port);
453 bprintf(bp, "%9s ", pe->p_name);
455 bprintf(bp, "%9u ", id->proto);
456 bprintf(bp, "%7d %39s/%-5d ", id->flow_id6,
457 inet_ntop(AF_INET6, &(id->src_ip6), buff, sizeof(buff)),
458 id->src_port);
459 bprintf(bp, " %39s/%-5d ",
460 inet_ntop(AF_INET6, &(id->dst_ip6), buff, sizeof(buff)),
461 id->dst_port);
463 pr_u64(bp, &ni->tot_pkts, 4);
464 pr_u64(bp, &ni->tot_bytes, 8);
466 ni->length, ni->len_bytes, ni->drops);
477 l = fs->qsize;
478 if (fs->flags & DN_QSIZE_BYTES) {
485 if (fs->plr[0] || fs->plr[1]) {
486 if (fs->plr[1] == 0)
488 1.0 * fs->plr[0] / (double)(0x7fffffff));
491 1.0 * fs->plr[0] / (double)(0x7fffffff),
492 1.0 * fs->plr[1] / (double)(0x7fffffff),
493 1.0 * fs->plr[2] / (double)(0x7fffffff),
494 1.0 * fs->plr[3] / (double)(0x7fffffff));
498 if (fs->flags & DN_IS_RED) { /* RED parameters */
501 (fs->flags & DN_IS_GENTLE_RED) ? 'G' : ' ',
502 1.0 * fs->w_q / (double)(1 << SCALE_RED),
503 fs->min_th,
504 fs->max_th,
505 1.0 * fs->max_p / (double)(1 << SCALE_RED));
506 if (fs->flags & DN_IS_ECN)
510 } else if (fs->flags & DN_IS_AQM) {
511 get_extra_parms(fs->fs_nr, red, DN_AQM_PARAMS);
518 prefix, qs, plr, fs->oid.id, fs->buckets, red);
523 fs->fs_nr, qs, plr, fs->oid.id, fs->buckets,
524 fs->sched_nr, fs->par[0], fs->par[1], fs->par[2], red);
525 if (fs->flags & DN_HAVE_MASK)
526 print_mask(&fs->flow_mask);
534 if (p->samples_no <= 0)
537 loss = p->loss_level;
538 loss /= p->samples_no;
540 p->name, loss, p->samples_no);
570 for (; oid != end; oid = O_NEXT(oid, oid->len)) {
571 if (oid->len < sizeof(*oid))
572 errx(1, "invalid oid len %d\n", oid->len);
574 switch (oid->type) {
577 printf("unrecognized object %d size %d\n", oid->type, oid->len);
586 l = (oid->len - sizeof(*oid))/sizeof(d->p[0]);
591 printf("%u ", d->p[i]);
597 printf("answer for cmd %d, len %d\n", oid->type, oid->id);
603 s->sched_nr,
604 s->name, s->flags, s->buckets, s->oid.id);
607 get_extra_parms(s->sched_nr, parms, DN_SCH_PARAMS);
610 if (s->flags & DN_HAVE_MASK)
611 print_mask(&s->sched_mask);
617 print_header(&((struct dn_flow *)oid)->fid);
627 double b = p->bandwidth;
629 char burst[5 + 7];
645 if (humanize_number(burst, sizeof(burst), p->burst,
647 sprintf(burst, "%d", (int)p->burst);
648 sprintf(buf, "%05d: %s %4d ms burst %s",
649 p->link_nr % DN_MAX_ID, bwbuf, p->delay, burst);
704 * L +-- loss-level x
711 * +-------*------------------->
732 * loss-level L
758 loss-level 0.86
775 #define ED_TOK_LOSS "loss-level"
784 * returns 1 if s is a non-negative number, with at least one '.'
806 if (*bandwidth != (uint32_t)-1)
815 namelen--;
856 const struct point *p1 = vp1;
860 res = p1->prob - p2->prob;
862 res = p1->delay - p2->delay;
864 return -1;
882 int samples = -1;
883 double loss = -1.0;
885 int delay_first = -1;
891 p->link_nr = link->link_nr;
934 read_bandwidth(arg, &link->bandwidth, buf, sizeof(buf));
936 if (loss != -1.0)
979 if (samples == -1) {
984 if (loss == -1.0) {
997 for (i = 0; i<points_no-1; ++i) {
1008 p->samples[ix] = x1;
1010 double m = (y2-y1)/(x2-x1);
1011 double c = y1 - m*x1;
1013 p->samples[ix] = (ix - c)/m;
1016 p->samples_no = samples;
1017 p->loss_level = loss * samples;
1018 strlcpy(p->name, profile_name, sizeof(p->name));
1032 ep->par[i] = -1;
1038 * 0- target, 1- interval, 2- flags,
1040 * 3- quantum, 4- limit, 5- flows
1043 ep->par[2] = 0;
1045 ep->par[2] = CODEL_ECN_ENABLED;
1049 (*ac)--; av++;
1055 ep->par[0] = time_to_us(av[0]);
1056 (*ac)--; av++;
1063 ep->par[1] = time_to_us(av[0]);
1064 (*ac)--; av++;
1068 ep->par[2] = CODEL_ECN_ENABLED;
1071 ep->par[2] &= ~CODEL_ECN_ENABLED;
1080 ep->par[3]= atoi(av[0]);
1081 (*ac)--; av++;
1090 ep->par[4] = atoi(av[0]);
1091 (*ac)--; av++;
1100 ep->par[5] = atoi(av[0]);
1101 (*ac)--; av++;
1105 printf("%s is Invalid parameter\n", av[-1]);
1112 * 0- target , 1- tupdate, 2- max_burst,
1113 * 3- max_ecnth, 4- alpha,
1114 * 5- beta, 6- flags
1116 * 7- quantum, 8- limit, 9- flows
1120 ep->par[6] = PIE_CAPDROP_ENABLED | PIE_DEPRATEEST_ENABLED
1123 /* for FQ-PIE, use TS mode */
1124 ep->par[6] = PIE_CAPDROP_ENABLED | PIE_DERAND_ENABLED
1129 (*ac)--; av++;
1135 ep->par[0] = time_to_us(av[0]);
1136 (*ac)--; av++;
1143 ep->par[1] = time_to_us(av[0]);
1144 (*ac)--; av++;
1151 ep->par[2] = time_to_us(av[0]);
1152 (*ac)--; av++;
1159 ep->par[3] = atof(av[0]) * PIE_SCALE;
1160 (*ac)--; av++;
1167 ep->par[4] = atof(av[0]) * PIE_SCALE;
1168 (*ac)--; av++;
1175 ep->par[5] = atof(av[0]) * PIE_SCALE;
1176 (*ac)--; av++;
1180 ep->par[6] |= PIE_ECN_ENABLED;
1183 ep->par[6] &= ~PIE_ECN_ENABLED;
1187 ep->par[6] |= PIE_CAPDROP_ENABLED;
1190 ep->par[6] &= ~PIE_CAPDROP_ENABLED;
1194 ep->par[6] |= PIE_ON_OFF_MODE_ENABLED;
1198 ep->par[6] |= PIE_DEPRATEEST_ENABLED;
1202 ep->par[6] &= ~PIE_DEPRATEEST_ENABLED;
1206 ep->par[6] |= PIE_DERAND_ENABLED;
1209 ep->par[6] &= ~PIE_DERAND_ENABLED;
1219 ep->par[7]= atoi(av[0]);
1220 (*ac)--; av++;
1229 ep->par[8] = atoi(av[0]);
1230 (*ac)--; av++;
1239 ep->par[9] = atoi(av[0]);
1240 (*ac)--; av++;
1245 printf("%s is invalid parameter\n", av[-1]);
1261 * do_pipe = 1 -> "pipe N config ..." only for backward compatibility
1268 * do_pipe = 2 -> flowset N config
1271 * do_pipe = 3 -> sched N config
1306 /* Extra Params */
1308 /* two lmax_extra because one for AQM params and another
1309 * sch params
1314 av++; ac--;
1317 i = atoi(*av); av++; ac--;
1319 i = -1;
1325 base->id = DN_API_VERSION;
1335 * If we do a 'pipe config' mask -> sched_mask.
1341 sch_extra ->oid.subtype = 0; /* don't configure scheduler */
1347 aqm_extra ->oid.subtype = 0; /* don't configure AQM */
1351 sch->sched_nr = i;
1352 sch->oid.subtype = 0; /* defaults to WF2Q+ */
1353 mask = &sch->sched_mask;
1354 flags = &sch->flags;
1355 buckets = &sch->buckets;
1358 p->link_nr = i;
1361 fs->fs_nr = i + 2*DN_MAX_ID;
1362 fs->sched_nr = i + DN_MAX_ID;
1368 aqm_extra ->oid.subtype = 0;
1371 fs->fs_nr = i;
1372 mask = &fs->flow_mask;
1373 flags = &fs->flags;
1374 buckets = &fs->buckets;
1380 sch_extra ->oid.subtype = 0;
1385 aqm_extra ->oid.subtype = 0;
1388 sch->sched_nr = i;
1389 mask = &sch->sched_mask;
1390 flags = &sch->flags;
1391 buckets = &sch->buckets;
1393 fs->fs_nr = i + DN_MAX_ID;
1394 fs->sched_nr = i;
1397 /* set to -1 those fields for which we want to reuse existing
1403 p->bandwidth = -1;
1404 for (j = 0; j < nitems(fs->par); j++)
1405 fs->par[j] = -1;
1409 ac--; av++;
1414 fs->flags |= DN_NOERROR;
1423 fs->plr[0] = (int)(d*0x7fffffff);
1428 fs->plr[1] = (int)(d*0x7fffffff);
1433 fs->plr[2] = (int)(d*0x7fffffff);
1438 fs->plr[3] = (int)(d*0x7fffffff);
1440 ac--; av++;
1447 fs->qsize = strtoul(av[0], &end, 0);
1449 fs->flags |= DN_QSIZE_BYTES;
1450 fs->qsize *= 1024;
1453 fs->flags |= DN_QSIZE_BYTES;
1455 ac--; av++;
1462 ac--; av++;
1471 * per-flow queue, mask is dst_ip, dst_port,
1486 ac--; av++;
1493 mask->dst_ip = ~0;
1494 mask->src_ip = ~0;
1495 mask->dst_port = ~0;
1496 mask->src_port = ~0;
1497 mask->proto = ~0;
1498 n2mask(&mask->dst_ip6, 128);
1499 n2mask(&mask->src_ip6, 128);
1500 mask->flow_id6 = ~0;
1505 mask->extra = ~0;
1510 mask->addr_type = 4;
1511 p32 = &mask->dst_ip;
1515 mask->addr_type = 4;
1516 p32 = &mask->src_ip;
1520 mask->addr_type = 6;
1521 pa6 = &mask->dst_ip6;
1525 mask->addr_type = 6;
1526 pa6 = &mask->src_ip6;
1530 mask->addr_type = 6;
1531 p20 = &mask->flow_id6;
1535 p16 = &mask->dst_port;
1539 p16 = &mask->src_port;
1546 ac++; av--; /* backtrack */
1554 a = (a == 32) ? ~0 : (1 << a) - 1;
1579 mask->proto = (uint8_t)a;
1583 ac--; av++;
1592 fs->flags &= ~(DN_IS_RED|DN_IS_GENTLE_RED);
1593 fs->flags |= DN_IS_AQM;
1595 strlcpy(aqm_extra->name, av[-1],
1596 sizeof(aqm_extra->name));
1597 aqm_extra->oid.subtype = DN_AQM_PARAMS;
1604 if (!strcmp(av[-1],"type"))
1608 strlcpy(sch_extra->name, av[-1],
1609 sizeof(sch_extra->name));
1610 sch_extra->oid.subtype = DN_SCH_PARAMS;
1617 fs->flags |= DN_IS_RED;
1619 fs->flags |= DN_IS_GENTLE_RED;
1627 fs->w_q = (int) (w_q * (1 << SCALE_RED));
1630 fs->min_th = strtoul(end, &end, 0);
1632 fs->min_th *= 1024;
1635 fs->max_th = strtoul(end, &end, 0);
1637 fs->max_th *= 1024;
1643 fs->max_p = (int)(max_p * (1 << SCALE_RED));
1645 ac--; av++;
1649 fs->flags |= DN_IS_ECN;
1654 fs->flags &= ~(DN_IS_RED|DN_IS_GENTLE_RED);
1660 read_bandwidth(av[0], &p->bandwidth, NULL, 0);
1661 ac--; av++;
1667 p->delay = strtoul(av[0], NULL, 0);
1668 ac--; av++;
1678 strlcpy(sch->name, av[0], sizeof(sch->name));
1679 sch->oid.subtype = 0; /* use string */
1685 strlcpy(sch_extra->name, av[0],
1686 sizeof(sch_extra->name));
1687 sch_extra->oid.subtype = DN_SCH_PARAMS;
1690 ac--;av++;
1693 ac--;av++;
1701 fs->par[0] = strtol(av[0], &end, 0);
1702 ac--; av++;
1708 fs->par[1] = strtol(av[0], &end, 0);
1709 ac--; av++;
1715 fs->par[2] = strtol(av[0], &end, 0);
1716 ac--; av++;
1723 fs->sched_nr = strtoul(av[0], &end, 0);
1724 ac--; av++;
1734 --ac; ++av;
1739 NEED(p, "burst");
1740 NEED1("burst needs argument\n");
1742 if (expand_number(av[0], &p->burst) < 0)
1745 "burst: invalid argument");
1746 if (errno || p->burst > (1ULL << 48) - 1)
1748 "burst: out of range (0..2^48-1)");
1749 ac--; av++;
1753 errx(EX_DATAERR, "unrecognised option ``%s''", av[-1]);
1759 if (p->delay > 10000)
1761 if (p->bandwidth == (uint32_t)-1)
1762 p->bandwidth = 0;
1766 if (fs->flags & DN_QSIZE_BYTES) {
1772 &limit, &len, NULL, 0) == -1)
1774 if (fs->qsize > limit)
1782 &limit, &len, NULL, 0) == -1)
1784 if (fs->qsize > limit)
1789 if ((fs->flags & DN_IS_ECN) && !((fs->flags & DN_IS_RED)||
1790 (fs->flags & DN_IS_AQM)))
1794 if ((fs->flags & DN_IS_ECN) && !(fs->flags & DN_IS_RED))
1799 if (fs->flags & DN_IS_RED) {
1803 if (!(fs->flags & DN_IS_ECN) && (fs->min_th >= fs->max_th))
1805 fs->min_th, fs->max_th);
1806 else if ((fs->flags & DN_IS_ECN) && (fs->min_th > fs->max_th))
1808 fs->min_th, fs->max_th);
1810 if (fs->max_th == 0)
1815 &lookup_depth, &len, NULL, 0) == -1)
1823 &avg_pkt_size, &len, NULL, 0) == -1)
1833 * Ticks needed for sending a medium-sized packet.
1848 * (1-w_q)^x < 10^-3.
1850 w_q = ((double)fs->w_q) / (1 << SCALE_RED);
1852 fs->lookup_step = (int)idle / lookup_depth;
1853 if (!fs->lookup_step)
1854 fs->lookup_step = 1;
1855 weight = 1 - w_q;
1856 for (t = fs->lookup_step; t > 1; --t)
1857 weight *= 1 - w_q;
1858 fs->lookup_weight = (int)(weight * (1 << SCALE_RED));
1863 i = do_cmd(IP_DUMMYNET3, base, (char *)buf - (char *)base);
1893 for (s = *av; s != NULL; av++, ac--) {
1895 v[1] = (*endptr != '-') ? v[0] :
1908 av--;
1911 v[0] >= DN_MAX_ID-1 ||
1912 v[1] >= DN_MAX_ID-1) {
1930 * Format for a range can be n1-n2 or n3 n4 n5 ...
1932 * A number 'n4' is translate in a range 'n4-n4'
1933 * All number must be > 0 and < DN_MAX_ID-1
1945 ac--;
1973 oid->subtype = DN_LINK; /* list pipe */
1976 oid->subtype = DN_FS; /* list queue */
1979 oid->subtype = DN_SCH; /* list sched */
1993 ret = do_cmd(-IP_DUMMYNET3, oid, (uintptr_t)&l);
1994 if (ret != 0 || oid->id <= sizeof(*oid))
1996 buflen = oid->id + max_size;
1997 oid->len = sizeof(*oid); /* restore */
2003 bcopy(oid, x, oid->len);
2004 ret = do_cmd(-IP_DUMMYNET3, x, (uintptr_t)&l);
2005 if (ret != 0 || x->id <= sizeof(*oid))