Calculating the required bandwidth for ACK queues for asymetric link
-
Well, R represents the ratio of amounts of service that should be allocated to all other traffics and ACK traffic in the same duration (say, 1s).
Whether it is ratio of packet sizes (as shown in equations (1) and (2)) is not important. The point is the bandwidth 10% set by the Traffic Shaper Wizard, which corresponds to R = 9. I believed it is a good choice in the case of symmetric link, and tried to use it as a known parameter in the general case. ;)
-
Well, R represents the ratio of amounts of service that should be allocated to all other traffics and ACK traffic in the same duration (say, 1s).
Whether it is ratio of packet sizes (as shown in equations (1) and (2)) is not important. The point is the bandwidth 10% set by the Traffic Shaper Wizard, which corresponds to R = 9. I believed it is a good choice in the case of symmetric link, and tried to use it as a known parameter in the general case. ;)
Ahh, see the 10% value is just a value chosen almost purely at random. It works…I agree, it may not be optimal, but it's a value that seems to work for now. If you can come up with a better method, by all means, I'm listening. HFSC is enough of a black art that I certainly don't claim to fully understand it.
--Bill
-
Based on statistical data found via Google (confirmed by pftop on my own network traffic) I've re-calculated the maximum bandwidth of qWANack and qLANack. (I'm totally unfamiliar with traffic engineering and the likes, so please correct me if I'm wrong.) As shown below, the calculation supports our feeling that 10% is good in case of symmetric link, and shows that my figures in post #1 for asymmetric links were too aggressive.
For the purpose of calculation we assume a simple model, with qWANroot consisting of only qWANack and qWANdef, and qLANroot consisting of only qLANack and qLANdef. Thus outgoing and incomming packets other than ACKs are all queued in qWANdef and qLANdef, respectively.
A, B, X, Y are defined as above. Let C = bandwidth(qWANdef), D = bandwith(qLANdef). Thus A = C+X and B = D+Y. In post #1, calculation was based on the system of equations X/D = Y/C = 1/9, which was too simplified:
-
It characterizes some "imaginary" or "average" traffic, not uploading, downloading, web surf nor any other real-life traffic.
-
It establishes some relation between the amount of data in certain direction and ACKnowledges in the opposite direction, but not yet the relation between the amount of incomming and outgoing data.
Now we fix both the problems by assuming every (type of) traffic be characterized by a pattern, which is a 4-dimensional vector (c,d,x,y), where c, d, x, y is the amount of data passing through qWANdef, qLANdef, qWANack, qLANack, respectively, in the same duration (say, 1s), of that particular traffic.
For example, the traffic pattern for Web surfing is (0.11, 1, 0.075, 0.075), saying that in order to receive 1 kb of useful Web data, 0.11 kb must be transmitted, furthermore 0.075 kb of ACKs must be transmitted and other 0.075 kb of ACKs must be received in 1s.
The actual activity of i-th traffic is then obtained simply by multiplying that vector with a non-negative variable. For example, v*(0.11, 1, 0.075, 0.075) shows how much bandwidth are required for each queue in order to surf Web at v kb/s.
The (new) calculation is based on six types of traffic, corresponding to variables v0 through v5:
v0 * (1, 0.40, 0.01, 0.04) is p2p upload activity
v1 * (0.04, 1, 0.04, 0.01) is p2p download activity
v2 * (1, 0.1, 0.015, 0.05) is other bulk upload activity
v3 * (0.1, 1, 0.05, 0.15) is other bulk download activity
v4 * (1, 0.11, 0.075, 0.075) is web server activity
v5 * (0.11, 1, 0.075, 0.075) is web surf activityand constrained by:
sum(v_i * a_i) <= A
sum(v_i * b_i) <= Bwhere a_i = c_i + x_i and b_i = d_i + y_i and i running in 0,…,5.
Two further constraints are made, limiting p2p upload and download at 80% of uplink and downlink bandwidth, respectively:
v_0 * c_0 <= A * 0.8
v_1 * d_1 <= B * 0.8We are now ready to estimate X and Y, the required bandwidth of qWANack and qLANack, in a worst-case fashion:
X = max(sum(v_i * x_i))
Y = max(sum(v_i * y_i))One can find the max's using any linear programming solver. I used M$ Excel :-).
Examples
Recall that K = B/A. If (say) A=128 kb/s and B=1024 kb/s, then K=8.
Ex 1. For K=1, namely A=1, B=1 [mb/s], X/A = Y/B = 11.90% at (v4 = v5 = 0.794, others v_i = 0, here and below, unshown v_i are zeros), both links saturated.
Ex 2. For K=2, namely A=1, B=2 [mb/s], X/A = 17.86% and Y/B = 8.93% at (v4 = 0.629, v5 = 1.752), both links saturated.
Ex 3. For K=4, namely A=1, B=4 [mb/s], X/A = 29.76% and Y/B = 7.44% at (v4 = 0.299 ; v5 = 3.67), both links saturated.
Ex 4. For K=8, namely A=1, B=8 [mb/s], maximums of sum(v_ix_i) and sum(v_iy_i) are not reached at the same time:
X/A = 43.58% while sum(v_iy_i) = 3.94% at (v1 = 4.016 ; v5 = 3.669), both links saturated.
Y/B = 5.07% while sum(v_ix_i) = 40.54% at (v5 = 5.405), uplink is saturated (at A100%), while downlink is loaded at B72.64%.Notes
The traffic patterns (c_i, d_i, x_i, y_i) used here are illustrative. Nevertheless, the examples of calculation suggest that 10% would suffice in the case of symmetric and nearly-symmetric link, and in the case of very asymmetric link, one might consider setting some larger bandwidth for qWANack (although not too large as suggested in my post#1 above).
Game and VoIP clients do not figure here, as they typically use UDP which – I think -- does not use ACK queues. In a network with game and VoIP continuously backlogged, then ACK queues require -- in percentage -- yet lower bandwidth.
This is a worst-case analysis. But it is possible to estimate the bandwidths more closely to the average case by further constraining with upper limits that shouldn't be much higher than the desired linkshare.
-
-
Maybe you can try to verify your formulas with these " shot in the dark unscientific" testing on ACK queues and an asymetric 16000kbit/s down 800 kbit/s up line:
When I used 10% acks up and down I was not able to get more than about 8 mbit down when up was saturated.
I changed the qwan acks (were showing drops with the 10% setting) to 40% and my downloads raised to 12 mbit with saturated upload.
I changed qwan acks to 60% and my downloads went up and down between 13 and 15 mbit/s with saturated upload.
Link was saturated by running multiple bittorrents, 3 ftp downloads, 2 http downloads and listening to an internetstream (about 1300 states)
Some more observations:
When only running few downloads it needs about 400 kbit/s ack only traffic to download with 16 mbit/s
Pings with no load are about 7 ms on my line, with full upload I have about 10-20 ms, with full up and down and 60% ack setting (only qwan acks btw) they are between 30 and 110 ms (with even some lost pings judging from the rrd's).
-
Thank you for your data.
Based on the "400 kbit/s ack only traffic to download with 16 mbit/s", I added another pattern, "FTP client", which is (epsilon, 1, 0.025, epsilon/5), where epsilon is somewhat arbitrarily chosen (I let it be 2.5E-4).
I've tried using them as a next example of calculation:
K=20. A=0.8, B=16 [mb/s].
"p2p upload" and "p2p download" are constrained by an upper limit of 10%.
"other bulk upload" and "other bulk download" are constrained by an upper limit of 20%.
"web server" and "web surf" are excluded (i.e. upper limited by 0).Let v7 be the "activity" variable for FTP client (unconstrained).
Given that, WAN acks reached its maximum = 60,59% (while LAN acks reached 0.34% which isn't its maximum) at (v1 = 1.6; v3=2.483; v7=11.863), both links saturated.
As noted, my traffic patterns are only illustrative ("bulk download" and "bulk download" was based on audio streaming), to be accurate one would collect his/her own FTP download traffic patterns, say, from the values shown by pftop in its "Queues" screen in "P/S" (packets/second) and "B/S" (bytes/second) columns for qWANack, qLANack, qWANothers, qLANothers, qFTPup, qFTPdown when running (almost) solely FTP at full load.
Where qWANothers (qLANothers) is the sum of all uplink (downlink) queues except qWANack (qLANack), qFTPup and qFTPdown are the queues containing FTP traffic.
-
If you want to calculate a trafficshapingsetup for my connection and give me advice how to configure it or even sending me the trafficshaperpart of the config.xml (you can backup only this part from your pfSense) I can test it for you and report back how well these settings work. If we get some good results we can start integrating your formulars into the wizard ;D
-
As you can see, even with not-so-cool traffic patterns, my first attempt for an open formula (post#1) fails. For now, I can only offer closed formulas which must be solved by linear programming solvers.
Linear programming based on traffic patterns cannot answer the "What should I do" question, so it cannot recommend any optimal traffic shaping setup. It can only answer the "What if" questions. For example:
-
What maximum % qWANack would reach if I run p2p limited by 80% bandwidth, surf Web and check email at most 50% bandwidth and download FTP unlimited?
-
Isn't that maximum too overestimated if I want to exploit my downlink at 90%?
Note that if we want to predict the behavior with respect to linkshare setup, we must constrain not only the variables v_i but also ratios between some of them. Then the problem goes beyond the scope of linear programming. However, one can still analyze it with the same "traffic pattern" approach, using a non-linear solver (MS Excel, for example).
Can we still develop an (empirical) open formula? Yes we can, but much works must be done before any second attempt:
1. Collect more realistic traffic patterns.
2. Select several of them as representatives.
3. Analyze and estimate the maximum bandwidth of qWANack (maybe qLANack too) for K=2, 4, 8, 16, 20, 24 and 32 (if any).
4. Let people try them out. Listen to feedback.
If no problems are reported, build the formula and (if it's desired,) integrate it to the wizard.
–--------------------
Hoba,Pls, PM me your email address and I'll send you my spreadsheet. (You'll need MS Windows and Excel.)
-
-
What about a userland daemon that watches traffic and dynamically alters the HFSC profile as traffic patterns change?
Please send me a copy of your spreadsheet as well (sullrich@gmail.com).
Thanks!
-
Adaptive traffic shaping? Would be great. There is a software named QoSbox that change linkshare dynamically. Maybe you'll find it helpful. For more details, refer to http://www.cs.virginia.edu/~mngroup/projects/qosbox/docs.html.
In the context of ACK queues in HFSC, however, I think it's not so hot topic. Because it's almost surely harmless assigning some large value (say, 60%) to qWANack linkshare or realtime curve's m1. If that bandwidth is needed, it's used. Otherwise it is allocated to other traffics.
Just my opinion.
–----
to hoba, sullrich: spreadsheet sent. -
Sounds great. You seem to know a lot more about HFSC than we do. Want to adopt our code? :)
-
Attaching the spreadsheet mentioned prior in this thread.
-
the outcome of this topic sounds really interesting and potentially very useful :)
best of luck -
Hi, please help me! How much set LAN ack and WAN ack (into percent) for DSL line Upload 512Kbps and Download 8192Kbps. (asymetric line).
Very thanks!!! -
Hi, please help me! How much set LAN ack and WAN ack (into percent) for DSL line Upload 512Kbps and Download 8192Kbps. (asymetric line).
Very thanks!!!Download the excel document and plug your values in.
-
where find cell for LAN ans WAN ack? I am not uderstand this sheet :-(
Thanks!
-
A (UP)
B (DOWN) -
Then
- click Tools/Solver…
- click Set Target Cell, click R15C12 (or R16C12), click Max, click Solve
- click Keep Solver Solution, click OK
The required X [kb/s or mb/s] is shown in R15C12. The required X/A [%] is shown in R16C12.
-
dusan can you please explain the rationale behind this in a formal way.
I want to integrate this in the shaper wizard and the excel is not easily readble/understandable.
Thanks in advance.
-
Well here's an explaination which – I hope -- is more detailed and formal.
All symbols are defined as before but we rather sumarize them here:
A = bandwidth of qWANroot
B = bandwidth of qLANroot
C = bandwidth of qWANdef
D = bandwidth of qLANdef
X = bandwidth of qWANack
Y = bandwidth of qLANackIn this model, we make use of no other queues:
A = C + X
B = D + Y(To be exact, we know A, B and don't know C, D, X, Y. The analysis shows how much qWANack and qLANack could be actually utilized assuming they may be as large as needed, i.e. unbounded by anything else than A and B, respectively, that's what would be taken as the required value for X and Y and the rest of A and B would simply become C and D, respectively.)
Consider a single, i-th, traffic. The traffic varies in time, and utilizes four queues qWANdef, qLANdef, qWANack and qLANack at the same time. However, assuming that for the traffic, the four queue utilization "amounts" are directly related (rather than independent) by some constant coefficients (c_i,d_i,x_i,y_i), we represent the traffic "activity" as a single variable (v_i) rather than four. For example, for i=5 (Web surf traffic), the queue utilization "amounts" are assumed to be (v5c5, v5d5, v5x5, v5y5) at every time. The vector (c5, d5, x5, y5) = (0.135, 1, 0.0375, 0.0125), which is assumed constant for every network with any ratio of asymmetricity, is called Web surf traffic pattern.
(The assumption is supported by experimental observation. At time t in network N, it was observed that the qWANdef, qLANdef, qWANack, qLANack utilization "amounts" are
0.135, 1, 0.0375, 0.0125 [kb/s], respectively
and at time t' in network N', it was observed that the four queue utilization "amounts" are
135, 1000, 37.5, 12.5 [kb/s], respectively.
The experiments were made under Web surf traffic solely and no others involved, of course.)
The spreadsheed makes use of 8 traffic patterns, indexed by 0 through 7.
For every i in 0…7, let
a_i = c_i + x_i
b_i = d_i + y_iAt every time, the qWANdef utilization is
v0 * c0 + ... + v7 * c7
the qWANack utilization is
v0 * x0 + ... + v7 * x7
the qWANroot (ie. uplink) utilization is the sum of the two above:
(v0 * c0 + ... + v7 * c7) + (v0 * x0 + ... + v7 * x7)
= (v0 * c0 + v0 * x0) + ... + (v7 * c7 + v7 * x7)
= v0 * (c0 + x0) + ... + v7 * (c7 + x7)
= v0 * a0 + ... + v7 * a7the qLANdef utilization is
v0 * d0 + ... + v7 * d7
the qLANack utilization is
v0 * y0 + ... + v7 * y7
the qLANroot (ie. downlink) utilization is the sum of the two above:
(v0 * d0 + ... + v7 * d7) + (v0 * y0 + ... + v7 * y7)
= (v0 * d0 + v0 * y0) + ... + (v7 * d7 + v7 * y7)
= v0 * (d0 + y0) + ... + v7 * (d7 + y7)
= v0 * b0 + ... + v7 * b7Now we can construct a system of inequations, each represents a constraint, of 8 unknowns v_0 through v_7.
Uplink utilization must not exceed uplink bandwidth:
(C1) v0 * a0 + ... + v7 * a7 <= A
Downlink utilization must not exceed downlink bandwidth:
(C2) v0 * b0 + ... + v7 * b7 <= B
All network traffic must be non-negative:
(C3) v_i >= 0
Additional constraints may be made. For example, if we know that p2p uploading are upper-limited by 80% uplink bandwidth then we may add the constraint:
(C4) v0 * c0 <= A * 0.8
Similarly, if we know that p2p downloading are upper-limited by 80% downlink bandwidth then we may add the constraint:
(C5) v1 * d1 <= B * 0.8
The bounds like A and B are to be filled as values in row 3 of the Excel spreadsheet. The bounds like A0.8 and B0.8 are pre-filled as formulars in columns 8 and 9 of the sheet.
The MS Excel Solver find a solution of (C1)-(C5) that maximize a user-selected target cell. Note that we are concerned of queues' utilization implied from the solution, not the solution itself. Of particular interest may be the utilization of qWANack, qLANack, uplink and downlink. The spreadsheet includes formulars for them. We can select one of them as the target and observe others as the implied consequence.
As I've said, the Excel is for the purpose of analysis. It's not suitable and not worth to integrate in the Wizard as such.
-
A = interface/tocken bucket bandwidth
c = observed from the samples.
x = observed from the samples.SO you are saying that the basic equation for a queue is:
A >= c*x (if we have a single queue under A).and it transforms to
A >= sum(c_i* x_i) (for i queues).
and each queue gets c_i + x_iIf that is right and one wants to write a daemon that start by the assumtion of the constants calculated/observed by your testings and smaples traffic to adjust the i queues accordingly how can one calculate the c_i/x_i to be used later on a new calculation.
Basically can you provide even the calculation for the variables so one can write such a daemon?!I hope to have understood your explanation. The rationale of integrating this with the wizard is to be coupled with such a daemon to make sense.
By the way thanks for your quick reply.