prometheus.conf upgrade
authorxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Tue, 26 Nov 2013 20:09:37 +0000 (20:09 +0000)
committerxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Tue, 26 Nov 2013 20:09:37 +0000 (20:09 +0000)
git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@239 251d49ef-1d17-4917-a970-b30cf55b089b

ipstruct.h
parsehosts.c
prometheus.c

index 72bf976b87406945115a4fdb8b278161e338a32e..d8427deb8efa5815341858433eff38e47f1b7e60 100644 (file)
@@ -56,7 +56,7 @@ struct Keyword
  char *html_color;\r
  int ip_count;\r
  char *leaf_discipline;\r
\r
+ int allowed_avgmtu;        /* this is for calculating packet limits, 0 = no limit*/ \r
  list(Keyword);\r
 };\r
 \r
index 7e12a41b34d1280821ef1c916e417675fade4b4a..9ee2c2b003995e59c746cbe7789dd563f553817a 100644 (file)
@@ -151,6 +151,7 @@ void parse_hosts(char *hosts)
  char *str, *ptr;\r
  char *substring;\r
  struct IP *network;\r
+ int pktratio;\r
 \r
  parse(hosts)\r
  {\r
@@ -259,12 +260,15 @@ void parse_hosts(char *hosts)
       }\r
      }\r
 \r
-     /* MTU is 1450 bytes = 11600 bits ~= 12 kbit, max is in kb/s \r
-        average pkt 1/2 MTU = 6 kbit*/\r
-     ip->pps_limit = ip->max/6;\r
-     if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */\r
+     /* avg MTU bytes * 8 >> 10 = in bits, max is in kb/s  */\r
+     pktratio = (ip->keyword->allowed_avgmtu*8) >> 10;\r
+     if(pktratio > 0)\r
      {\r
-      ip->pps_limit = 0; /* do not apply packet limits */\r
+      ip->pps_limit = ip->max/pktratio;\r
+      if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */\r
+      {\r
+       ip->pps_limit = 0; /* do not apply packet limits */\r
+      }\r
      }\r
 \r
      ip->mark = FIRSTIPCLASS+1+class_count++;     \r
index 1227592f5e566027f35ced5bf9272bc9c0234e6f..087102e66aa75a0062260f3a2d5f7ef1d78fb8bb 100644 (file)
@@ -7,7 +7,7 @@
 /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf  */\r
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
 \r
-/* Modified by: xChaos, 20131119\r
+/* Modified by: xChaos, 20131126\r
                  ludva, 20080415\r
  \r
    Prometheus QoS is free software; you can redistribute it and/or\r
@@ -107,6 +107,8 @@ long long int     line = 1024; /* WAN/ISP download in kbps */
 long long int       up = 1024; /* WAN/ISP upload in kbps */\r
 int           free_min = 256; /* minimum guaranted bandwidth for all undefined hosts */\r
 int           free_max = 512; /* maximum allowed bandwidth for all undefined hosts */\r
+int      overlimit_min = 256; /* minimum guaranted bandwidth for all undefined hosts */\r
+int      overlimit_max = 512; /* maximum allowed bandwidth for all undefined hosts */\r
 int     qos_free_delay = 0; /* seconds to sleep before applying new QoS rules */\r
 int     digital_divide = 2; /* controls digital divide weirdness ratio, 1...3 */ \r
 int        max_nesting = 3; /* maximum nesting of HTB clases, built-in maximum seems to be 4 */\r
@@ -220,24 +222,25 @@ void get_config(char *config_filename)
    printf("%s ",kwd);\r
 \r
    create(keyword,Keyword);\r
-   keyword->key=kwd;\r
-   keyword->asymetry_ratio=1;          /* ratio for ADSL-like upload */\r
-   keyword->asymetry_fixed=0;          /* fixed treshold for ADSL-like upload */\r
-   keyword->data_limit=8;              /* hard shaping: apply magic_treshold if max*data_limit MB exceeded */\r
-   keyword->data_prio=4;               /* soft shaping (qos): reduce HTB prio if max*data_prio MB exceeded */\r
-   keyword->fixed_limit=0;             /* fixed data limit for setting lower HTB ceil */\r
-   keyword->fixed_prio=0;              /* fixed data limit for setting lower HTB prio */\r
-   keyword->reserve_min=8;            /* bonus for nominal HTB rate bandwidth (in kbps) */\r
-   keyword->reserve_max=0;            /* malus for nominal HTB ceil (in kbps) */\r
-   keyword->default_prio=highest_priority+1;\r
-   keyword->html_color="000000";\r
-   keyword->ip_count=0;\r
-   keyword->leaf_discipline="";\r
+   keyword->key = kwd;\r
+   keyword->asymetry_ratio = 1;          /* ratio for ADSL-like upload */\r
+   keyword->asymetry_fixed = 0;          /* fixed treshold for ADSL-like upload */\r
+   keyword->data_limit = 8;              /* hard shaping: apply magic_treshold if max*data_limit MB exceeded */\r
+   keyword->data_prio = 4;               /* soft shaping (qos): reduce HTB prio if max*data_prio MB exceeded */\r
+   keyword->fixed_limit = 0;             /* fixed data limit for setting lower HTB ceil */\r
+   keyword->fixed_prio = 0;              /* fixed data limit for setting lower HTB prio */\r
+   keyword->reserve_min = 8;            /* bonus for nominal HTB rate bandwidth (in kbps) */\r
+   keyword->reserve_max = 0;            /* malus for nominal HTB ceil (in kbps) */\r
+   keyword->default_prio = highest_priority+1;\r
+   keyword->html_color = "000000";\r
+   keyword->ip_count = 0;\r
+   keyword->leaf_discipline = "";\r
+   keyword->allowed_avgmtu = 0;\r
 \r
    push(keyword,keywords);\r
    if(!defaultkeyword)\r
    {\r
-    defaultkeyword=keyword;\r
+    defaultkeyword = keyword;\r
    }\r
    keywordcount++;\r
    \r
@@ -253,17 +256,18 @@ void get_config(char *config_filename)
      {\r
       char *tmptr=_; /*  <---- l+1 ----> */\r
       _+=l+1;        /*  via-prometheus-asymetry-ratio, etc. */\r
-      ioption("asymetry-ratio",keyword->asymetry_ratio);\r
-      ioption("asymetry-treshold",keyword->asymetry_fixed);\r
-      ioption("magic-relative-limit",keyword->data_limit);\r
-      ioption("magic-relative-prio",keyword->data_prio);\r
-      loption("magic-fixed-limit",keyword->fixed_limit);\r
-      loption("magic-fixed-prio",keyword->fixed_prio);\r
-      ioption("htb-default-prio",keyword->default_prio);\r
-      ioption("htb-rate-bonus",keyword->reserve_min);\r
-      ioption("htb-ceil-malus",keyword->reserve_max);\r
-      option("leaf-discipline",keyword->leaf_discipline);\r
-      option("html-color",keyword->html_color);\r
+      ioption("asymetry-ratio", keyword->asymetry_ratio);\r
+      ioption("asymetry-treshold", keyword->asymetry_fixed);\r
+      ioption("magic-relative-limit", keyword->data_limit);\r
+      ioption("magic-relative-prio", keyword->data_prio);\r
+      loption("magic-fixed-limit", keyword->fixed_limit);\r
+      loption("magic-fixed-prio", keyword->fixed_prio);\r
+      ioption("htb-default-prio", keyword->default_prio);\r
+      ioption("htb-rate-bonus", keyword->reserve_min);\r
+      ioption("htb-ceil-malus", keyword->reserve_max);\r
+      option("leaf-discipline", keyword->leaf_discipline);\r
+      option("html-color", keyword->html_color);\r
+      ioption("allowed-avgmtu" ,keyword->allowed_avgmtu);\r
       _=tmptr;\r
       \r
       if(keyword->data_limit || keyword->fixed_limit || \r
@@ -316,6 +320,8 @@ void get_config(char *config_filename)
 /*  ioption("qos-proxy-port",proxy_port); */\r
   ioption("free-rate",free_min);\r
   ioption("free-ceil",free_max);\r
+  ioption("overlimit-rate",overlimit_min);\r
+  ioption("overlimit-ceil",overlimit_max);\r
   ioption("htb-burst",burst);\r
   ioption("htb-burst-main",burst_main);\r
   ioption("htb-burst-group",burst_group);\r
@@ -1356,10 +1362,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
    puts("Generating bandwith class for overlimit packets...");\r
    /*-----------------------------------------------------------------*/\r
    sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",\r
-                tc, lan, parent, OVERLIMIT_CLASS, 1024, 4096, burst, lowest_priority);\r
+                tc, lan, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority);\r
    safe_run(str);\r
    sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",\r
-                tc, wan, parent, OVERLIMIT_CLASS, 1024, 4096, burst, lowest_priority);\r
+                tc, wan, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority);\r
    safe_run(str);\r
  }\r
  printf("Total IP count: %d\n", i);\r
This page took 0.204984 seconds and 4 git commands to generate.