Revision 6fd23d7a
Added by Ermal LUÇI about 14 years ago
usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc | ||
---|---|---|
1010 | 1010 |
} |
1011 | 1011 |
array_pop($tmppath); |
1012 | 1012 |
|
1013 |
$downfactor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]); |
|
1014 |
$downbw = floatval($config['ezshaper']['step2']["conn{$i}download"]) * $downfactor; |
|
1015 |
|
|
1016 |
$tmppath = array(); |
|
1017 |
$altq =& new altq_root_queue(); |
|
1018 |
|
|
1019 |
$altq->SetInterface($config['ezshaper']['step2']["local{$i}interface"]); |
|
1020 |
$altq->SetScheduler($config['ezshaper']['step2']["local{$i}downloadscheduler"]); |
|
1021 |
$altq->SetBandwidth($config['ezshaper']['step2']["conn{$i}download"]); |
|
1022 |
$altq->SetBwscale($config['ezshaper']['step2']["conn{$i}downloadspeed"]); |
|
1023 |
$altq->SetEnabled("on"); |
|
1024 |
$altq_list_queues[$altq->GetQname()] =& $altq; |
|
1025 |
array_push($tmppath, $config['ezshaper']['step2']["local{$i}interface"]); |
|
1026 |
$altq->SetLink($tmppath); |
|
1027 |
//var_dump($input_errors); |
|
1028 |
$altq->wconfig(); |
|
1029 |
|
|
1030 |
$sched = $config['ezshaper']['step2']["local{$i}downloadscheduler"]; |
|
1031 |
$voipbw =0; |
|
1032 |
$voipbwunit = "%"; |
|
1033 |
$voip = false; |
|
1034 |
$penalty = false; |
|
1035 |
$penaltybw = 0; |
|
1036 |
$penaltybwunit = "%"; |
|
1037 |
$p2p = false; |
|
1038 |
$p2pcatchall = false; |
|
1039 |
$p2pcatchbw = 0; |
|
1040 |
$games = false; |
|
1041 |
$otherpriority = false; |
|
1042 |
$remainbw = 0; |
|
1043 |
|
|
1044 |
|
|
1045 |
if ($config['ezshaper']['step3']['enable']) { |
|
1046 |
$voip = true; |
|
1047 |
$voipbw = $config['ezshaper']['step3']["local{$i}download"]; |
|
1048 |
$voipbwunit = $config['ezshaper']['step3']["local{$i}downloadspeed"]; |
|
1049 |
if ($sched != HFSC) { |
|
1050 |
if ($penaltybwunit == "%") |
|
1051 |
$factor = $downbw/100; |
|
1052 |
else |
|
1053 |
$factor = wizard_get_bandwidthtype_scale($voipbwunit); |
|
1054 |
$remainbw += floatval($voipbw) * $factor; |
|
1055 |
} else |
|
1056 |
$remainbw += 32000; /* 32Kbit/s reserved for HFSC linksharing */ |
|
1057 |
} |
|
1058 |
if ($config['ezshaper']['step4']['enable']) { |
|
1059 |
$penalty = true; |
|
1060 |
$penaltybw = $config['ezshaper']['step4']['bandwidth']; |
|
1061 |
$penaltybwunit = $config['ezshaper']['step4']['bandwidthunit']; |
|
1062 |
if ($penaltybwunit == "%") |
|
1063 |
$factor = $downbw/100; |
|
1064 |
else |
|
1065 |
$factor = wizard_get_bandwidthtype_scale($penaltybwunit); |
|
1066 |
$remainbw += floatval($penaltybw) * $factor; |
|
1067 |
} else { |
|
1068 |
$penalty = false; |
|
1069 |
$penaltybw = 0; |
|
1070 |
} |
|
1071 |
if ($config['ezshaper']['step5']['enable']) { |
|
1072 |
$p2p = true; |
|
1073 |
if ($config['ezshaper']['step5']['p2pcatchall']) { |
|
1074 |
$p2pcatchall = true; |
|
1075 |
$p2pcatchbw = $config['ezshaper']['step5']['bandwidth']; |
|
1076 |
$p2pcatchbwunit = $config['ezshaper']['step5']['bandwidthunit']; |
|
1077 |
if ($p2pcatchbwunit == "%") |
|
1078 |
$factor = $downbw/100; |
|
1079 |
else |
|
1080 |
$factor = wizard_get_bandwidthtype_scale($p2pcatchbwunit); |
|
1081 |
$remainbw += floatval($p2pcatchbw) * $factor; |
|
1082 |
} else { |
|
1083 |
$p2pcatchall = false; |
|
1084 |
$p2pcatchbw = 0; |
|
1085 |
} |
|
1086 |
} else { |
|
1087 |
$p2p = false; |
|
1088 |
$p2pcatchall = false; |
|
1089 |
$p2pcatchbw = 0; |
|
1090 |
} |
|
1091 |
if ($config['ezshaper']['step6']['enable']) { |
|
1092 |
$games = true; |
|
1093 |
} else { |
|
1094 |
$games = false; |
|
1095 |
} |
|
1096 |
|
|
1097 |
if ($config['ezshaper']['step7']['enable']) { |
|
1098 |
$otherpriority = true; |
|
1099 |
} else { |
|
1100 |
$otherpriority = false; |
|
1101 |
} |
|
1102 |
$remainbw = round($remainbw / $downbw * 100, 2); |
|
1103 |
if (intval($remainbw) > 0 && intval($remainbw) > 40) { |
|
1104 |
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue."); |
|
1105 |
header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$savemsg}"); |
|
1106 |
exit; |
|
1107 |
} else { |
|
1108 |
$remainbw = 100 - $remainbw; |
|
1109 |
} |
|
1110 |
|
|
1111 |
if ($sched != "PRIQ") { |
|
1112 |
if ($sched == "CBQ") |
|
1113 |
$q =& new cbq_queue(); |
|
1114 |
else if ($sched == "HFSC") |
|
1115 |
$q =& new hfsc_queue(); |
|
1116 |
$tmpcf = array(); |
|
1117 |
$tmpcf['name'] = "qInternet"; |
|
1118 |
//$tmpcf['priority'] = 6; |
|
1119 |
$tmpcf['ecn'] = "on"; |
|
1120 |
$tmpcf['enabled'] = "on"; |
|
1121 |
If ($sched == "CBQ") { |
|
1122 |
$tmpcf['bandwidth'] = floatval($config['ezshaper']['step2']["conn{$i}download"]); |
|
1123 |
$tmpcf['bandwidthtype'] = $config['ezshaper']['step2']["conn{$i}downloadspeed"]; |
|
1124 |
} |
|
1125 |
else if ($sched == "HFSC") { |
|
1126 |
$tmpcf['upperlimit'] = "on"; |
|
1127 |
$tmpcf['upperlimit3'] = floatval($config['ezshaper']['step2']["conn{$i}download"]) . $config['ezshaper']['step2']["conn{$i}downloadspeed"]; |
|
1128 |
$tmpcf['linkshare'] = "on"; |
|
1129 |
$tmpcf['linkshare3'] = floatval($config['ezshaper']['step2']["conn{$i}download"]) . $config['ezshaper']['step2']["conn{$i}downloadspeed"]; |
|
1130 |
$tmpcf['bandwidth'] = floatval($config['ezshaper']['step2']["conn{$i}download"]); |
|
1131 |
$tmpcf['bandwidthtype'] = $config['ezshaper']['step2']["conn{$i}downloadspeed"]; |
|
1132 |
} |
|
1133 |
array_push($tmppath, "qInternet"); |
|
1134 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1135 |
//array_pop($tmppath); |
|
1136 |
//echo "qInternet <br />"; |
|
1137 |
//var_dump($input_errors); |
|
1138 |
$qtmp->wconfig(); |
|
1139 |
$altq =& $qtmp; |
|
1140 |
} |
|
1141 |
|
|
1142 |
if ($sched == "PRIQ") |
|
1143 |
$q =& new priq_queue(); |
|
1144 |
else if ($sched == "CBQ") |
|
1145 |
$q =& new cbq_queue(); |
|
1146 |
else if ($sched == "HFSC") |
|
1147 |
$q =& new hfsc_queue(); |
|
1148 |
$tmpcf = array(); |
|
1149 |
$tmpcf['name'] = "qACK"; |
|
1150 |
$tmpcf['priority'] = 6; |
|
1151 |
$tmpcf['ecn'] = "on"; |
|
1152 |
$tmpcf['enabled'] = "on"; |
|
1153 |
If ($sched == "CBQ") { |
|
1154 |
$tmpcf['borrow'] = "on"; |
|
1155 |
$tmpcf['bandwidth'] = $remainbw * 0.2; |
|
1156 |
$tmpcf['bandwidthtype'] = "%"; |
|
1157 |
} |
|
1158 |
else if ($sched == "HFSC") { |
|
1159 |
$lkbw = 0.20 * $remainbw; |
|
1160 |
$tmpcf['linkshare3'] = "{$lkbw}%"; |
|
1161 |
$tmpcf['linkshare'] = "on"; |
|
1162 |
$tmpcf['bandwidth'] = $lkbw; |
|
1163 |
$tmpcf['bandwidthtype'] = "%"; |
|
1164 |
} |
|
1165 |
array_push($tmppath, "qACK"); |
|
1166 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1167 |
array_pop($tmppath); |
|
1168 |
//echo "qACK $remainbw <br />"; |
|
1169 |
//var_dump($input_errors); |
|
1170 |
$qtmp->wconfig(); |
|
1171 |
|
|
1172 |
if ($sched == "PRIQ") |
|
1173 |
$q =& new priq_queue(); |
|
1174 |
else if ($sched == "CBQ") |
|
1175 |
$q =& new cbq_queue(); |
|
1176 |
else if ($sched == "HFSC") |
|
1177 |
$q =& new hfsc_queue(); |
|
1178 |
$tmpcf = array(); |
|
1179 |
if ($p2pcatchall) |
|
1180 |
$tmpcf['name'] = "qOthersDefault"; |
|
1181 |
else |
|
1182 |
$tmpcf['name'] = "qDefault"; |
|
1183 |
$tmpcf['priority'] = 3; |
|
1184 |
$tmpcf['enabled'] = "on"; |
|
1185 |
if (!$p2pcatchall) |
|
1186 |
$tmpcf['default'] = "on"; |
|
1187 |
$tmpcf['ecn'] = "on"; |
|
1188 |
if ($sched == "CBQ") { |
|
1189 |
$tmpcf['borrow'] = "on"; |
|
1190 |
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */ |
|
1191 |
$tmpcf['bandwidthtype'] = "%"; |
|
1192 |
} else if ($sched == "HFSC") { |
|
1193 |
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */ |
|
1194 |
$tmpcf['bandwidthtype'] = "%"; |
|
1195 |
} |
|
1196 |
array_push($tmppath, $tmpcf['name']); |
|
1197 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1198 |
array_pop($tmppath); |
|
1199 |
//echo "qDefault <br />"; |
|
1200 |
//var_dump($input_errors); |
|
1201 |
$qtmp->wconfig(); |
|
1202 |
|
|
1203 |
if ($p2p) { |
|
1204 |
if ($sched == "PRIQ") |
|
1205 |
$q =& new priq_queue(); |
|
1206 |
else if ($sched == "CBQ") |
|
1207 |
$q =& new cbq_queue(); |
|
1208 |
else if ($sched == "HFSC") |
|
1209 |
$q =& new hfsc_queue(); |
|
1210 |
$tmpcf = array(); |
|
1211 |
$tmpcf['name'] = "qP2P"; |
|
1212 |
$tmpcf['priority'] = 1; |
|
1213 |
$tmpcf['ecn'] = "on"; |
|
1214 |
$tmpcf['enabled'] = "on"; |
|
1215 |
if ($p2pcatchall) { |
|
1216 |
if ($sched == "CBQ") { |
|
1217 |
$tmpcf['borrow'] = "on"; |
|
1218 |
$tmpcf['bandwidth'] = $p2pcatchbw; |
|
1219 |
$tmpcf['bandwidthtype'] = $p2pcatchbwunit; |
|
1220 |
} else if ($sched == "HFSC") { |
|
1221 |
$tmpcf['linkshare'] = "on"; |
|
1222 |
$tmpcf['linkshare3'] = "{$p2pcatchbw}{$p2pcatchbwunit}"; |
|
1223 |
$tmpcf['upperlimit'] = "on"; |
|
1224 |
$tmpcf['upperlimit3'] = "{$p2pcatchbw}{$p2pcatchbwunit}"; |
|
1225 |
$tmpcf['bandwidth'] = $p2pcatchbw; |
|
1226 |
$tmpcf['bandwidthtype'] = $p2pcatchbwunit; |
|
1227 |
} |
|
1228 |
$tmpcf['default'] = "on"; |
|
1229 |
|
|
1230 |
} else { |
|
1231 |
if ($sched == "CBQ") { |
|
1232 |
$tmpcf['borrow'] = "on"; |
|
1233 |
$tmpcf['bandwidth'] = $remainbw * 0.05; /* 5% bandwidth */ |
|
1234 |
$tmpcf['bandwidthtype'] = "%"; |
|
1235 |
} else if ($sched == "HFSC") { |
|
1236 |
$tmpbw = $remainbw * 0.05; /* 5% bandwidth */ |
|
1237 |
$tmpcf['linkshare'] = "on"; |
|
1238 |
$tmpcf['linkshare3'] = "{$tmpbw}%"; |
|
1239 |
$tmpcf['upperlimit'] = "on"; |
|
1240 |
$tmpcf['upperlimit3'] = "{$tmpbw}%"; |
|
1241 |
$tmpcf['bandwidth'] = $tmpbw; |
|
1242 |
$tmpcf['bandwidthtype'] = "%"; |
|
1243 |
} |
|
1244 |
} |
|
1245 |
array_push($tmppath, "qP2P"); |
|
1246 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1247 |
array_pop($tmppath); |
|
1248 |
//echo "qP2P <br />"; |
|
1249 |
//var_dump($input_errors); |
|
1250 |
$qtmp->wconfig(); |
|
1251 |
} |
|
1252 |
|
|
1253 |
if ($voip) { |
|
1254 |
if ($sched == "PRIQ") |
|
1255 |
$q =& new priq_queue(); |
|
1256 |
else if ($sched == "CBQ") |
|
1257 |
$q =& new cbq_queue(); |
|
1258 |
else if ($sched == "HFSC") |
|
1259 |
$q =& new hfsc_queue(); |
|
1260 |
$tmpcf = array(); |
|
1261 |
$tmpcf['name'] = "qVoIP"; |
|
1262 |
$tmpcf['priority'] = 7; |
|
1263 |
$tmpcf['ecn'] = "on"; |
|
1264 |
$tmpcf['enabled'] = "on"; |
|
1265 |
if ($sched == "CBQ") { |
|
1266 |
$tmpcf['borrow'] = "on"; |
|
1267 |
if ($voipbw > 0) { |
|
1268 |
$tmpcf['bandwidth'] = $voipbw; |
|
1269 |
$tmpcf['bandwidthtype'] = $voipbwunit; |
|
1270 |
} else { |
|
1271 |
$tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */ |
|
1272 |
$tmpcf['bandwidthtype'] = "%"; |
|
1273 |
} |
|
1274 |
} else if ($sched == "HFSC") { |
|
1275 |
if ($voipbw > 0) { |
|
1276 |
$tmpcf['realtime3'] = "{$voipbw}{$voipbwunit}"; |
|
1277 |
} else { |
|
1278 |
$voipbw = $remainbw * 0.20; /* 20% bandwidth */ |
|
1279 |
$tmpcf['realtime3'] = "{$voipbw}%"; |
|
1280 |
} |
|
1281 |
$tmpcf['realtime'] = "on"; |
|
1282 |
$tmpcf['bandwidth'] = 32; |
|
1283 |
$tmpcf['bandwidthtype'] = "Kb"; |
|
1284 |
} |
|
1285 |
array_push($tmppath, "qVoIP"); |
|
1286 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1287 |
array_pop($tmppath); |
|
1288 |
//echo "qVoIP <br />"; |
|
1289 |
//var_dump($input_errors); |
|
1290 |
$qtmp->wconfig(); |
|
1291 |
} |
|
1292 |
|
|
1293 |
if ($games) { |
|
1294 |
if ($sched == "PRIQ") |
|
1295 |
$q =& new priq_queue(); |
|
1296 |
else if ($sched == "CBQ") |
|
1297 |
$q =& new cbq_queue(); |
|
1298 |
else if ($sched == "HFSC") |
|
1299 |
$q =& new hfsc_queue(); |
|
1300 |
$tmpcf = array(); |
|
1301 |
$tmpcf['name'] = "qGames"; |
|
1302 |
$tmpcf['priority'] = 5; |
|
1303 |
$tmpcf['enabled'] = "on"; |
|
1304 |
$tmpcf['ecn'] = "on"; |
|
1305 |
if ($sched == "CBQ") { |
|
1306 |
$tmpcf['borrow'] = "on"; |
|
1307 |
$tmpcf['bandwidth'] = $remainbw * 0.2; /* 20% bandwidth */ |
|
1308 |
$tmpcf['bandwidthtype'] = "%"; |
|
1309 |
} else if ($sched == "HFSC") { |
|
1310 |
$gamesbw = $remainbw * 0.2; /* 20% bandwidth */ |
|
1311 |
$tmpcf['linkshare'] = "on"; |
|
1312 |
$tmpcf['linkshare3'] = "{$gamesbw}%"; |
|
1313 |
$tmpcf['bandwidth'] = "{$gamesbw}"; |
|
1314 |
$tmpcf['bandwidthtype'] = "%"; |
|
1315 |
} |
|
1316 |
array_push($tmppath, "qGames"); |
|
1317 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1318 |
array_pop($tmppath); |
|
1319 |
//echo "qGames <br />"; |
|
1320 |
//var_dump($input_errors); |
|
1321 |
$qtmp->wconfig(); |
|
1322 |
} |
|
1323 |
|
|
1324 |
if ($otherpriority) { |
|
1325 |
if ($sched == "PRIQ") |
|
1326 |
$q =& new priq_queue(); |
|
1327 |
else if ($sched == "CBQ") |
|
1328 |
$q =& new cbq_queue(); |
|
1329 |
else if ($sched == "HFSC") |
|
1330 |
$q =& new hfsc_queue(); |
|
1331 |
$tmpcf = array(); |
|
1332 |
$tmpcf['name'] = "qOthersHigh"; |
|
1333 |
$tmpcf['priority'] = 4; |
|
1334 |
$tmpcf['ecn'] = "on"; |
|
1335 |
$tmpcf['enabled'] = "on"; |
|
1336 |
if ($sched == "CBQ") { |
|
1337 |
$tmpcf['borrow'] = "on"; |
|
1338 |
$tmpcf['bandwidth'] = $remainbw * 0.1; /* 10% bandwidth */ |
|
1339 |
$tmpcf['bandwidthtype'] = "%"; |
|
1340 |
} else if ($sched == "HFSC") { |
|
1341 |
$tmpcf['linkshare'] = "on"; |
|
1342 |
$otherbw = $remainbw * 0.1; /* 10% bandwidth */ |
|
1343 |
$tmpcf['linkshare3'] = "{$otherbw}%"; |
|
1344 |
$tmpcf['bandwidth'] = $otherbw; |
|
1345 |
$tmpcf['bandwidthtype'] = "%"; |
|
1346 |
} |
|
1347 |
array_push($tmppath, "qOthersHigh"); |
|
1348 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1349 |
array_pop($tmppath); |
|
1350 |
//echo "qHigh <br />"; |
|
1351 |
//var_dump($input_errors); |
|
1352 |
$qtmp->wconfig(); |
|
1353 |
|
|
1354 |
|
|
1355 |
if ($sched == "PRIQ") |
|
1356 |
$q =& new priq_queue(); |
|
1357 |
else if ($sched == "CBQ") |
|
1358 |
$q =& new cbq_queue(); |
|
1359 |
else if ($sched == "HFSC") |
|
1360 |
$q =& new hfsc_queue(); |
|
1361 |
$tmpcf = array(); |
|
1362 |
$tmpcf['name'] = "qOthersLow"; |
|
1363 |
$tmpcf['priority'] = 2; |
|
1364 |
$tmpcf['ecn'] = "on"; |
|
1365 |
$tmpcf['enabled'] = "on"; |
|
1366 |
if ($sched == "CBQ") { |
|
1367 |
$tmpcf['borrow'] = "on"; |
|
1368 |
if ($penalty) { |
|
1369 |
$tmpcf['bandwidth'] = $penaltybw; |
|
1370 |
$tmpcf['bandwidthtype'] = $penaltybwunit; |
|
1371 |
} else { |
|
1372 |
$tmpcf['bandwidthtype'] = "%"; |
|
1373 |
$tmpcf['bandwidth'] = $remainbw * 0.05; /* 5% bandwidth */ |
|
1374 |
} |
|
1375 |
} else if ($sched == "HFSC") { |
|
1376 |
if ($penalty) { |
|
1377 |
$tmpcf['linkshare3'] = "{$penaltybw}{$penaltybwunit}"; |
|
1378 |
$tmpcf['bandwidth'] = $penaltybw; |
|
1379 |
$tmpcf['bandwidthtype'] = $penaltybwunit; |
|
1380 |
} else { |
|
1381 |
$lsbw = $remainbw * 0.05; |
|
1382 |
$tmpcf['linkshare3'] = "{$lsbw}%"; /* 5% bandwidth */ |
|
1383 |
$tmpcf['bandwidth'] = $lsbw; |
|
1384 |
$tmpcf['bandwidthtype'] = "%"; |
|
1385 |
} |
|
1386 |
$tmpcf['linkshare'] = "on"; |
|
1387 |
} |
|
1388 |
array_push($tmppath, "qOthersLow"); |
|
1389 |
$qtmp =& $altq->add_queue($q, &$tmpcf, &$tmppath, $input_errors); |
|
1390 |
array_pop($tmppath); |
|
1391 |
//echo "qLow <br />"; |
|
1392 |
//var_dump($input_errors); |
|
1393 |
$qtmp->wconfig(); |
|
1394 |
} |
|
1395 |
array_pop($tmppath); |
|
1013 | 1396 |
} |
1014 | 1397 |
|
1015 | 1398 |
|
Also available in: Unified diff
Revert "Ticket #749. Do not create the queues at LAN side for traffic_shaper_wizard_dedicated. Since we cannot control bandwidth its useless to try to handle it(ALTQ was built with this concept in mind)."
This reverts commit cd3346e205ad0f818977b7ccd0bd7259ed2f2e4e.