summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/flow_gen/bundle_maker.lua
blob: ca24d4bb2f9fa76416f2b9c496646ef4a9a42597 (plain)
1
2
3
4
5
6
7
8
9
10
11

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Litera
--
-- Copyright (c) 2010-2017 Intel Corporation
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

function get_client_bundles(bundles)
   local client_bundles = {};

   for i,b in ipairs(bundles) do
      client_bundles[i] = {bundle = b, imix_fraction = 1}
   end

   return client_bundles;
end

function get_server_streams(bundles)
   local server_streams = {}
   n_listen = 0
   for i, bundle in ipairs(bundles) do
      for j, stream in ipairs(bundle) do
	 n_listen = n_listen + 1
	 server_streams[n_listen] = stream
      end
   end
   return server_streams;
end

function setup_bundles(first_ip_byte, speed_scaling)
   bundles = dofile("cfg.lua")

   local client_bundles = get_client_bundles(bundles);
   local server_streams = get_server_streams(bundles);

   for i,e in ipairs(client_bundles) do
      for j,stream in ipairs(e.bundle) do
	 stream.clients.ip[1] = first_ip_byte
	 stream.clients.port_mask = 0xffff
      end
   end

   for i,stream in ipairs(server_streams) do
      stream.servers.ip[1] = first_ip_byte
   end

   local highest_bps = 0;
   for i,e in ipairs(client_bundles) do
      for j,s in ipairs(e.bundle) do
	 if (s.up_bps ~= 1250000000 and s.dn_bps ~= 1250000000) then
	    if (highest_bps < s.up_bps) then
	       highest_bps = s.up_bps
	    end
	    if (highest_bps < s.dn_bps) then
	       highest_bps = s.dn_bps
	    end
	 end
      end
   end

   if (highest_bps == 0) then
      highest_bps = 1250000000
   end
   max_ss = 1250000000/highest_bps

   if (max_ss_and_quit == not nil and max_ss_and_quit == true) then
      print("max ss=" .. max_ss .. "")
      os.exit(0);
   end

   if (speed_scaling > max_ss) then
      error("Scaling too high (maximum scaling is " .. max_ss .. ")")
   end

   for i,e in ipairs(client_bundles) do
      for j,s in ipairs(e.bundle) do
	 if (s.up_bps ~= 1250000000 and s.dn_bps ~= 1250000000) then
	    s.up_bps = s.up_bps * speed_scaling;
	    s.dn_bps = s.dn_bps * speed_scaling;
	 end
      end
   end

   return client_bundles, server_streams
end