# Copyright 2015-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.

# ############################
# Traffic gen configuration
# ############################

# log file for all traffic generator related commands
LOG_FILE_TRAFFIC_GEN = 'traffic-gen.log'

# TRAFFIC dictionary defines traffic parameters used by all traffic generators.
# Detailed description of TRAFFIC dictionary items follows:
#
#    'traffic_type'  - One of the supported traffic types.
#                      E.g. rfc2544_throughput, rfc2544_back2back
#                      or rfc2544_continuous
#                      Data type: str
#                      Default value: "rfc2544_throughput".
#    'bidir'         - Specifies if generated traffic will be full-duplex (True)
#                      or half-duplex (False)
#                      Data type: str
#                      Supported values: "True", "False"
#                      Default value: "False".
#    'frame_rate'    - Defines desired percentage of frame rate used during
#                      continuous stream tests.
#                      Data type: int
#                      Default value: 100.
#    'multistream'   - Defines number of flows simulated by traffic generator.
#                      Value 0 disables multistream feature
#                      Data type: int
#                      Supported values: 0-65536 for 'L4' stream type
#                                        unlimited for 'L2' and 'L3' stream types
#                      Default value: 0.
#    'stream_type'   - Stream type is an extension of the "multistream" feature.
#                      If multistream is disabled, then stream type will be
#                      ignored. Stream type defines ISO OSI network layer used
#                      for simulation of multiple streams.
#                      Data type: str
#                      Supported values:
#                         "L2" - iteration of destination MAC address
#                         "L3" - iteration of destination IP address
#                         "L4" - iteration of destination port
#                                of selected transport protocol
#                      Default value: "L4".
#    'pre_installed_flows'
#                   -  Pre-installed flows is an extension of the "multistream"
#                      feature. If enabled, it will implicitly insert a flow
#                      for each stream. If multistream is disabled, then
#                      pre-installed flows will be ignored.
#                      Note: It is supported only for p2p deployment scenario.
#                      Data type: str
#                      Supported values:
#                         "Yes" - flows will be inserted into OVS
#                         "No"  - flows won't be inserted into OVS
#                      Default value: "No".
#    'flow_type'     - Defines flows complexity.
#                      Data type: str
#                      Supported values:
#                         "port" - flow is defined by ingress ports
#                         "IP"   - flow is defined by ingress ports
#                                  and src and dst IP addresses
#                      Default value: "port"
#    'l2'            - A dictionary with l2 network layer details. Supported
#                      values are:
#        'srcmac'    - Specifies source MAC address filled by traffic generator.
#                      NOTE: It can be modified by vsperf in some scenarios.
#                      Data type: str
#                      Default value: "00:00:00:00:00:00".
#        'dstmac'    - Specifies destination MAC address filled by traffic generator.
#                      NOTE: It can be modified by vsperf in some scenarios.
#                      Data type: str
#                      Default value: "00:00:00:00:00:00".
#        'framesize' - Specifies default frame size. This value should not be
#                      changed directly. It will be overridden during testcase
#                      execution by values specified by list TRAFFICGEN_PKT_SIZES.
#                      Data type: int
#                      Default value: 64
#    'l3'            - A dictionary with l3 network layer details. Supported
#                      values are:
#        'enabled'   - Specifies if l3 layer should be enabled or disabled.
#                      Data type: bool
#                      Default value: True
#                      NOTE: Supported only by IxNet trafficgen class
#        'srcip'     - Specifies source MAC address filled by traffic generator.
#                      NOTE: It can be modified by vsperf in some scenarios.
#                      Data type: str
#                      Default value: "1.1.1.1".
#        'dstip'     - Specifies destination MAC address filled by traffic generator.
#                      NOTE: It can be modified by vsperf in some scenarios.
#                      Data type: str
#                      Default value: "90.90.90.90".
#        'proto'     - Specifies deflaut protocol type.
#                      Please check particular traffic generator implementation
#                      for supported protocol types.
#                      Data type: str
#                      Default value: "udp".
#    'l4'            - A dictionary with l4 network layer details. Supported
#                      values are:
#        'enabled'   - Specifies if l4 layer should be enabled or disabled.
#                      Data type: bool
#                      Default value: True
#                      NOTE: Supported only by IxNet trafficgen class
#        'srcport'   - Specifies source port of selected transport protocol.
#                      NOTE: It can be modified by vsperf in some scenarios.
#                      Data type: int
#                      Default value: 3000
#        'dstport'   - Specifies destination port of selected transport protocol.
#                      NOTE: It can be modified by vsperf in some scenarios.
#                      Data type: int
#                      Default value: 3001
#    'vlan'          - A dictionary with vlan encapsulation details. Supported
#                      values are:
#        'enabled'   - Specifies if vlan encapsulation should be enabled or
#                      disabled.
#                      Data type: bool
#                      Default value: False
#        'id'        - Specifies vlan id.
#                      Data type: int (NOTE: must fit to 12 bits)
#                      Default value: 0
#        'priority'  - Specifies a vlan priority (PCP header field).
#                      Data type: int (NOTE: must fit to 3 bits)
#                      Default value: 0
#        'cfi'       - Specifies if frames can or cannot be dropped during
#                      congestion (DEI header field).
#                      Data type: int (NOTE: must fit to 1 bit)
#                      Default value: 0
TRAFFIC = {
    'traffic_type' : 'rfc2544_throughput',
    'frame_rate' : 100,
    'bidir' : 'True',  # will be passed as string in title format to tgen
    'multistream' : 0,
    'stream_type' : 'L4',
    'pre_installed_flows' : 'No',           # used by vswitch implementation
    'flow_type' : 'port',                   # used by vswitch implementation

    'l2': {
        'framesize': 64,
        'srcmac': '00:00:00:00:00:00',
        'dstmac': '00:00:00:00:00:00',
    },
    'l3': {
        'enabled': True,
        'proto': 'udp',
        'srcip': '1.1.1.1',
        'dstip': '90.90.90.90',
    },
    'l4': {
        'enabled': True,
        'srcport': 3000,
        'dstport': 3001,
    },
    'vlan': {
        'enabled': False,
        'id': 0,
        'priority': 0,
        'cfi': 0,
    },
}

#path to traffic generators directory.
TRAFFICGEN_DIR = os.path.join(ROOT_DIR, 'tools/pkt_gen')

# traffic generator to use in tests
#TRAFFICGEN = 'TestCenter'
TRAFFICGEN = 'Dummy'
#TRAFFICGEN = 'IxNet'
#TRAFFICGEN = 'Ixia'
#TRAFFICGEN = 'Xena'
#TRAFFICGEN = 'Moongen'

# List of packet sizes to send.
# Expand like this: (64, 128, 256, 512, 1024)
TRAFFICGEN_PKT_SIZES = (64,)

TRAFFICGEN_DURATION = 30

TRAFFICGEN_RFC2544_TESTS = 1
TRAFFICGEN_RFC2889_TRIALS = 1
TRAFFICGEN_LOSSRATE = 0.0

##############################
# DUMMY Configuration -- BEGIN

# By default, dummy traffic generator asks for "measured" values.
# Following dictionary allows to preconfigure these values and
# to avoid user interaction. It can be useful for automated
# integration tests.
# Example of values for continuous traffic type:
#   TRAFFICGEN_DUMMY_RESULTS{'frames rx': 500000,
#                            'frames tx': 500000,
#                            'rx rate %': 100,
#                            'tx rate %': 100,
#                            'frameloss %': 0,
#                            'min latency': 1,
#                            'max latency': 15,
#                            'avg latency': 2.5,
#                           }
#
TRAFFICGEN_DUMMY_RESULTS = {}

# DUMMY Configuration -- END
############################

#############################
# IXIA Configuration -- BEGIN

# path to 'ixos' install path
TRAFFICGEN_IXIA_ROOT_DIR = '/opt/ixos'

# network address of IXIA chassis
TRAFFICGEN_IXIA_HOST = ''

TRAFFICGEN_IXIA_CARD = ''

TRAFFICGEN_IXIA_PORT1 = ''

TRAFFICGEN_IXIA_PORT2 = ''

TRAFFICGEN_IXNET_LIB_PATH = '/opt/ixnetwork/lib/IxTclNetwork'

# IxNetwork host IP address
TRAFFICGEN_IXNET_MACHINE = ''
TRAFFICGEN_IXNET_PORT = ''
TRAFFICGEN_IXNET_USER = ''
TRAFFICGEN_IXNET_CHASSIS = ''

# The result directory on $TRAFFICGEN_IXNET_MACHINE
TRAFFICGEN_IXNET_TESTER_RESULT_DIR = ''

# The result directory on DUT. This needs to map to the same directory
# as the previous one
TRAFFICGEN_IXNET_DUT_RESULT_DIR = ''

# directory with 3rd party scripts generated by IXIA tools
TRAFFICGEN_IXIA_3RD_PARTY = os.path.join(ROOT_DIR, '3rd_party/ixia')

# default TCL script, which will be used for IXNETWORK configuration
TRAFFICGEN_IXNET_TCL_SCRIPT = 'ixnetrfc2544.tcl'

# IXIA Configuration -- END
###########################


###########################################
# Spirent TestCenter Configuration -- BEGIN

# Path to Python 2 executable
TRAFFICGEN_STC_PYTHON2_PATH = "/bin/python2.7"

# Path to the location of the TestCenter files
TRAFFICGEN_STC_TESTCENTER_PATH = os.path.join(ROOT_DIR, 'tools/pkt_gen/testcenter')

# Name of the TestCenter RFC2544 Tput helper python script
TRAFFICGEN_STC_RFC2544_TPUT_TEST_FILE_NAME = "testcenter-rfc2544-throughput.py"

# Name of the Testcenter RFC2899 Tput Helper Python Scripts
TRAFFICGEN_STC_RFC2889_TEST_FILE_NAME = "testcenter-rfc2889-rest.py"

# 2889 Port Locations
TRAFFICGEN_STC_RFC2889_LOCATION = ""

# The address of the Spirent Lab Server to use
TRAFFICGEN_STC_LAB_SERVER_ADDR = ""

# The address of the Spirent License Server in your environment
TRAFFICGEN_STC_LICENSE_SERVER_ADDR = ""

# The address of the TestCenter chassis that holds the east port
TRAFFICGEN_STC_EAST_CHASSIS_ADDR = ""

# The slot number of the card that holds the east port
TRAFFICGEN_STC_EAST_SLOT_NUM = ""

# The port number on the card that holds the east port
TRAFFICGEN_STC_EAST_PORT_NUM = ""

# The address of the TestCenter chassis that holds the west port
TRAFFICGEN_STC_WEST_CHASSIS_ADDR = ""

# The slot number of the card that holds the west port
TRAFFICGEN_STC_WEST_SLOT_NUM = ""

# The port number on the card that holds the west port
TRAFFICGEN_STC_WEST_PORT_NUM = ""

# The friendly name to identify the Spirent Lab Server test session
TRAFFICGEN_STC_TEST_SESSION_NAME = "RFC2544 Tput"
# The directory to copy results to

TRAFFICGEN_STC_RESULTS_DIR = os.path.join(ROOT_DIR, "Results")
#  The prefix for the CSV results file

TRAFFICGEN_STC_CSV_RESULTS_FILE_PREFIX = "RFC2544_tput"
# The number of trials to execute during the test

TRAFFICGEN_STC_NUMBER_OF_TRIALS = "1"

# The duration of each trial executed during the test, in seconds
TRAFFICGEN_STC_TRIAL_DURATION_SEC = "60"

# The traffic pattern between endpoints, BACKBONE, MESH or PAIR
TRAFFICGEN_STC_TRAFFIC_PATTERN = "PAIR"

# The search mode used to find the throughput rate, COMBO, STEP or BINARY
TRAFFICGEN_STC_SEARCH_MODE = "BINARY"

# The learning mode used during the test, AUTO, L2_LEARNING, L3_LERNING, or NONE
TRAFFICGEN_STC_LEARNING_MODE = "AUTO"

# The minimum percent line rate that will be used during the test
TRAFFICGEN_STC_RATE_LOWER_LIMIT_PCT = "1.0"

# The maximum percent line rate that will be used during the test
TRAFFICGEN_STC_RATE_UPPER_LIMIT_PCT = "99.0"

# If SearchMode is BINARY, the percent line rate that will be used at the start of the test
TRAFFICGEN_STC_RATE_INITIAL_PCT = "99.0"

# When SearchMode is STEP, the percent increase in load per step
TRAFFICGEN_STC_RATE_STEP_PCT = "10.0"

# The minimum percentage of load adjustment between iterations
TRAFFICGEN_STC_RESOLUTION_PCT = "1.0"

# The frame size, in bytes
TRAFFICGEN_STC_FRAME_SIZE = "256"

# The maximum acceptable frame loss percent in any iteration
TRAFFICGEN_STC_ACCEPTABLE_FRAME_LOSS_PCT = "0.0"

# The address to assign to the first emulated device interface on the first east port
TRAFFICGEN_STC_EAST_INTF_ADDR = ""

# The gateway address to assign to the first emulated device interface on the first east port
TRAFFICGEN_STC_EAST_INTF_GATEWAY_ADDR = ""

# The address to assign to the first emulated device interface on the first west port
TRAFFICGEN_STC_WEST_INTF_ADDR = ""

# The gateway address to assign to the first emulated device interface on the first west port
TRAFFICGEN_STC_WEST_INTF_GATEWAY_ADDR = ""

# Print additional information to the terminal during the test
TRAFFICGEN_STC_VERBOSE = "True"

# Spirent TestCenter Configuration -- END
#########################################

#############################
# Xena Configuration -- BEGIN

# Xena traffic generator connection info
TRAFFICGEN_XENA_IP = ''
TRAFFICGEN_XENA_PORT1 = ''
TRAFFICGEN_XENA_PORT2 = ''
TRAFFICGEN_XENA_USER = ''
TRAFFICGEN_XENA_PASSWORD = ''
TRAFFICGEN_XENA_MODULE1 = ''
TRAFFICGEN_XENA_MODULE2 = ''

# Xena Port IP info
TRAFFICGEN_XENA_PORT0_IP = '192.168.199.10'
TRAFFICGEN_XENA_PORT0_CIDR = 24
TRAFFICGEN_XENA_PORT0_GATEWAY = '192.168.199.1'
TRAFFICGEN_XENA_PORT1_IP = '192.168.199.11'
TRAFFICGEN_XENA_PORT1_CIDR = 24
TRAFFICGEN_XENA_PORT1_GATEWAY = '192.168.199.1'

# Xena RFC 2544 options
# Please reference xena documentation before making changes to these settings
TRAFFICGEN_XENA_2544_TPUT_INIT_VALUE = '10.0'
TRAFFICGEN_XENA_2544_TPUT_MIN_VALUE = '0.1'
TRAFFICGEN_XENA_2544_TPUT_MAX_VALUE = '100.0'
TRAFFICGEN_XENA_2544_TPUT_VALUE_RESOLUTION = '0.5'
TRAFFICGEN_XENA_2544_TPUT_USEPASS_THRESHHOLD = 'false'
TRAFFICGEN_XENA_2544_TPUT_PASS_THRESHHOLD = '0.0'

# Xena RFC 2544 final verification options
TRAFFICGEN_XENA_RFC2544_VERIFY = False
TRAFFICGEN_XENA_RFC2544_VERIFY_DURATION = 120 # in seconds
# Number of verify attempts before giving up...
TRAFFICGEN_XENA_RFC2544_MAXIMUM_VERIFY_ATTEMPTS = 10
# Logic for restarting binary search, see documentation for details
TRAFFICGEN_XENA_RFC2544_BINARY_RESTART_SMART_SEARCH = True

# Xena Continuous traffic options
# Please reference xena documentation before making changes to these settings
TRAFFICGEN_XENA_CONT_PORT_LEARNING_ENABLED = True
TRAFFICGEN_XENA_CONT_PORT_LEARNING_DURATION = 3

# Xena Configuration -- END
###########################

###################################################
# MoonGen Configuration and Connection Info-- BEGIN

# Ex: TRAFFICGEN_MOONGEN_HOST_IP_ADDR = "192.10.1.1"
TRAFFICGEN_MOONGEN_HOST_IP_ADDR = ''
TRAFFICGEN_MOONGEN_USER = ''
TRAFFICGEN_MOONGEN_BASE_DIR = ''
TRAFFICGEN_MOONGEN_PORTS = ''
# Ex. 10 Gbps: TRAFFICGEN_MOONGEN_LINE_SPEED_GBPS = '10'
# Today only 10 Gbps is supported
TRAFFICGEN_MOONGEN_LINE_SPEED_GBPS = ''

# MoonGen Configuration and Connection Info-- END
###################################################