Project

General

Profile

« Previous | Next » 

Revision dbf56eb4

Added by Matt Underscore about 7 years ago

- Fix an incorrect assumption where I thought the sysctls were measured in ms. they appear to be microseconds instead (thanks Harvy66)
- Fix a problem where I was recursively assigning parameters in FormatParameters(), but that was not an ideal method (using vsprintf instead)
- Fix scheduler configuration to better mirror pfSense forum's command syntax (configuring scheduler w/ pipe now with: 'sched 1 config pipe 1' instead of 'sched 1 config')

View differences:

src/etc/inc/shaper.inc
36 36
// update as needed when dummynet changes
37 37

  
38 38
// List of schedulers ('type' command on scheduler/pipe) that dummynet/ipfw is supposed to support
39
function getSchedulers() {
40
	return array(
41
		"fifo" => array(
42
			"name" => "FIFO",
43
			"parameter_format" => "type fifo",
44
			"description" => "First-in-First-out is a fundamental queueing discipline which ensures packet sequence.",
45
			"parameters" => array(),
46
			"ecn" => false
47
		),
48
		"qfq" => array(
49
			"name" => "Quick Fair Queueing",
50
			"parameter_format" => "type qfq",
51
			"description" => "QFQ is a fast, low-complexity Approximated Fair Queueing scheduler.",
52
			"parameters" => array(),
53
			"ecn" => false
54
		),
55
		"rr" => array(
56
			"name" => "Round Robin",
57
			"parameter_format" => "type rr",
58
			"description" => "Round Robin (RR) schedules packets in a round-robin fashion.",
59
			"parameters" => array(),
60
			"ecn" => false
61
		),
62
		"wf2q+" => array(
63
			"name" => "Worst-case Weighted fair Queueing",
64
			"parameter_format" => "type wf2q+",
65
			"description" => "Worst-case Weighted fair Queueing (WF2Q+) schedules flows with an associated weight.",
66
			"parameters" => array(),
67
			"ecn" => false
68
		),
69
		"prio" => array(
70
			"name" => "PRIO",
71
			"parameter_format" => "type prio",
72
			"description" => "PRIO schedules packets by their corresponding priority.",
73
			"parameters" => array(),
74
			"ecn" => false
75
		),
76
		"fq_codel" => array(
77
			"name" => "FQ_CODEL",
78
			"parameter_format" => "type fq_codel target %target interval %interval quantum %quantum limit %limit flows %flows",
79
			"description" => "CoDel is a novel \"no knobs\", \"just works\", \"handles variable bandwidth and RTT\", and simple AQM algorithm."
80
							. " As a scheduler, FQ_CODEL implements several flows (defined below), each having their own CoDel AQM.",
81
			"parameters" => array(
82
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.target")),
83
				"interval" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.interval")),
84
				"quantum" => array("name" => "quantum", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.quantum")),
85
				"limit" => array("name" => "limit", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.limit")),
86
				"flows" => array("name" => "flows", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.flows"))
87
			),
88
			"ecn" => true
89
		),
90
		"fq_pie" => array(
91
			"name" => "FQ_PIE",
92
			"parameter_format" => "type fq_pie target %target tupdate %tupdate alpha %alpha beta %beta max_burst %max_burst max_ecnth %max_ecnth",
93
			"description" => "Fair Queue Proportional Integral controller Enhanced AQM (FQ_PIE) is similar to FQ_CODEL but uses a slightly different algorithm.",
94
			"parameters" => array(
95
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.target")),
96
				"tupdate" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.tupdate")),
97
				"alpha" => array("name" => "alpha", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.alpha")),
98
				"beta" => array("name" => "beta", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.beta")),
99
				"max_burst" => array("name" => "max_burst", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_burst")),
100
				"max_ecnth" => array("name" => "max_ecnth", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_ecnth"))
101
			),
102
			"ecn" => true
103
		)
104
	);
105
}
106
// list of AQMs that dummynet supports
107
function getAQMs() {
108
	return array(
109
		"droptail" => array(
110
			"name" => "Tail Drop",
111
			"description" => "Tail Drop is a fundamental queue management algorithm which drops inbound packets once the queue is full.",
112
			"parameter_format" => "droptail",
113
			"parameters" => array(),
114
			"ecn" => false
115
		),
116
		"codel" => array(
117
			"name" => "CoDel",
118
			"description" => "CoDel is a novel \"no knobs\", \"just works\", \"handles variable bandwidth and RTT\", and simple AQM algorithm.",
119
			"parameter_format" => "codel target %target interval %interval",
120
			"parameters" => array(
121
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.codel.target")),
122
				"interval" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.codel.interval")),
123
			),
124
			"ecn" => true
125
		),
126
		"pie" => array(
127
			"name" => "PIE",
128
			"description" => "Proportional Integral controller Enhanced AQM (PIE) is similar to CoDel but uses a slightly different algorithm.",
129
			"parameter_format" => "pie target %target tupdate %tupdate alpha %alpha beta %beta max_burst %max_burst max_ecnth %max_ecnth",
130
			"parameters" => array(
131
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.target")),
132
				"tupdate" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.tupdate")),
133
				"alpha" => array("name" => "alpha", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.alpha")),
134
				"beta" => array("name" => "beta", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.beta")),
135
				"max_burst" => array("name" => "max_burst", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_burst")),
136
				"max_ecnth" => array("name" => "max_ecnth", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_ecnth"))
137
			),
138
			"ecn" => true
139
		),
140
		"red" => array(
141
			"name" => "Random Early Detection (RED)",
142
			"description" => "Random Early Detection (RED) drops packets based on probability, which increases as the queue increases in size.",
143
			"parameter_format" => "red %w_q/%min_th/%max_th/%max_p",
144
			"parameters" => array(
145
				"w_q" => array("name" => "w_q", "type" => "number", "default" => 1),
146
				"min_th" => array("name" => "min_th", "type" => "number", "default" => 0),
147
				"max_th" => array("name" => "max_th", "type" => "number", "default" => 1),
148
				"max_p" => array("name" => "max_p", "type" => "number", "default" => 1)
149
			),
150
			"ecn" => true
151
		),
152
		"gred" => array(
153
			"name" => "Gentle Random Early Detection (GRED)",
154
			"description" => "Gentle Random Early Detection (GRED) drops packets based on probability, which increases as the queue increases in size.",
155
			"parameter_format" => "gred %w_q/%min_th/%max_th/%max_p",
156
			"parameters" => array(
157
				"w_q" => array("name" => "w_q", "type" => "number", "default" => 1),
158
				"min_th" => array("name" => "min_th", "type" => "number", "default" => 0),
159
				"max_th" => array("name" => "max_th", "type" => "number", "default" => 1),
160
				"max_p" => array("name" => "max_p", "type" => "number", "default" => 1)
161
			),
162
			"ecn" => true
163
		)
164
	);
165
}
39
function getSchedulers() {
	return array(
		"fifo" => array(
			"name" => "FIFO",
			"parameter_format" => "type fifo",
			"description" => "First-in-First-out is a fundamental queueing discipline which ensures packet sequence.",
			"parameters" => array(),
			"ecn" => false
		),
		"qfq" => array(
			"name" => "Quick Fair Queueing",
			"parameter_format" => "type qfq",
			"description" => "QFQ is a fast, low-complexity Approximated Fair Queueing scheduler.",
			"parameters" => array(),
			"ecn" => false
		),
		"rr" => array(
			"name" => "Round Robin",
			"parameter_format" => "type rr",
			"description" => "Round Robin (RR) schedules packets in a round-robin fashion.",
			"parameters" => array(),
			"ecn" => false
		),
		"wf2q+" => array(
			"name" => "Worst-case Weighted fair Queueing",
			"parameter_format" => "type wf2q+",
			"description" => "Worst-case Weighted fair Queueing (WF2Q+) schedules flows with an associated weight.",
			"parameters" => array(),
			"ecn" => false
		),
		"prio" => array(
			"name" => "PRIO",
			"parameter_format" => "type prio",
			"description" => "PRIO schedules packets by their corresponding priority.",
			"parameters" => array(),
			"ecn" => false
		),
		"fq_codel" => array(
			"name" => "FQ_CODEL",
			"parameter_format" => "type fq_codel target %sms interval %sms quantum %s limit %limit flows %flows",
			"description" => "CoDel is a novel \"no knobs\", \"just works\", \"handles variable bandwidth and RTT\", and simple AQM algorithm."
							. " As a scheduler, FQ_CODEL implements several flows (defined below), each having their own CoDel AQM.",
			"parameters" => array(
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.target") / 1000),
				"interval" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.interval") / 1000),
				"quantum" => array("name" => "quantum", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.quantum")),
				"limit" => array("name" => "limit", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.limit")),
				"flows" => array("name" => "flows", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqcodel.flows"))
			),
			"ecn" => true
		),
		"fq_pie" => array(
			"name" => "FQ_PIE",
			"parameter_format" => "type fq_pie target %sms tupdate %sms alpha %s beta %s max_burst %s max_ecnth %s",
			"description" => "Fair Queue Proportional Integral controller Enhanced AQM (FQ_PIE) is similar to FQ_CODEL but uses a slightly different algorithm.",
			"parameters" => array(
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.target") / 1000),
				"tupdate" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.tupdate") / 1000),
				"alpha" => array("name" => "alpha", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.alpha")),
				"beta" => array("name" => "beta", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.beta")),
				"max_burst" => array("name" => "max_burst", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_burst")),
				"max_ecnth" => array("name" => "max_ecnth", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_ecnth"))
			),
			"ecn" => true
		)
	);
}
// list of AQMs that dummynet supports
function getAQMs() {
	return array(
		"droptail" => array(
			"name" => "Tail Drop",
			"description" => "Tail Drop is a fundamental queue management algorithm which drops inbound packets once the queue is full.",
			"parameter_format" => "droptail",
			"parameters" => array(),
			"ecn" => false
		),
		"codel" => array(
			"name" => "CoDel",
			"description" => "CoDel is a novel \"no knobs\", \"just works\", \"handles variable bandwidth and RTT\", and simple AQM algorithm.",
			"parameter_format" => "codel target %sms interval %sms",
			"parameters" => array(
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.codel.target") / 1000),
				"interval" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.codel.interval") / 1000),
			),
			"ecn" => true
		),
		"pie" => array(
			"name" => "PIE",
			"description" => "Proportional Integral controller Enhanced AQM (PIE) is similar to CoDel but uses a slightly different algorithm.",
			"parameter_format" => "pie target %sms tupdate %sms alpha %s beta %s max_burst %s max_ecnth %s",
			"parameters" => array(
				"target" => array("name" => "Target Delay (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.target") / 1000),
				"tupdate" => array("name" => "Interval (ms)", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.tupdate") / 1000),
				"alpha" => array("name" => "alpha", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.alpha")),
				"beta" => array("name" => "beta", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.beta")),
				"max_burst" => array("name" => "max_burst", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_burst")),
				"max_ecnth" => array("name" => "max_ecnth", "type" => "number", "default" => get_single_sysctl("net.inet.ip.dummynet.fqpie.max_ecnth"))
			),
			"ecn" => true
		),
		"red" => array(
			"name" => "Random Early Detection (RED)",
			"description" => "Random Early Detection (RED) drops packets based on probability, which increases as the queue increases in size.",
			"parameter_format" => "red %s/%s/%s/%s",
			"parameters" => array(
				"w_q" => array("name" => "w_q", "type" => "number", "default" => 1),
				"min_th" => array("name" => "min_th", "type" => "number", "default" => 0),
				"max_th" => array("name" => "max_th", "type" => "number", "default" => 1),
				"max_p" => array("name" => "max_p", "type" => "number", "default" => 1)
			),
			"ecn" => true
		),
		"gred" => array(
			"name" => "Gentle Random Early Detection (GRED)",
			"description" => "Gentle Random Early Detection (GRED) drops packets based on probability, which increases as the queue increases in size.",
			"parameter_format" => "gred %s/%s/%s/%s",
			"parameters" => array(
				"w_q" => array("name" => "w_q", "type" => "number", "default" => 1),
				"min_th" => array("name" => "min_th", "type" => "number", "default" => 0),
				"max_th" => array("name" => "max_th", "type" => "number", "default" => 1),
				"max_p" => array("name" => "max_p", "type" => "number", "default" => 1)
			),
			"ecn" => true
		)
	);
}
166 40
// used to map above
167 41
function array_map_assoc(callable $f, array $a) {
168 42
	return array_column(array_map($f, array_keys($a), $a), 1, 0);
......
220 94

  
221 95
	return($form);
222 96
}
223
function FormatParameters($format_string, $params) {
224
	foreach ($params as $key => $value) {
225
		$format_string = str_replace('%' . $key, gettext($value), $format_string);
226
	}
227
	
228
	return $format_string;
229
}
97
function FormatParameters($format_string, $params) {
	return vsprintf($format_string, $params);
}
230 98
/* End limiter patch */
231 99

  
232 100
function get_queue_stats() {
......
4036 3904
		}
4037 3905
		$selectedScheduler = getSchedulers()[$this->getScheduler()];
4038 3906
		if ($selectedScheduler) {
4039
			$pfq_rule .= "\nsched ". $this->GetNumber() . " config " . FormatParameters($selectedScheduler["parameter_format"], $this->scheduler_params);
3907
			$pfq_rule .= "\nsched ". $this->GetNumber() . " config pipe " . $this->GetNumber() . " " . FormatParameters($selectedScheduler["parameter_format"], $this->scheduler_params);
4040 3908
			if ($selectedScheduler["ecn"]) {
4041 3909
				if ($this->getECN() == 'on') {
4042 3910
					$pfq_rule .= ' ecn';

Also available in: Unified diff