-p just generate Preview of data transfer statistics and exit (after -r)\n\
-s Start shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\
-q Quit shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\
+-2 Reduce HTB ceil (min+(max-min)/2 + keep stats like -p) (after -r)\n\
+-4 Reduce HTB ceil (min+(max-min)/2 + keep stats like -p) (after -r)\n\
-n run Now (like -r delay - overrides qos-free-delay keyword, after boot)\n\
-f just Flush iptables and tc classes and exit (stop shaping, no QiS)\n\
-9 emergency iptables flush (like -f, but dumps data transfer statistics)\n\
\r
perc6=(double)(bytes6)/(bytes4+bytes6)*100;\r
fputs("<p><table class=\"decorated last\"><caption>IP protocols usage</caption>\n",f);\r
- fprintf(f, "%s<td>Total %d IPv4 (addreses)</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%.2f %%)</td></tr>\n",\r
+ fprintf(f, "%s<td>Total %d IPv4 addreses</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%.2f %%)</td></tr>\n",\r
tr_odd_even(), count4, bytes4, (double)(bytes4)/(bytes4+bytes6)*100, pkts4, (float)(100*pkts4)/(pkts4+pkts6));\r
- fprintf(f, "%s<td>Total %d IPv6 (/64 ranges)</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%.2f %%)</td></tr>\n",\r
+ fprintf(f, "%s<td>Total %d IPv6 /64 ranges</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%.2f %%)</td></tr>\n",\r
tr_odd_even(), count6, bytes6, perc6, pkts6, (float)(100*pkts6)/(pkts4+pkts6));\r
fputs("</table></p>\n", f);\r
}\r
iplog=fopen(str,"a");\r
if(iplog)\r
{\r
- fprintf(iplog, "%ld\t%d\t%d %%\t%Lu M\t%Ld %%\tACTIVE %d\tTRAFFIC %Lu M\tCLASSES %d\tFUP-LIMIT %d\tLOW-PRIO %d\tIPv6 %Lu\t%.2f %%\t%s",\r
+ fprintf(iplog, "%ld\t%d\t%d %%\t%Lu M\t%Ld %%\tACTIVE %d\tTRAFFIC %Lu M\tCLASSES %d\tFUP-LIMIT %d\tLOW-PRIO %d\tIPv6 %Lu M\t%.2f %%\t%s",\r
time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, \r
active_classes, total_traffic, i, limit_count, prio_count,\r
bytes6, perc6, d); /* d = date*/\r
int nodelay = FALSE;\r
int just_preview = FALSE; /* preview - generate just stats */\r
int start_shaping = FALSE; /* apply FUP - requires classmap file */\r
- int stop_shaping = FALSE; /* apply FUP - requires classmap file */\r
+ int stop_shaping = FALSE; /* lift FUP - requires classmap file */\r
+ int reduce_ceil = 0; /* allow only rate+(ceil-rate)/2, /4, etc. */\r
int just_logs = FALSE; /* just parse logs */\r
int run = FALSE;\r
int total = 0;\r
argument("-9") { run=TRUE; just_flush=9; }\r
argument("-p") { run=TRUE; just_preview=TRUE; }\r
argument("-q") { run=TRUE; just_preview=TRUE; stop_shaping=TRUE; }\r
+ argument("-2") { run=TRUE; just_preview=TRUE; reduce_ceil=2; }\r
+ argument("-4") { run=TRUE; just_preview=TRUE; reduce_ceil=4; }\r
argument("-s") { run=TRUE; just_preview=TRUE; start_shaping=TRUE; }\r
argument("-r") { run=TRUE; }\r
argument("-n") { run=TRUE; nodelay=TRUE; }\r
\r
if(just_preview)\r
{\r
- if(start_shaping || stop_shaping)\r
+ if(start_shaping || stop_shaping || reduce_ceil)\r
{\r
printf("Reading %s and applying Fair Use Policy rules ... \n", classmap);\r
parse(classmap)\r
if_exists(ip,ips,eq(ip->addr,_))\r
{\r
ip->mark=atoi(ptr);\r
- if(ip->max < ip->desired || stop_shaping) /* apply or disable FUP limit immediately.... */\r
+ if(ip->max < ip->desired || stop_shaping || reduce_ceil) /* apply or disable FUP limit immediately.... */\r
{\r
if(stop_shaping)\r
{\r
}\r
else\r
{\r
- printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark); \r
+ printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark);\r
+ if(reduce_ceil)\r
+ {\r
+ ip->max = ip->min + (ip->desired-ip->min)/reduce_ceil;\r
+ }\r
}\r
printf("(down: %dk-%dk ", ip->min, ip->max); \r
sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d", \r
{\r
swchar='s';\r
}\r
+ else if(reduce_ceil)\r
+ {\r
+ swchar='0'+reduce_ceil; /* -2, -4 */\r
+ }\r
else if(stop_shaping)\r
{\r
swchar='q';\r