1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
# policer at external interface: build srTCM ----------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext \
tcsim -Xc,-xif:test -q
dev eth0 {
// THIS EXAMPLE IS OBSOLETE - USE meters.tc INSTEAD !
/*
* srtcm.tc - Color-blind Single Rate Three Color Marker (srTCM) example
*
* Written 2001 by Werner Almesberger
* Copyright 2001 Network Robots
*
* This example implements an srTCM as described in RFC2697.
*/
#define CIR 100 kbps
#define CBS 10 kB
#define EBS 50 kB
#define MTU 1500 B /* required by implementation */
#define RED 1
#define YELLOW 2
#define GREEN 3
$Te = police(rate 0 kbps,burst EBS,mtu MTU);
$Tc = police(rate CIR,burst CBS,overflow police $Te,mtu MTU);
dsmark (indices 64) {
class (GREEN)
if conform police $Tc && count police $Tc;
class (YELLOW)
if conform police $Te && count police $Te;
class (RED)
if 1;
}
}
send 0 /* match only becomes active if there is traffic */
EOF
# policer at external interface: build trTCM ----------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext \
tcsim -Xc,-xif:test -q
dev eth0 {
// THIS EXAMPLE IS OBSOLETE - USE meters.tc INSTEAD !
/*
* trtcm.tc - Color-blind Two Rate Three Color Marker (trTCM) example
*
* Written 2001 by Werner Almesberger
* Copyright 2001 Network Robots
*
* This example implements a trTCM as described in RFC2698.
*/
#define CIR 100 kbps
#define PIR 150 kbps
#define CBS 10 kB
#define PBS 50 kB
#define MTU 1500 B /* required by implementation */
#define RED 1
#define YELLOW 2
#define GREEN 3
$Tc = police(rate CIR,burst CBS,mtu MTU);
$Tp = police(rate PIR,burst PBS,mtu MTU);
dsmark (indices 64) {
class (GREEN)
if conform police $Tc && conform police $Tp &&
count police $Tc && count police $Tp;
class (YELLOW)
if conform police $Tp && count police $Tp;
class (RED)
if 1;
}
}
send 0 /* match only becomes active if there is traffic */
EOF
# policer at external interface: with matches (no overlap) --------------------
tcc -xif:err 2>&1 | sed '/^match/s/ action.*//p;d'
$p1 = police(rate 1kbps,burst 1kB);
$p2 = police(rate 2kbps,burst 2kB);
prio {
class if raw[0] == 5 && conform police $p1;
class if raw[1] == 4 && conform police $p2;
class if 1;
}
EOF
match 0:0:16=0x0504
match 0:0:8=0x05
match 0:8:8=0x04
match
# policer at external interface: with matches (with overlap) ------------------
tcc -xif:err 2>&1 | sed '/^match/s/ action.*//p;d'
$p1 = police(rate 1kbps,burst 1kB);
$p2 = police(rate 2kbps,burst 2kB);
prio {
class if raw[0] == 5 && conform police $p1;
class if raw[0] == 4 && conform police $p2;
class if 1;
}
EOF
match 0:0:8=0x05
match 0:0:8=0x04
match
|