summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua
diff options
context:
space:
mode:
authorLuc Provoost <luc.provoost@intel.com>2020-05-28 12:57:46 +0200
committerLuc Provoost <luc.provoost@intel.com>2020-05-28 12:57:46 +0200
commitb3c5a6a20926dc9fca32240b89f3dea09d07aa02 (patch)
tree6753e77e0dd1445d9a55181b282077566a124453 /VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua
parent8f21fb5ed8231125bca3cec1329d9fd739f14684 (diff)
IPV6 testing & minor changes and fixes
IPV6 test has been added. The generator will now generate IPV6 packets using NDP to resolve MAC addresses. The hex IP addresses in the inline definition of the packets in the cfg files is now calculated by a lua function called in parameters.lua. The hard-coded path /home/centos has been replaced by ~. An error in the speed calculations has been fixed. See the RapidTest class for details. The actual number of generated flows is now reported. If the requested number of flows is not a power of 2, the lowest power of 2 that is larger than the requested number of flows will be used and reported. Change-Id: I36b8d345b4a03c2cf358c19ec353ca8ad2831293 Signed-off-by: Luc Provoost <luc.provoost@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua')
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua b/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua
new file mode 100644
index 00000000..d38bb808
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/helper.lua
@@ -0,0 +1,61 @@
+--
+-- Copyright (c) 2010-2020 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 convertIPToHex(ip)
+ local address_chunks = {}
+ if type(ip) ~= "string" then
+ print ("IP ADDRESS ERROR: ", ip)
+ return "IP ADDRESS ERROR"
+ end
+
+ local chunks = {ip:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$")}
+ if #chunks == 4 then
+ for i,v in ipairs(chunks) do
+ if tonumber(v) > 255 then
+ print ("IPV4 ADDRESS ERROR: ", ip)
+ return "IPV4 ADDRESS ERROR"
+ end
+ address_chunks[#address_chunks + 1] = string.format ("%02x", v)
+ end
+ result = table.concat(address_chunks, " ")
+ print ("Hex IPV4: ", result)
+ return result
+ end
+
+ delimiter = ":"
+ for match in (ip..delimiter):gmatch("(.-)"..delimiter) do
+ if match ~= "" then
+ number = tonumber(match, 16)
+ if number <= 65535 then
+ table.insert(address_chunks, string.format("%02x %02x",number/256,number % 256))
+ end
+ else
+ table.insert(address_chunks, "")
+ end
+ end
+ for i, chunk in ipairs(address_chunks) do
+ if chunk =="" then
+ table.remove(address_chunks, i)
+ for j = 1,(8-#address_chunks) do
+ table.insert(address_chunks, i, "00 00")
+ end
+ break
+ end
+ end
+ result = table.concat(address_chunks, " ")
+ print ("Hex IPV6: ", result)
+ return result
+end