2 -- Copyright (c) 2010-2017 Intel Corporation
4 -- Licensed under the Apache License, Version 2.0 (the "License");
5 -- you may not use this file except in compliance with the License.
6 -- You may obtain a copy of the License at
8 -- http://www.apache.org/licenses/LICENSE-2.0
10 -- Unless required by applicable law or agreed to in writing, software
11 -- distributed under the License is distributed on an "AS IS" BASIS,
12 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 -- See the License for the specific language governing permissions and
14 -- limitations under the License.
17 function get_client_bundles(bundles)
18 local client_bundles = {};
20 for i,b in ipairs(bundles) do
21 client_bundles[i] = {bundle = b, imix_fraction = 1}
24 return client_bundles;
27 function get_server_streams(bundles)
28 local server_streams = {}
30 for i, bundle in ipairs(bundles) do
31 for j, stream in ipairs(bundle) do
32 n_listen = n_listen + 1
33 server_streams[n_listen] = stream
36 return server_streams;
39 function setup_bundles(first_ip_byte, speed_scaling)
40 bundles = dofile("cfg.lua")
42 local client_bundles = get_client_bundles(bundles);
43 local server_streams = get_server_streams(bundles);
45 for i,e in ipairs(client_bundles) do
46 for j,stream in ipairs(e.bundle) do
47 stream.clients.ip[1] = first_ip_byte
48 stream.clients.port_mask = 0xffff
52 for i,stream in ipairs(server_streams) do
53 stream.servers.ip[1] = first_ip_byte
56 local highest_bps = 0;
57 for i,e in ipairs(client_bundles) do
58 for j,s in ipairs(e.bundle) do
59 if (s.up_bps ~= 1250000000 and s.dn_bps ~= 1250000000) then
60 if (highest_bps < s.up_bps) then
61 highest_bps = s.up_bps
63 if (highest_bps < s.dn_bps) then
64 highest_bps = s.dn_bps
70 if (highest_bps == 0) then
71 highest_bps = 1250000000
73 max_ss = 1250000000/highest_bps
75 if (max_ss_and_quit == not nil and max_ss_and_quit == true) then
76 print("max ss=" .. max_ss .. "")
80 if (speed_scaling > max_ss) then
81 error("Scaling too high (maximum scaling is " .. max_ss .. ")")
84 for i,e in ipairs(client_bundles) do
85 for j,s in ipairs(e.bundle) do
86 if (s.up_bps ~= 1250000000 and s.dn_bps ~= 1250000000) then
87 s.up_bps = s.up_bps * speed_scaling;
88 s.dn_bps = s.dn_bps * speed_scaling;
93 return client_bundles, server_streams