wireless-net/trunk/sbin/gen-wlan-files.py

arekm cvs at pld-linux.org
Sat Apr 8 20:49:30 CEST 2006


Author: arekm
Date: Sat Apr  8 20:49:28 2006
New Revision: 7333

Modified:
   wireless-net/trunk/sbin/gen-wlan-files.py
Log:
Separate UP/DOWN bandwidth.

Modified: wireless-net/trunk/sbin/gen-wlan-files.py
==============================================================================
--- wireless-net/trunk/sbin/gen-wlan-files.py	(original)
+++ wireless-net/trunk/sbin/gen-wlan-files.py	Sat Apr  8 20:49:28 2006
@@ -76,12 +76,14 @@
 hostname = config.get('base', 'hostname')
 use_htb = config.getboolean('base', 'use_htb')
 
-bandwidth = 32768
+bandwidth_up = 32768
+bandwidth_down = 32768
 ipac = False
 use_ipac = False
 old_ipac = False
 try:
-    bandwidth = config.getint('base', 'bandwidth')
+    bandwidth_up = config.getint('base', 'bandwidth_up')
+    bandwidth_down = config.getint('base', 'bandwidth_down')
     ipac = config.get('base', 'ipac')
     use_ipac = config.getboolean('base', 'use_ipac')
     old_ipac = config.getboolean('base', 'use_old_ipac')
@@ -170,18 +172,27 @@
     users.append(u)
 fp.close()
 
-user_bandwidth = int(bandwidth/len(users))
-if user_bandwidth < 1:
-    user_bandwidth = 1
-
-print "Bandwith total: %s, per user %s" % (str(bandwidth), str(user_bandwidth))
-
-for iface in [ iface_lup, iface_ldown ]:
-    print "Preparing root tc queue for %s interface." % iface
-    run("tc qdisc del root dev %s 2> /dev/null" % iface, False)
-    run("tc qdisc add dev %s root handle 1: htb default 2" % iface)
-    run("tc class add dev %s classid 0001:0001 root htb rate 990000kbit ceil 100000kbit quantum 12207750" % (iface))
-    run("tc class add dev %s classid 0001:0005 parent 0001:0001 htb rate %s.00kbit ceil 1400kbit quantum 174250" % (iface, bandwidth))
+user_bandwidth_up = int(bandwidth_up/len(users))
+if user_bandwidth_up < 1:
+    user_bandwidth_up = 1
+
+user_bandwidth_down = int(bandwidth_down/len(users))
+if user_bandwidth_down < 1:
+    user_bandwidth_down = 1
+
+print "Bandwith total: UP [%s, per user %s], DOWN [%s, per user %s]" % (str(bandwidth_up), str(user_bandwidth_down))
+
+print "Preparing root tc queue for %s interface." % iface_lup
+run("tc qdisc del root dev %s 2> /dev/null" % iface_lup, False)
+run("tc qdisc add dev %s root handle 1: htb default 2" % iface_lup)
+run("tc class add dev %s classid 0001:0001 root htb rate 990000kbit ceil 100000kbit quantum 12207750" % (iface_lup))
+run("tc class add dev %s classid 0001:0005 parent 0001:0001 htb rate %s.00kbit ceil 1400kbit quantum 174250" % (iface_lup, bandwidth_up))
+
+print "Preparing root tc queue for %s interface." % iface_ldown
+run("tc qdisc del root dev %s 2> /dev/null" % iface_ldown, False)
+run("tc qdisc add dev %s root handle 1: htb default 2" % iface_ldown)
+run("tc class add dev %s classid 0001:0001 root htb rate 990000kbit ceil 100000kbit quantum 12207750" % (iface_ldown))
+run("tc class add dev %s classid 0001:0005 parent 0001:0001 htb rate %s.00kbit ceil 1400kbit quantum 174250" % (iface_ldown, bandwidth_ldown))
 
 for u in users:
 
@@ -200,7 +211,7 @@
 
     # upstream
     if speed_up > 0:
-        user_up_bandwidth = user_bandwidth
+        user_up_bandwidth = user_bandwidth_up
         if user_up_bandwidth > speed_up:
             user_up_bandwidth = speed_up
         run("tc class add dev %s classid 0001:%s parent 0001:0005 htb rate %dkbit ceil %dkbit quantum 1500" % (iface_lup, nr_htb, user_up_bandwidth, speed_up))
@@ -209,7 +220,7 @@
         run("iptables -t mangle -A customers -s %s -j IMQ --todev 0" % (ip))
     # downstream
     if speed_down > 0:
-        user_down_bandwidth = user_bandwidth
+        user_down_bandwidth = user_bandwidth_down
         if user_down_bandwidth > speed_down:
             user_down_bandwidth = speed_down
         run("tc class add dev %s classid 0001:%s parent 0001:0005 htb rate %dkbit ceil %dkbit quantum 1500" % (iface_ldown, nr_htb, user_down_bandwidth, speed_down))


More information about the pld-cvs-commit mailing list