From 79f5ba9bf7656972dd988508eff9465562dde42c Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Mon, 4 May 2020 13:05:26 +0200 Subject: Separate files needing GPL license + Keep apache license for now, until this is completed: https://wiki.fd.io/view/TSC/Relicensing_Procedure + Add utilities for switching license comment blocks. - They do not preserve attributes, so executable flag is lost. + Move the affected files to GPL/. + Update paths so files are executed from the new location. + Change the way scripts are started to do not require executable flag. + Employ OptionString when constructing longer command lines. + Move also PacketVerifier.py and TrafficScriptArg.py as they are linked with traffic scripts. + That means the two files are outside "resources" package tree now. + Added __init__.py files so relative imports work in new package tree. + Start traffic scripts as python modules to allow relative imports. + Once again needed because they are outside the default PYTHONPATH. Change-Id: Ieb135629e890adbaf5b79497570f3be25b746f9f Signed-off-by: Vratko Polak --- .../trex/profile_trex_stateless_base_class.py | 217 ++++++++++++++++ .../trex/trex-sl-2n-dot1qip4asym-ip4src254.py | 133 ++++++++++ .../trex/trex-sl-2n-dot1qip6asym-ip6src253.py | 134 ++++++++++ .../trex/trex-sl-2n-ethip4-ip4dst-rnd10000.py | 127 +++++++++ .../trex/trex-sl-2n-ethip4-ip4dst-rnd100000.py | 126 +++++++++ .../trex/trex-sl-2n-ethip4-ip4dst-rnd1000000.py | 126 +++++++++ .../trex/trex-sl-2n-ethip4-ip4dst10000.py | 125 +++++++++ .../trex/trex-sl-2n-ethip4-ip4dst100000.py | 126 +++++++++ .../trex/trex-sl-2n-ethip4-ip4dst1000000.py | 126 +++++++++ .../trex/trex-sl-2n-ethip4-ip4src253.py | 126 +++++++++ .../trex/trex-sl-2n-ethip4-ip4src254.py | 126 +++++++++ .../trex/trex-sl-2n-ethip4-macsrc500kdst500k.py | 215 +++++++++++++++ .../trex/trex-sl-2n-ethip4-macsrc50kdst50k.py | 214 +++++++++++++++ .../trex/trex-sl-2n-ethip4-macsrc5kdst5k.py | 215 +++++++++++++++ .../trex/trex-sl-2n-ethip4udp-1000u15p.py | 146 +++++++++++ .../trex/trex-sl-2n-ethip4udp-10u1000p-conc.py | 189 ++++++++++++++ .../trex/trex-sl-2n-ethip4udp-1u1p.py | 104 ++++++++ .../trex/trex-sl-2n-ethip4udp-lb.py | 150 +++++++++++ .../trex/trex-sl-2n-ethip6-ip6dst10000.py | 129 +++++++++ .../trex/trex-sl-2n-ethip6-ip6dst100000.py | 129 +++++++++ .../trex/trex-sl-2n-ethip6-ip6dst1000000.py | 129 +++++++++ .../trex/trex-sl-2n-ethip6-ip6src253.py | 129 +++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-10c1n.py | 163 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-10c2n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-1c10n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-1c1n.py | 166 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-1c2n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-1c4n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-1c6n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-1c8n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-2c10n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-2c1n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-2c2n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-2c4n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-2c6n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-2c8n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-4c1n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-4c2n.py | 162 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-4c4n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-4c6n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-6c1n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-6c2n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-6c4n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-8c1n.py | 164 ++++++++++++ .../trex/trex-sl-2n3n-ethip4-ip4src254-8c2n.py | 164 ++++++++++++ ...rex-sl-3n-dot1qip4-vlan100ip4src254ip4dst254.py | 191 ++++++++++++++ ...trex-sl-3n-dot1qip4-vlan10ip4src254ip4dst254.py | 191 ++++++++++++++ .../trex-sl-3n-dot1qip4-vlan1ip4src254ip4dst254.py | 166 ++++++++++++ ...trex-sl-3n-dot1qip4-vlan1kip4src254ip4dst254.py | 191 ++++++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1.py | 85 ++++++ .../trex/trex-sl-3n-ethip4-ip4dst100.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1000-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1000-2cnf.py | 156 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1000-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1000-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst10000-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst10000-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst10000-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst10000-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst10000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst100000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst1000000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst20000-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst20000-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst20000-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst20000-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst20000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst253.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst253_l3fwd.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst4-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst4-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst4-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst4.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst400-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst400-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst400-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst400-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst400.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40000-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40000-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40000-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40000-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst40000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst5000-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst5000-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst5000-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst5000-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst5000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4dst60000-1cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst60000-2cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst60000-4cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst60000-8cnf.py | 157 +++++++++++ .../trex/trex-sl-3n-ethip4-ip4dst60000.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4src253.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-ip4src254.py | 126 +++++++++ .../trex/trex-sl-3n-ethip4-macsrc100ip4src100.py | 161 ++++++++++++ .../trex/trex-sl-3n-ethip4-macsrc100kip4src100k.py | 161 ++++++++++++ .../trex/trex-sl-3n-ethip4-macsrc10kip4src10k.py | 161 ++++++++++++ .../trex/trex-sl-3n-ethip4-macsrc500kdst500k.py | 215 +++++++++++++++ .../trex/trex-sl-3n-ethip4-macsrc50kdst50k.py | 215 +++++++++++++++ .../trex/trex-sl-3n-ethip4-macsrc5kdst5k.py | 215 +++++++++++++++ .../trex/trex-sl-3n-ethip4udp-1000u15p.py | 148 +++++++++++ .../trex/trex-sl-3n-ethip4udp-100u1000p-conc.py | 189 ++++++++++++++ .../trex/trex-sl-3n-ethip4udp-100u15p.py | 148 +++++++++++ .../trex/trex-sl-3n-ethip4udp-10u1000p-conc.py | 189 ++++++++++++++ .../trex/trex-sl-3n-ethip4udp-10u10p-conc.py | 189 ++++++++++++++ .../trex/trex-sl-3n-ethip4udp-10u15p.py | 148 +++++++++++ .../trex/trex-sl-3n-ethip4udp-1u15p.py | 141 ++++++++++ .../trex/trex-sl-3n-ethip4udp-1u1p.py | 104 ++++++++ .../trex/trex-sl-3n-ethip4udp-2000u15p.py | 148 +++++++++++ .../trex/trex-sl-3n-ethip4udp-4000u15p.py | 148 +++++++++++ .../trex/trex-sl-3n-ethip6-ip6dst10000.py | 129 +++++++++ .../trex/trex-sl-3n-ethip6-ip6dst100000.py | 129 +++++++++ .../trex/trex-sl-3n-ethip6-ip6dst1000000.py | 129 +++++++++ .../trex/trex-sl-3n-ethip6-ip6src253.py | 129 +++++++++ ...trex-sl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py | 170 ++++++++++++ .../trex-sl-dot1qip4-vlan1ip4src254ip4dst254.py | 164 ++++++++++++ .../trex-sl-dot1qip4vxlan-ip4src10udpsrcrnd.py | 287 ++++++++++++++++++++ .../trex/trex-sl-dot1qip4vxlan-ip4src1udpsrcrnd.py | 288 +++++++++++++++++++++ .../trex/trex-sl-dot1qip4vxlan-ip4src2udpsrcrnd.py | 288 +++++++++++++++++++++ .../trex/trex-sl-dot1qip4vxlan-ip4src4udpsrcrnd.py | 288 +++++++++++++++++++++ .../trex/trex-sl-dot1qip4vxlan-ip4src6udpsrcrnd.py | 288 +++++++++++++++++++++ .../trex/trex-sl-dot1qip4vxlan-ip4src8udpsrcrnd.py | 288 +++++++++++++++++++++ .../trex/trex-sl-ethip4vxlan-ip4src1udpsrcrnd.py | 261 +++++++++++++++++++ 130 files changed, 20864 insertions(+) create mode 100644 GPL/traffic_profiles/trex/profile_trex_stateless_base_class.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-dot1qip4asym-ip4src254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-dot1qip6asym-ip6src253.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd10000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd100000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd1000000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst10000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst100000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst1000000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src253.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc500kdst500k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc50kdst50k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc5kdst5k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1000u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-10u1000p-conc.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1u1p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-lb.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst10000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst100000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst1000000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6src253.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c1n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c2n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c10n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c1n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c2n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c4n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c6n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c8n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c10n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c1n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c2n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c4n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c6n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c8n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c1n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c2n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c4n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c6n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c1n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c2n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c4n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c1n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c2n.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan100ip4src254ip4dst254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan10ip4src254ip4dst254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1ip4src254ip4dst254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1kip4src254ip4dst254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253_l3fwd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-1cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-2cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-4cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-8cnf.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src253.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100ip4src100.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100kip4src100k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc10kip4src10k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc500kdst500k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc50kdst50k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc5kdst5k.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1000u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u1000p-conc.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u1000p-conc.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u10p-conc.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u1p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-2000u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-4000u15p.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst10000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst100000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst1000000.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6src253.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src10udpsrcrnd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src1udpsrcrnd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src2udpsrcrnd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src4udpsrcrnd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src6udpsrcrnd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src8udpsrcrnd.py create mode 100644 GPL/traffic_profiles/trex/trex-sl-ethip4vxlan-ip4src1udpsrcrnd.py (limited to 'GPL/traffic_profiles') diff --git a/GPL/traffic_profiles/trex/profile_trex_stateless_base_class.py b/GPL/traffic_profiles/trex/profile_trex_stateless_base_class.py new file mode 100644 index 0000000000..a3736796eb --- /dev/null +++ b/GPL/traffic_profiles/trex/profile_trex_stateless_base_class.py @@ -0,0 +1,217 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Base class for stream profiles for T-rex traffic generator. +""" + +import sys +import socket +import struct + +from random import choice +from string import ascii_letters + +from trex.stl.api import * + + +class TrafficStreamsBaseClass: + """Base class for stream profiles for T-rex traffic generator.""" + + STREAM_TABLE = { + u"IMIX_v4": [ + {u"size": 60, u"pps": 28, u"isg": 0}, + {u"size": 590, u"pps": 20, u"isg": 0.1}, + {u"size": 1514, u"pps": 4, u"isg": 0.2} + ], + 'IMIX_v4_1': [ + {u"size": 64, u"pps": 28, u"isg": 0}, + {u"size": 570, u"pps": 16, u"isg": 0.1}, + {u"size": 1518, u"pps": 4, u"isg": 0.2} + ] + } + + def __init__(self): + # Default value of frame size, it will be overwritten by the value of + # "framesize" parameter of "get_streams" method. + self.framesize = 64 + + # If needed, add your own parameters. + + def _gen_payload(self, length): + """Generate payload. + + If needed, implement your own algorithm. + + :param length: Length of generated payload. + :type length: int + :returns: The generated payload. + :rtype: str + """ + payload = u"" + for _ in range(length): + payload += choice(ascii_letters) + + return payload + + def _get_start_end_ipv6(self, start_ip, end_ip): + """Get start host and number of hosts from IPv6 as integer. + + :param start_ip: Start IPv6. + :param end_ip: End IPv6. + :type start_ip: string + :type end_ip: string + :return: Start host, number of hosts. + :rtype tuple of int + :raises: ValueError if start_ip is greater then end_ip. + :raises: socket.error if the IP addresses are not valid IPv6 addresses. + """ + try: + ip1 = socket.inet_pton(socket.AF_INET6, start_ip) + ip2 = socket.inet_pton(socket.AF_INET6, end_ip) + + hi1, lo1 = struct.unpack(u"!QQ", ip1) + hi2, lo2 = struct.unpack(u"!QQ", ip2) + + if ((hi1 << 64) | lo1) > ((hi2 << 64) | lo2): + raise ValueError(u"IPv6: start_ip is greater then end_ip") + + return lo1, abs(int(lo1) - int(lo2)) + + except socket.error as err: + print(err) + raise + + def define_packets(self): + """Define the packets to be sent from the traffic generator. + + This method MUST return: + + return base_pkt_a, base_pkt_b, vm1, vm2 + + vm1 and vm2 CAN be None. + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + raise NotImplementedError + + def create_streams(self): + """Create traffic streams. + + Implement your own traffic streams. + + :returns: Traffic streams. + :rtype: list + """ + base_pkt_a, base_pkt_b, vm1, vm2 = self.define_packets() + + # In most cases you will not have to change the code below: + + # Frame size is defined as an integer, e.g. 64, 1518: + if isinstance(self.framesize, int): + + # Create a base packet and pad it to size + payload_len = max(0, self.framesize - len(base_pkt_a) - 4) # No FCS + + # Direction 0 --> 1 + pkt_a = STLPktBuilder( + pkt=base_pkt_a / self._gen_payload(payload_len), vm=vm1 + ) + # Direction 1 --> 0 + pkt_b = STLPktBuilder( + pkt=base_pkt_b / self._gen_payload(payload_len), vm=vm2 + ) + + # Packets for latency measurement: + # Direction 0 --> 1 + pkt_lat_a = STLPktBuilder( + pkt=base_pkt_a / self._gen_payload(payload_len), vm=vm1 + ) + # Direction 1 --> 0 + pkt_lat_b = STLPktBuilder( + pkt=base_pkt_b / self._gen_payload(payload_len), vm=vm2 + ) + + # Create the streams: + # Direction 0 --> 1 + stream1 = STLStream(packet=pkt_a, mode=STLTXCont(pps=9000)) + # Direction 1 --> 0 + # second traffic stream with a phase of 10ns (inter-stream gap) + stream2 = STLStream(packet=pkt_b, isg=10.0, + mode=STLTXCont(pps=9000)) + + # Streams for latency measurement: + # Direction 0 --> 1 + lat_stream1 = STLStream( + packet=pkt_lat_a, + flow_stats=STLFlowLatencyStats(pg_id=0), + mode=STLTXCont(pps=9000) + ) + # Direction 1 --> 0 + # second traffic stream with a phase of 10ns (inter-stream gap) + lat_stream2 = STLStream( + packet=pkt_lat_b, + isg=10.0, + flow_stats=STLFlowLatencyStats(pg_id=1), + mode=STLTXCont(pps=9000) + ) + + return [stream1, stream2, lat_stream1, lat_stream2] + + # Frame size is defined as a string, e.g.IMIX_v4_1: + elif isinstance(self.framesize, str): + + stream1 = list() + stream2 = list() + + for stream in self.STREAM_TABLE[self.framesize]: + payload_len_a = max(0, stream[u"size"] - len(base_pkt_a) - 4) + payload_len_b = max(0, stream[u"size"] - len(base_pkt_b) - 4) + # Create a base packet and pad it to size + pkt_a = STLPktBuilder( + pkt=base_pkt_a / self._gen_payload(payload_len_a), + vm=vm1) + pkt_b = STLPktBuilder( + pkt=base_pkt_b / self._gen_payload(payload_len_b), + vm=vm2) + + # Create the streams: + stream1.append(STLStream( + packet=pkt_a, + isg=stream[u"isg"], + mode=STLTXCont(pps=stream[u"pps"])) + ) + stream2.append(STLStream( + packet=pkt_b, + isg=stream[u"isg"], + mode=STLTXCont(pps=stream[u"pps"])) + ) + streams = list() + streams.extend(stream1) + streams.extend(stream2) + + return streams + + def get_streams(self, **kwargs): + """Get traffic streams created by "create_streams" method. + + If needed, add your own parameters. + + :param kwargs: Key-value pairs used by "create_streams" method while + creating streams. + :returns: Traffic streams. + :rtype: list + """ + self.framesize = kwargs[u"framesize"] + + return self.create_streams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-dot1qip4asym-ip4src254.py b/GPL/traffic_profiles/trex/trex-sl-2n-dot1qip4asym-ip4src254.py new file mode 100644 index 0000000000..ae411e233b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-dot1qip4asym-ip4src254.py @@ -0,0 +1,133 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Direction 0 --> 1: + - Packet: ETH / IP / + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Packet: ETH / DOT1Q / IP / + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN ID + self.vlan_id = 10 + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.vlan_id + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-dot1qip6asym-ip6src253.py b/GPL/traffic_profiles/trex/trex-sl-2n-dot1qip6asym-ip6src253.py new file mode 100644 index 0000000000..f2e9e81920 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-dot1qip6asym-ip6src253.py @@ -0,0 +1,134 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Direction 0 --> 1: + - Packet: ETH / IPv6 / + - Source IP address range: 2001:1::2 - 2001:1::FE + - Destination IP address range: 2001:2::2 + - Direction 1 --> 0: + - Packet: ETH / DOT1Q / IPv6 / + - Source IP address range: 2001:2::2 - 2001:2::FE + - Destination IP address range: 2001:1::2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN ID + self.vlan_id = 10 + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::2" + self.p1_src_end_ip = u"2001:1::FE" + self.p1_dst_start_ip = u"2001:2::2" + + self.p2_src_start_ip = u"2001:2::2" + self.p2_src_end_ip = u"2001:2::FE" + self.p2_dst_start_ip = u"2001:1::2" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_src_start_ip, + self.p1_src_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_src_start_ip, + self.p2_src_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.vlan_id + ) / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_src", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_src", + pkt_offset=u"IPv6.src", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_src", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_src", + pkt_offset=u"IPv6.src", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd10000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd10000.py new file mode 100644 index 0000000000..16627f0884 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd10000.py @@ -0,0 +1,127 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams" parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + limit=10000 + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + limit=10000 + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd100000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd100000.py new file mode 100644 index 0000000000..751528d10c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd100000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.1.134.159 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.1.134.159 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams" parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.1.134.159" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.1.134.159" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + limit=100000 + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + limit=100000 + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd1000000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd1000000.py new file mode 100644 index 0000000000..58ab03516c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst-rnd1000000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.15.66.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.15.66.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams" parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.15.66.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.15.66.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + limit=1000000 + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVarRepeatableRandom( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + limit=1000000 + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst10000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst10000.py new file mode 100644 index 0000000000..e9d5fb15f6 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst10000.py @@ -0,0 +1,125 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst100000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst100000.py new file mode 100644 index 0000000000..5977d36b5b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst100000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.1.134.159 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.1.134.159 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.1.134.159" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.1.134.159" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst1000000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst1000000.py new file mode 100644 index 0000000000..8b63b82e4f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4dst1000000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.15.66.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.15.66.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.15.66.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.15.66.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name="dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op="inc" + ), + STLVmWrFlowVar( + fv_name="dst", + pkt_offset="IP.dst" + ), + STLVmFixIpv4( + offset="IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src253.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src253.py new file mode 100644 index 0000000000..883883ad18 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src253.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.10.10.2 - 10.10.10.254 + - Destination IP address range: 20.20.20.2 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.2 - 20.20.20.254 + - Destination IP address range: 10.10.10.2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.2" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.2" + + self.p2_src_start_ip = u"20.20.20.2" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.2" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src254.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src254.py new file mode 100644 index 0000000000..fc6167d126 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-ip4src254.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc500kdst500k.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc500kdst500k.py new file mode 100644 index 0000000000..9c55482078 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc500kdst500k.py @@ -0,0 +1,215 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:07:a1:1f + - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:07:a1:1f + - Source IP address range: 10.0.0.0 - 10.7.161.31 + - Destination IP address range: 20.0.0.0 - 20.7.161.31 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:07:a1:1f + - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:07:a1:1f + - Source IP address range: 20.0.0.0 - 20.7.161.31 + - Destination IP address range: 10.0.0.0 - 10.7.161.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 500000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.7.161.31" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.7.161.31" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.7.161.31" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.7.161.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac, + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc50kdst50k.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc50kdst50k.py new file mode 100644 index 0000000000..42e3db6a6f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc50kdst50k.py @@ -0,0 +1,214 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:c3:4f + - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:c3:4f + - Source IP address range: 10.0.0.0 - 10.0.195.79 + - Destination IP address range: 20.0.0.0 - 20.0.195.79 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:c3:4f + - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:c3:4f + - Source IP address range: 20.0.0.0 - 20.0.195.79 + - Destination IP address range: 10.0.0.0 - 10.0.195.79 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 50000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.195.79" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.195.79" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.195.79" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.195.79" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac, + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc5kdst5k.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc5kdst5k.py new file mode 100644 index 0000000000..29df3373d3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4-macsrc5kdst5k.py @@ -0,0 +1,215 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:13:87 + - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:13:87 + - Source IP address range: 10.0.0.0 - 10.0.19.135 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:13:87 + - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:13:87 + - Source IP address range: 20.0.0.0 - 20.0.19.135 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 5000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.19.135" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.19.135" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac, + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1000u15p.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1000u15p.py new file mode 100644 index 0000000000..64fe1a705f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1000u15p.py @@ -0,0 +1,146 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 - 20.0.3.231 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 16023 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.3.231" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 16023 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple" + ), + STLVmWrFlowVar( + fv_name=u"tuple.ip", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4(offset=u"IP"), + STLVmWrFlowVar( + fv_name=u"tuple.port", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-10u1000p-conc.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-10u1000p-conc.py new file mode 100644 index 0000000000..77f05f8af3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-10u1000p-conc.py @@ -0,0 +1,189 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 10.10.10.2 - 10.10.10.11 + - Destination IP address range: 20.20.20.2 - 20.20.20.11 + - Source UDP port range: 1001 - 2000 + - Destination UDP port range: 2001 - 3000 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.2 - 20.20.20.11 + - Destination IP address range: 10.10.10.2 - 10.10.10.11 + - Source UDP port range: 2001 - 3000 + - Destination UDP port range: 1001 - 2000 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.2" + self.p1_src_end_ip = u"10.10.10.11" + self.p1_dst_start_ip = u"20.20.20.2" + self.p1_dst_end_ip = u"20.20.20.11" + + self.p2_src_start_ip = u"20.20.20.2" + self.p2_src_end_ip = u"20.20.20.11" + self.p2_dst_start_ip = u"10.10.10.2" + self.p2_dst_end_ip = u"10.10.10.11" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1001 + self.p1_src_end_udp_port = 2000 + self.p1_dst_start_udp_port = 2001 + self.p1_dst_end_udp_port = 3000 + + self.p2_src_start_udp_port = 2001 + self.p2_src_end_udp_port = 3000 + self.p2_dst_start_udp_port = 1001 + self.p2_dst_end_udp_port = 2000 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple1_src" + ), + STLVmTupleGen( + ip_min=self.p1_dst_start_ip, + ip_max=self.p1_dst_end_ip, + port_min=self.p1_dst_start_udp_port, + port_max=self.p1_dst_end_udp_port, + name=u"tuple1_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p2_src_start_ip, + ip_max=self.p2_src_end_ip, + port_min=self.p2_src_start_udp_port, + port_max=self.p2_src_end_udp_port, + name=u"tuple2_src" + ), + STLVmTupleGen( + ip_min=self.p2_dst_start_ip, + ip_max=self.p2_dst_end_ip, + port_min=self.p2_dst_start_udp_port, + port_max=self.p2_dst_end_udp_port, + name=u"tuple2_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1u1p.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1u1p.py new file mode 100644 index 0000000000..a892ec8822 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-1u1p.py @@ -0,0 +1,104 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1028 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_ip = u"20.0.0.0" + self.p1_dst_ip = u"12.0.0.2" + + self.p2_src_ip = u"12.0.0.2" + self.p2_dst_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_udp_port = 1024 + self.p1_dst_udp_port = 1024 + + self.p2_src_udp_port = 1024 + self.p2_dst_udp_port = 1028 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_ip, + dst=self.p1_dst_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_udp_port, + dport=self.p1_dst_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_ip, + dst=self.p2_dst_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_udp_port, + dport=self.p2_dst_udp_port + ) + ) + + return base_pkt_a, base_pkt_b, None, None + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-lb.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-lb.py new file mode 100644 index 0000000000..df05cbff17 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip4udp-lb.py @@ -0,0 +1,150 @@ +# Copyright (c) 2020 Intel and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 192.168.50.74 - 192.168.50.79 + - Destination IP address range: 90.1.2.1 + - Direction 1 --> 0: + - Source IP address range: 192.168.60.74 - 192.168.60.79 + - Destination IP address range: 192.168.50.74 - 192.168.50.79 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"192.168.50.74" + self.p1_src_end_ip = u"192.168.50.79" + self.p1_dst_start_ip = u"90.1.2.1" + + self.p2_src_start_ip = u"192.168.60.74" + self.p2_src_end_ip = u"192.168.60.79" + self.p2_dst_start_ip = u"192.168.50.74" + self.p2_dst_end_ip = u"192.168.50.79" + + # UDP ports used in packet headers. + self.p1_src_udp_port = 63 + self.p1_dst_udp_port = 20000 + + self.p2_src_udp_port = 3307 + self.p2_dst_udp_port = 63 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17) / + UDP( + sport=self.p1_src_udp_port, + dport=self.p1_dst_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_udp_port, + dport=self.p2_dst_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst10000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst10000.py new file mode 100644 index 0000000000..f1b90350fb --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst10000.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::1 + - Destination IP address range: 2001:2::0 - 2001:2::270F + - Direction 1 --> 0: + - Source IP address range: 2001:2::1 + - Destination IP address range: 2001:1::0 - 2001:1::270F +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::1" + self.p1_dst_start_ip = u"2001:2::0" + self.p1_dst_end_ip = u"2001:2::270F" + + self.p2_src_start_ip = u"2001:2::1" + self.p2_dst_start_ip = u"2001:1::0" + self.p2_dst_end_ip = u"2001:1::270F" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_dst_start_ip, + self.p1_dst_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_dst_start_ip, + self.p2_dst_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst100000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst100000.py new file mode 100644 index 0000000000..87e76726b2 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst100000.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::1 + - Destination IP address range: 2001:2::0 - 2001:2::1:869F + - Direction 1 --> 0: + - Source IP address range: 2001:2::1 + - Destination IP address range: 2001:1::0 - 2001:1::1:869F +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::1" + self.p1_dst_start_ip = u"2001:2::0" + self.p1_dst_end_ip = u"2001:2::1:869F" + + self.p2_src_start_ip = u"2001:2::1" + self.p2_dst_start_ip = u"2001:1::0" + self.p2_dst_end_ip = u"2001:1::1:869F" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_dst_start_ip, + self.p1_dst_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_dst_start_ip, + self.p2_dst_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst1000000.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst1000000.py new file mode 100644 index 0000000000..9214b6239d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6dst1000000.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::1 + - Destination IP address range: 2001:2::0 - 2001:2::F:423F + - Direction 1 --> 0: + - Source IP address range: 2001:2::1 + - Destination IP address range: 2001:1::0 - 2001:1::F:423F +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::1" + self.p1_dst_start_ip = u"2001:2::0" + self.p1_dst_end_ip = u"2001:2::F:423F" + + self.p2_src_start_ip = u"2001:2::1" + self.p2_dst_start_ip = u"2001:1::0" + self.p2_dst_end_ip = u"2001:1::F:423F" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_dst_start_ip, + self.p1_dst_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_dst_start_ip, + self.p2_dst_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6src253.py b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6src253.py new file mode 100644 index 0000000000..7ac5f75bed --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n-ethip6-ip6src253.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::2 - 2001:1::FE + - Destination IP address range: 2001:2::2 + - Direction 1 --> 0: + - Source IP address range: 2001:2::2 - 2001:2::FE + - Destination IP address range: 2001:1::2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::2" + self.p1_src_end_ip = u"2001:1::FE" + self.p1_dst_start_ip = u"2001:2::2" + + self.p2_src_start_ip = u"2001:2::2" + self.p2_src_end_ip = u"2001:2::FE" + self.p2_dst_start_ip = u"2001:1::2" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_src_start_ip, + self.p1_src_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_src_start_ip, + self.p2_src_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_src", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_src", + pkt_offset=u"IPv6.src", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_src", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_src", + pkt_offset=u"IPv6.src", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c1n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c1n.py new file mode 100644 index 0000000000..3707ec6b9a --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c1n.py @@ -0,0 +1,163 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 10 + self.nf_nodes = 1 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c2n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c2n.py new file mode 100644 index 0000000000..52396c3723 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-10c2n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 10 + self.nf_nodes = 2 + + # MACs used in packet headers. + self.p1_dst_start_mac = u'52:54:00:00:00:01' + self.p2_dst_start_mac = u'52:54:00:00:00:02' + + # IPs used in packet headers. + self.p1_src_start_ip = u'10.10.10.1' + self.p1_src_end_ip = u'10.10.10.254' + self.p1_dst_start_ip = u'20.20.20.1' + + self.p2_src_start_ip = u'20.20.20.1' + self.p2_src_end_ip = u'20.20.20.254' + self.p2_dst_start_ip = u'10.10.10.1' + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c10n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c10n.py new file mode 100644 index 0000000000..8d29f86b49 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c10n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 1 + self.nf_nodes = 10 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c1n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c1n.py new file mode 100644 index 0000000000..f50e2e6c1d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c1n.py @@ -0,0 +1,166 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from re import finditer + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 1 + self.nf_nodes = 1 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c2n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c2n.py new file mode 100644 index 0000000000..1923f72504 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c2n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 1 + self.nf_nodes = 2 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c4n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c4n.py new file mode 100644 index 0000000000..a1e55c5253 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c4n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 1 + self.nf_nodes = 4 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c6n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c6n.py new file mode 100644 index 0000000000..ffc8b428ef --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c6n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 1 + self.nf_nodes = 6 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c8n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c8n.py new file mode 100644 index 0000000000..952859b31d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-1c8n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 1 + self.nf_nodes = 8 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c10n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c10n.py new file mode 100644 index 0000000000..84440af422 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c10n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 2 + self.nf_nodes = 10 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c1n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c1n.py new file mode 100644 index 0000000000..91941769a3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c1n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 2 + self.nf_nodes = 1 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c2n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c2n.py new file mode 100644 index 0000000000..d66271f076 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c2n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 2 + self.nf_nodes = 2 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c4n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c4n.py new file mode 100644 index 0000000000..7eadae361b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c4n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 2 + self.nf_nodes = 4 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c6n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c6n.py new file mode 100644 index 0000000000..3725f75b3e --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c6n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 2 + self.nf_nodes = 6 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c8n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c8n.py new file mode 100644 index 0000000000..024cbc34f3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-2c8n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 2 + self.nf_nodes = 8 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c1n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c1n.py new file mode 100644 index 0000000000..e8c62b9c41 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c1n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 4 + self.nf_nodes = 1 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c2n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c2n.py new file mode 100644 index 0000000000..a6fbe9ea79 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c2n.py @@ -0,0 +1,162 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 4 + self.nf_nodes = 2 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c4n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c4n.py new file mode 100644 index 0000000000..f1477419c3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c4n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 4 + self.nf_nodes = 4 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c6n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c6n.py new file mode 100644 index 0000000000..7e2b79fdac --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-4c6n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 4 + self.nf_nodes = 6 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c1n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c1n.py new file mode 100644 index 0000000000..dc8616c6fe --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c1n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 6 + self.nf_nodes = 1 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c2n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c2n.py new file mode 100644 index 0000000000..53a83db70b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c2n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 6 + self.nf_nodes = 2 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c4n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c4n.py new file mode 100644 index 0000000000..ac697e60ec --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-6c4n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 6 + self.nf_nodes = 4 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c1n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c1n.py new file mode 100644 index 0000000000..587dfc3406 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c1n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 8 + self.nf_nodes = 1 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c2n.py b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c2n.py new file mode 100644 index 0000000000..9123a752b2 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-2n3n-ethip4-ip4src254-8c2n.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Destination MAC address: 52:54:00:00:nf_id:01 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Destination MAC address: 52:54:00:00:nf_id:02 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # Service density parameters. + self.nf_chains = 8 + self.nf_nodes = 2 + + # MACs used in packet headers. + self.p1_dst_start_mac = u"52:54:00:00:00:01" + self.p2_dst_start_mac = u"52:54:00:00:00:02" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=1, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=self.nf_nodes, + max_value=self.nf_chains*self.nf_nodes, + size=1, + step=self.nf_nodes, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=4 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan100ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan100ip4src254ip4dst254.py new file mode 100644 index 0000000000..b414bd1c7a --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan100ip4src254ip4dst254.py @@ -0,0 +1,191 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / + - Direction 0 --> 1: + - VLAN range: 1 - 100 + - Source IP address range: 10.0.0.1 - 10.0.0.254 + - Destination IP address range: 20.0.0.1 - 20.0.0.254 + - Direction 1 --> 0: + - VLAN range: 1 - 100 + - Source IP address range: 20.0.0.1 - 20.0.0.254 + - Destination IP address range: 10.0.0.1 - 10.0.0.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN IDs + self.vlans = 100 + + self.p1_vlan_start = 1 + self.p1_vlan_end = self.p1_vlan_start + self.vlans - 1 + + self.p2_vlan_start = 1 + self.p2_vlan_end = self.p2_vlan_start + self.vlans - 1 + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_src_end_ip = u"10.0.0.254" + + self.p1_dst_start_ip = u"20.0.0.1" + self.p1_dst_end_ip = u"20.0.0.254" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_src_end_ip = u"20.0.0.254" + + self.p2_dst_start_ip = u"10.0.0.1" + self.p2_dst_end_ip = u"10.0.0.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + Dot1Q( + vlan=self.p1_vlan_start + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.p2_vlan_start + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"vlan", + min_value=self.p1_vlan_start, + max_value=self.p1_vlan_end, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"vlan", + pkt_offset=u"Dot1Q.vlan" + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"vlan", + min_value=self.p2_vlan_start, + max_value=self.p2_vlan_end, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"vlan", + pkt_offset=u"Dot1Q.vlan" + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan10ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan10ip4src254ip4dst254.py new file mode 100644 index 0000000000..d878e2d726 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan10ip4src254ip4dst254.py @@ -0,0 +1,191 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / + - Direction 0 --> 1: + - VLAN range: 1 - 10 + - Source IP address range: 10.0.0.1 - 10.0.0.254 + - Destination IP address range: 20.0.0.1 - 20.0.0.254 + - Direction 1 --> 0: + - VLAN range: 1 - 10 + - Source IP address range: 20.0.0.1 - 20.0.0.254 + - Destination IP address range: 10.0.0.1 - 10.0.0.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN IDs + self.vlans = 10 + + self.p1_vlan_start = 1 + self.p1_vlan_end = self.p1_vlan_start + self.vlans - 1 + + self.p2_vlan_start = 1 + self.p2_vlan_end = self.p2_vlan_start + self.vlans - 1 + + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_src_end_ip = u"10.0.0.254" + + self.p1_dst_start_ip = u"20.0.0.1" + self.p1_dst_end_ip = u"20.0.0.254" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_src_end_ip = u"20.0.0.254" + + self.p2_dst_start_ip = u"10.0.0.1" + self.p2_dst_end_ip = u"10.0.0.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + Dot1Q( + vlan=self.p1_vlan_start + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.p2_vlan_start + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"vlan", + min_value=self.p1_vlan_start, + max_value=self.p1_vlan_end, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"vlan", + pkt_offset=u"Dot1Q.vlan" + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"vlan", + min_value=self.p2_vlan_start, + max_value=self.p2_vlan_end, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"vlan", + pkt_offset=u"Dot1Q.vlan" + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar(name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1ip4src254ip4dst254.py new file mode 100644 index 0000000000..c8f279bdb3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1ip4src254ip4dst254.py @@ -0,0 +1,166 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / + - Direction 0 --> 1: + - VLAN range: 1 + - Source IP address range: 10.0.0.1 - 10.0.0.254 + - Destination IP address range: 20.0.0.1 - 20.0.0.254 + - Direction 1 --> 0: + - VLAN range: 1 + - Source IP address range: 20.0.0.1 - 20.0.0.254 + - Destination IP address range: 10.0.0.1 - 10.0.0.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN IDs + self.p1_vlan_start = 1 + + self.p2_vlan_start = 1 + + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_src_end_ip = u"10.0.0.254" + + self.p1_dst_start_ip = u"20.0.0.1" + self.p1_dst_end_ip = u"20.0.0.254" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_src_end_ip = u"20.0.0.254" + + self.p2_dst_start_ip = u"10.0.0.1" + self.p2_dst_end_ip = u"10.0.0.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + Dot1Q( + vlan=self.p1_vlan_start + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.p2_vlan_start + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1kip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1kip4src254ip4dst254.py new file mode 100644 index 0000000000..02decf4284 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-dot1qip4-vlan1kip4src254ip4dst254.py @@ -0,0 +1,191 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / + - Direction 0 --> 1: + - VLAN range: 1 - 1000 + - Source IP address range: 10.0.0.1 - 10.0.0.254 + - Destination IP address range: 20.0.0.1 - 20.0.0.254 + - Direction 1 --> 0: + - VLAN range: 1 - 1000 + - Source IP address range: 20.0.0.1 - 20.0.0.254 + - Destination IP address range: 10.0.0.1 - 10.0.0.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN IDs + self.vlans = 1000 + + self.p1_vlan_start = 1 + self.p1_vlan_end = self.p1_vlan_start + self.vlans - 1 + + self.p2_vlan_start = 1 + self.p2_vlan_end = self.p2_vlan_start + self.vlans - 1 + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_src_end_ip = u"10.0.0.254" + + self.p1_dst_start_ip = u"20.0.0.1" + self.p1_dst_end_ip = u"20.0.0.254" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_src_end_ip = u"20.0.0.254" + + self.p2_dst_start_ip = u"10.0.0.1" + self.p2_dst_end_ip = u"10.0.0.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + Dot1Q( + vlan=self.p1_vlan_start + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.p2_vlan_start + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"vlan", + min_value=self.p1_vlan_start, + max_value=self.p1_vlan_end, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"vlan", + pkt_offset=u"Dot1Q.vlan" + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"vlan", + min_value=self.p2_vlan_start, + max_value=self.p2_vlan_end, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"vlan", + pkt_offset=u"Dot1Q.vlan" + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1.py new file mode 100644 index 0000000000..0d36b7358f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1.py @@ -0,0 +1,85 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_ip = u"10.0.0.1" + self.p1_dst_ip = u"20.0.0.0" + + self.p2_src_ip = u"20.0.0.1" + self.p2_dst_ip = u"10.0.0.0" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_ip, + dst=self.p1_dst_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_ip, + dst=self.p2_dst_ip, + proto=61 + ) + ) + + return base_pkt_a, base_pkt_b, None, None + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100.py new file mode 100644 index 0000000000..222b127914 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.99 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.99 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.99" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.99" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-1cnf.py new file mode 100644 index 0000000000..1397ae4828 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.3.231 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.3.231 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.231" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.3.231" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-2cnf.py new file mode 100644 index 0000000000..b7f316092a --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-2cnf.py @@ -0,0 +1,156 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.3.231 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.3.231 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.231" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.3.231" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-4cnf.py new file mode 100644 index 0000000000..a64e4d5a5e --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.3.231 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.3.231 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.231" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.3.231" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-8cnf.py new file mode 100644 index 0000000000..a58df6e87b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.3.231 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.3.231 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.231" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.3.231" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000.py new file mode 100644 index 0000000000..8d9ec21a25 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.3.231 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.3.231 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.3.231" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.3.231" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-1cnf.py new file mode 100644 index 0000000000..53e68de2b9 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-2cnf.py new file mode 100644 index 0000000000..ca3f41a6fb --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-4cnf.py new file mode 100644 index 0000000000..df7572853f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-8cnf.py new file mode 100644 index 0000000000..1dbd3feb1a --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000.py new file mode 100644 index 0000000000..9f55ff71de --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst10000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.39.15 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.39.15 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.39.15" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.39.15" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100000.py new file mode 100644 index 0000000000..ae36cf9995 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst100000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.1.134.159 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.1.134.159 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.1.134.159" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.1.134.159" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000000.py new file mode 100644 index 0000000000..8f6e5a0836 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst1000000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.15.66.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.15.66.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.15.66.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.15.66.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-1cnf.py new file mode 100644 index 0000000000..f6f6fada5a --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.78.31 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.78.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.78.31" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.78.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-2cnf.py new file mode 100644 index 0000000000..15cb461624 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.78.31 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.78.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.78.31" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.78.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-4cnf.py new file mode 100644 index 0000000000..62eb1bee78 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.78.31 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.78.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.78.31" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.78.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-8cnf.py new file mode 100644 index 0000000000..b6eef29366 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.78.31 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.78.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.78.31" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.78.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000.py new file mode 100644 index 0000000000..877e6cdc66 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst20000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.78.31 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.78.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.78.31" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.78.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253.py new file mode 100644 index 0000000000..e1e6a89af7 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 20.20.20.2 + - Destination IP address range: 2.1.1.2 - 2.1.1.254 + - Direction 1 --> 0: + - Source IP address range: 10.10.10.2 + - Destination IP address range: 1.1.1.2 - 1.1.1.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.20.20.2" + self.p1_dst_start_ip = u"2.1.1.2" + self.p1_dst_end_ip = u"2.1.1.254" + + self.p2_src_start_ip = u"10.10.10.2" + self.p2_dst_start_ip = u"1.1.1.2" + self.p2_dst_end_ip = u"1.1.1.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253_l3fwd.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253_l3fwd.py new file mode 100644 index 0000000000..ed4f5b5bd6 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst253_l3fwd.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 20.20.20.2 + - Destination IP address range: 1.1.1.2 - 1.1.1.254 + - Direction 1 --> 0: + - Source IP address range: 10.10.10.2 + - Destination IP address range: 2.1.1.2 - 2.1.1.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.20.20.2" + self.p1_dst_start_ip = u"1.1.1.2" + self.p1_dst_end_ip = u"1.1.1.254" + + self.p2_src_start_ip = u"10.10.10.2" + self.p2_dst_start_ip = u"2.1.1.2" + self.p2_dst_end_ip = u"2.1.1.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-1cnf.py new file mode 100644 index 0000000000..b937d02741 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.3 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.3 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.3" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.3" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-2cnf.py new file mode 100644 index 0000000000..b95649a94d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.3 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.3 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.3" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.3" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-4cnf.py new file mode 100644 index 0000000000..fed0d7ef3c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.3 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.3 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.3" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.3" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4.py new file mode 100644 index 0000000000..9f14d4c929 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst4.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.3 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.3 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.3" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.3" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-1cnf.py new file mode 100644 index 0000000000..d321d0ffb2 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.39 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.39 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.39" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.39" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-2cnf.py new file mode 100644 index 0000000000..acc565e776 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.39 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.39 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.39" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.39" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-4cnf.py new file mode 100644 index 0000000000..629100cb83 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.39 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.39 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.39" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.39" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-8cnf.py new file mode 100644 index 0000000000..b51c98d7aa --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.39 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.39 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.39" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.39" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40.py new file mode 100644 index 0000000000..5dbc5fc803 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.0.39 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.0.39 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.0.39" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.0.39" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-1cnf.py new file mode 100644 index 0000000000..1a004b055f --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.1.143 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.1.143 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.143" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.1.143" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-2cnf.py new file mode 100644 index 0000000000..b09e79d7dc --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.1.143 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.1.143 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.143" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.1.143" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-4cnf.py new file mode 100644 index 0000000000..7081525771 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.1.143 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.1.143 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.143" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.1.143" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-8cnf.py new file mode 100644 index 0000000000..c5b1d52e04 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.1.143 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.1.143 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.143" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.1.143" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400.py new file mode 100644 index 0000000000..44db3ec81c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst400.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.1.143 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.1.143 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.1.143" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.1.143" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-1cnf.py new file mode 100644 index 0000000000..038b986b65 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.156.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.156.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.156.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.156.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-2cnf.py new file mode 100644 index 0000000000..5933b33d20 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.156.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.156.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.156.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.156.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-4cnf.py new file mode 100644 index 0000000000..851cd7c870 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.156.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.156.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.156.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.156.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-8cnf.py new file mode 100644 index 0000000000..40d57f09dd --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.156.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.156.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.156.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.156.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000.py new file mode 100644 index 0000000000..570a236fd6 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst40000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.156.63 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.156.63 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.156.63" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.156.63" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() \ No newline at end of file diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-1cnf.py new file mode 100644 index 0000000000..fb4c61b030 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-2cnf.py new file mode 100644 index 0000000000..ca13c337cb --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-4cnf.py new file mode 100644 index 0000000000..1ffd8c8ba5 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-8cnf.py new file mode 100644 index 0000000000..26efc1a438 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000.py new file mode 100644 index 0000000000..95d8380a22 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst5000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() \ No newline at end of file diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-1cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-1cnf.py new file mode 100644 index 0000000000..251758ddae --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-1cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.234.95 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.234.95 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.234.95" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.234.95" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=0, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-2cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-2cnf.py new file mode 100644 index 0000000000..acebf6d06d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-2cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.234.95 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.234.95 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.234.95" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.234.95" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=1, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-4cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-4cnf.py new file mode 100644 index 0000000000..3fe3caf128 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-4cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.234.95 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.234.95 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.234.95" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.234.95" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=3, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-8cnf.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-8cnf.py new file mode 100644 index 0000000000..84bfb89f0b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000-8cnf.py @@ -0,0 +1,157 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.234.95 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.234.95 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.p1_dst_start_mac = u"02:02:00:00:12:00" + + self.p2_dst_start_mac = u"02:02:00:00:02:00" + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.234.95" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.234.95" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=7, + size=1, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset=5 + ), + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000.py new file mode 100644 index 0000000000..126302d545 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4dst60000.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.0.0.1 + - Destination IP address range: 20.0.0.0 - 20.0.234.95 + - Direction 1 --> 0: + - Source IP address range: 20.0.0.1 + - Destination IP address range: 10.0.0.0 - 10.0.234.95 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.1" + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.234.95" + + self.p2_src_start_ip = u"20.0.0.1" + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.234.95" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src253.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src253.py new file mode 100644 index 0000000000..883883ad18 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src253.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.10.10.2 - 10.10.10.254 + - Destination IP address range: 20.20.20.2 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.2 - 20.20.20.254 + - Destination IP address range: 10.10.10.2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.2" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.2" + + self.p2_src_start_ip = u"20.20.20.2" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.2" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src254.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src254.py new file mode 100644 index 0000000000..fc6167d126 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-ip4src254.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + self.p1_dst_start_ip = u"20.20.20.1" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + self.p2_dst_start_ip = u"10.10.10.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100ip4src100.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100ip4src100.py new file mode 100644 index 0000000000..b94c56ad6c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100ip4src100.py @@ -0,0 +1,161 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: | ETH | IP | + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:00:63 + - Source IP address range: 10.0.0.2 - 10.0.0.101 + - Destination IP address range: 20.0.0.1 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:00:63 + - Source IP address range: 20.0.0.2 - 20.0.0.101 + - Destination IP address range: 10.0.0.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 100 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.2" + self.p1_src_end_ip = u"10.0.0.101" + self.p1_dst_start_ip = u"20.0.0.1" + + self.p2_src_start_ip = u"20.0.0.2" + self.p2_src_end_ip = u"20.0.0.101" + self.p2_dst_start_ip = u"10.0.0.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset=8 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset=8 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100kip4src100k.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100kip4src100k.py new file mode 100644 index 0000000000..52eb841ab0 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc100kip4src100k.py @@ -0,0 +1,161 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: | ETH | IP | + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:01:86:9f + - Source IP address range: 10.0.0.2 - 10.1.134.161 + - Destination IP address range: 20.0.0.1 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:01:86:9f + - Source IP address range: 20.0.0.2 - 20.1.134.161 + - Destination IP address range: 10.0.0.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 100000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.2" + self.p1_src_end_ip = u"10.1.134.161" + self.p1_dst_start_ip = u"20.0.0.1" + + self.p2_src_start_ip = u"20.0.0.2" + self.p2_src_end_ip = u"20.1.134.161" + self.p2_dst_start_ip = u"10.0.0.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset=8 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset=8 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc10kip4src10k.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc10kip4src10k.py new file mode 100644 index 0000000000..8e959c829d --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc10kip4src10k.py @@ -0,0 +1,161 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: | ETH | IP | + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:27:0f + - Source IP address range: 10.0.0.2 - 10.0.39.17 + - Destination IP address range: 20.0.0.1 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:27:0f + - Source IP address range: 20.0.0.2 - 20.0.39.17 + - Destination IP address range: 10.0.0.1 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 10000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.2" + self.p1_src_end_ip = u"10.0.39.17" + self.p1_dst_start_ip = u"20.0.0.1" + + self.p2_src_start_ip = u"20.0.0.2" + self.p2_src_end_ip = u"20.0.39.17" + self.p2_dst_start_ip = u"10.0.0.1" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset=8 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset=8 + ), + STLVmFlowVar( + name=u"src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"src", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc500kdst500k.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc500kdst500k.py new file mode 100644 index 0000000000..da4348f2a0 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc500kdst500k.py @@ -0,0 +1,215 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:07:a1:1f + - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:07:a1:1f + - Source IP address range: 10.0.0.0 - 10.7.161.31 + - Destination IP address range: 20.0.0.0 - 20.7.161.31 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:07:a1:1f + - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:07:a1:1f + - Source IP address range: 20.0.0.0 - 20.7.161.31 + - Destination IP address range: 10.0.0.0 - 10.7.161.31 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 500000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.7.161.31" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.7.161.31" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.7.161.31" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.7.161.31" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac, + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc50kdst50k.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc50kdst50k.py new file mode 100644 index 0000000000..6cf066367b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc50kdst50k.py @@ -0,0 +1,215 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:c3:4f + - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:c3:4f + - Source IP address range: 10.0.0.0 - 10.0.195.79 + - Destination IP address range: 20.0.0.0 - 20.0.195.79 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:c3:4f + - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:c3:4f + - Source IP address range: 20.0.0.0 - 20.0.195.79 + - Destination IP address range: 10.0.0.0 - 10.0.195.79 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 50000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.195.79" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.195.79" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.195.79" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.195.79" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac, + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc5kdst5k.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc5kdst5k.py new file mode 100644 index 0000000000..29df3373d3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4-macsrc5kdst5k.py @@ -0,0 +1,215 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / + - Direction 0 --> 1: + - Source MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:13:87 + - Destination MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:13:87 + - Source IP address range: 10.0.0.0 - 10.0.19.135 + - Destination IP address range: 20.0.0.0 - 20.0.19.135 + - Direction 1 --> 0: + - Source MAC address range: fa:ce:00:00:00:00 - fa:ce:00:00:13:87 + - Destination MAC address range: ca:fe:00:00:00:00 - ca:fe:00:00:13:87 + - Source IP address range: 20.0.0.0 - 20.0.19.135 + - Destination IP address range: 10.0.0.0 - 10.0.19.135 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.clients = 5000 + + # MACs used in packet headers. + self.p1_src_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p1_dst_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + self.p2_src_start_mac = u"fa:ce:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + self.p2_dst_start_mac = u"ca:fe:00:00:00:00" # mask: 00:00:FF:FF:FF:FF + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.0.0.0" + self.p1_src_end_ip = u"10.0.19.135" + + self.p1_dst_start_ip = u"20.0.0.0" + self.p1_dst_end_ip = u"20.0.19.135" + + self.p2_src_start_ip = u"20.0.0.0" + self.p2_src_end_ip = u"20.0.19.135" + + self.p2_dst_start_ip = u"10.0.0.0" + self.p2_dst_end_ip = u"10.0.19.135" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + src=self.p1_src_start_mac, + dst=self.p1_dst_start_mac + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + src=self.p2_src_start_mac, + dst=self.p2_dst_start_mac + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"mac_src", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmFlowVar( + name=u"mac_dst", + min_value=0, + max_value=self.clients-1, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"mac_src", + pkt_offset= 8 + ), + STLVmWrFlowVar( + fv_name=u"mac_dst", + pkt_offset= 2 + ), + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1000u15p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1000u15p.py new file mode 100644 index 0000000000..b7b364f195 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1000u15p.py @@ -0,0 +1,148 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 - 20.0.3.231 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 16023 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.3.231" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 16023 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple" + ), + STLVmWrFlowVar( + fv_name=u"tuple.ip", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple.port", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u1000p-conc.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u1000p-conc.py new file mode 100644 index 0000000000..b93cd645ae --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u1000p-conc.py @@ -0,0 +1,189 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 10.10.10.2 - 10.10.10.101 + - Destination IP address range: 20.20.20.2 - 20.20.20.101 + - Source UDP port range: 1001 - 2000 + - Destination UDP port range: 2001 - 3000 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.2 - 20.20.20.101 + - Destination IP address range: 10.10.10.2 - 10.10.10.101 + - Source UDP port range: 2001 - 3000 + - Destination UDP port range: 1001 - 2000 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.2" + self.p1_src_end_ip = u"10.10.10.101" + self.p1_dst_start_ip = u"20.20.20.2" + self.p1_dst_end_ip = u"20.20.20.101" + + self.p2_src_start_ip = u"20.20.20.2" + self.p2_src_end_ip = u"20.20.20.101" + self.p2_dst_start_ip = u"10.10.10.2" + self.p2_dst_end_ip = u"10.10.10.101" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1001 + self.p1_src_end_udp_port = 2000 + self.p1_dst_start_udp_port = 2001 + self.p1_dst_end_udp_port = 3000 + + self.p2_src_start_udp_port = 2001 + self.p2_src_end_udp_port = 3000 + self.p2_dst_start_udp_port = 1001 + self.p2_dst_end_udp_port = 2000 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple1_src" + ), + STLVmTupleGen( + ip_min=self.p1_dst_start_ip, + ip_max=self.p1_dst_end_ip, + port_min=self.p1_dst_start_udp_port, + port_max=self.p1_dst_end_udp_port, + name=u"tuple1_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p2_src_start_ip, + ip_max=self.p2_src_end_ip, + port_min=self.p2_src_start_udp_port, + port_max=self.p2_src_end_udp_port, + name=u"tuple2_src" + ), + STLVmTupleGen( + ip_min=self.p2_dst_start_ip, + ip_max=self.p2_dst_end_ip, + port_min=self.p2_dst_start_udp_port, + port_max=self.p2_dst_end_udp_port, + name=u"tuple2_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u15p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u15p.py new file mode 100644 index 0000000000..31cdc5e628 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-100u15p.py @@ -0,0 +1,148 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 - 20.0.0.99 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 2523 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.0.99" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 2523 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple" + ), + STLVmWrFlowVar( + fv_name=u"tuple.ip", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple.port", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u1000p-conc.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u1000p-conc.py new file mode 100644 index 0000000000..9032a8c2f5 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u1000p-conc.py @@ -0,0 +1,189 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 10.10.10.2 - 10.10.10.11 + - Destination IP address range: 20.20.20.2 - 20.20.20.11 + - Source UDP port range: 1001 - 2000 + - Destination UDP port range: 2001 - 3000 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.2 - 20.20.20.11 + - Destination IP address range: 10.10.10.2 - 10.10.10.11 + - Source UDP port range: 2001 - 3000 + - Destination UDP port range: 1001 - 2000 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.2" + self.p1_src_end_ip = u"10.10.10.11" + self.p1_dst_start_ip = u"20.20.20.2" + self.p1_dst_end_ip = u"20.20.20.11" + + self.p2_src_start_ip = u"20.20.20.2" + self.p2_src_end_ip = u"20.20.20.11" + self.p2_dst_start_ip = u"10.10.10.2" + self.p2_dst_end_ip = u"10.10.10.11" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1001 + self.p1_src_end_udp_port = 2000 + self.p1_dst_start_udp_port = 2001 + self.p1_dst_end_udp_port = 3000 + + self.p2_src_start_udp_port = 2001 + self.p2_src_end_udp_port = 3000 + self.p2_dst_start_udp_port = 1001 + self.p2_dst_end_udp_port = 2000 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple1_src" + ), + STLVmTupleGen( + ip_min=self.p1_dst_start_ip, + ip_max=self.p1_dst_end_ip, + port_min=self.p1_dst_start_udp_port, + port_max=self.p1_dst_end_udp_port, + name=u"tuple1_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p2_src_start_ip, + ip_max=self.p2_src_end_ip, + port_min=self.p2_src_start_udp_port, + port_max=self.p2_src_end_udp_port, + name=u"tuple2_src" + ), + STLVmTupleGen( + ip_min=self.p2_dst_start_ip, + ip_max=self.p2_dst_end_ip, + port_min=self.p2_dst_start_udp_port, + port_max=self.p2_dst_end_udp_port, + name=u"tuple2_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u10p-conc.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u10p-conc.py new file mode 100644 index 0000000000..29433b3d27 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u10p-conc.py @@ -0,0 +1,189 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 10.10.10.2 - 10.10.10.11 + - Destination IP address range: 20.20.20.2 - 20.20.2011 + - Source UDP port range: 1001 - 1010 + - Destination UDP port range: 2001 - 2010 + - Direction 1 --> 0: + - Source IP address range: 20.20.20.2 - 20.20.20.11 + - Destination IP address range: 10.10.10.2 - 10.10.10.11 + - Source UDP port range: 2001 - 2010 + - Destination UDP port range: 1001 - 1010 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.2" + self.p1_src_end_ip = u"10.10.10.11" + self.p1_dst_start_ip = u"20.20.20.2" + self.p1_dst_end_ip = u"20.20.20.11" + + self.p2_src_start_ip = u"20.20.20.2" + self.p2_src_end_ip = u"20.20.20.11" + self.p2_dst_start_ip = u"10.10.10.2" + self.p2_dst_end_ip = u"10.10.10.11" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1001 + self.p1_src_end_udp_port = 1010 + self.p1_dst_start_udp_port = 2001 + self.p1_dst_end_udp_port = 2010 + + self.p2_src_start_udp_port = 2001 + self.p2_src_end_udp_port = 2010 + self.p2_dst_start_udp_port = 1001 + self.p2_dst_end_udp_port = 1010 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple1_src" + ), + STLVmTupleGen( + ip_min=self.p1_dst_start_ip, + ip_max=self.p1_dst_end_ip, + port_min=self.p1_dst_start_udp_port, + port_max=self.p1_dst_end_udp_port, + name=u"tuple1_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple1_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p2_src_start_ip, + ip_max=self.p2_src_end_ip, + port_min=self.p2_src_start_udp_port, + port_max=self.p2_src_end_udp_port, + name=u"tuple2_src" + ), + STLVmTupleGen( + ip_min=self.p2_dst_start_ip, + ip_max=self.p2_dst_end_ip, + port_min=self.p2_dst_start_udp_port, + port_max=self.p2_dst_end_udp_port, + name=u"tuple2_dst" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.ip", + pkt_offset=u"IP.src" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.ip", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_src.port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"tuple2_dst.port", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u15p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u15p.py new file mode 100644 index 0000000000..57c5b2dcbc --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-10u15p.py @@ -0,0 +1,148 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 - 20.0.0.9 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 1173 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.0.9" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + #self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 1173 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple" + ), + STLVmWrFlowVar( + fv_name=u"tuple.ip", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple.port", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u15p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u15p.py new file mode 100644 index 0000000000..df9a1642a9 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u15p.py @@ -0,0 +1,141 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 1038 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.0.0" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 1038 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"sport", + min_value=self.p1_src_start_udp_port, + max_value=self.p1_src_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"sport", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u1p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u1p.py new file mode 100644 index 0000000000..a892ec8822 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-1u1p.py @@ -0,0 +1,104 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1028 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_ip = u"20.0.0.0" + self.p1_dst_ip = u"12.0.0.2" + + self.p2_src_ip = u"12.0.0.2" + self.p2_dst_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_udp_port = 1024 + self.p1_dst_udp_port = 1024 + + self.p2_src_udp_port = 1024 + self.p2_dst_udp_port = 1028 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_ip, + dst=self.p1_dst_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_udp_port, + dport=self.p1_dst_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_ip, + dst=self.p2_dst_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_udp_port, + dport=self.p2_dst_udp_port + ) + ) + + return base_pkt_a, base_pkt_b, None, None + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-2000u15p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-2000u15p.py new file mode 100644 index 0000000000..c96f76aaee --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-2000u15p.py @@ -0,0 +1,148 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 - 20.0.7.207 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 31022 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.7.207" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 31022 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple" + ), + STLVmWrFlowVar( + fv_name=u"tuple.ip", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple.port", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-4000u15p.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-4000u15p.py new file mode 100644 index 0000000000..c1b3d5ba59 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip4udp-4000u15p.py @@ -0,0 +1,148 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / UDP + - Direction 0 --> 1: + - Source IP address range: 20.0.0.0 - 20.0.15.159 + - Destination IP address range: 12.0.0.2 + - Source UDP port range: 1024 - 1038 + - Destination UDP port range: 1024 + - Direction 1 --> 0: + - Source IP address range: 12.0.0.2 + - Destination IP address range: 200.0.0.0 + - Source UDP port range: 1024 + - Destination UDP port range: 1024 - 61022 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"20.0.0.0" + self.p1_src_end_ip = u"20.0.15.159" + self.p1_dst_start_ip = u"12.0.0.2" + + self.p2_src_start_ip = u"12.0.0.2" + self.p2_src_end_ip = u"12.0.0.2" + self.p2_dst_start_ip = u"200.0.0.0" + + # UDP ports used in packet headers. + self.p1_src_start_udp_port = 1024 + self.p1_src_end_udp_port = 1038 + self.p1_dst_start_udp_port = 1024 + + self.p2_src_start_udp_port = 1024 + self.p2_dst_start_udp_port = 1024 + self.p2_dst_end_udp_port = 61022 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | UDP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p1_src_start_udp_port, + dport=self.p1_dst_start_udp_port + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=17 + ) / + UDP( + sport=self.p2_src_start_udp_port, + dport=self.p2_dst_start_udp_port + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmTupleGen( + ip_min=self.p1_src_start_ip, + ip_max=self.p1_src_end_ip, + port_min=self.p1_src_start_udp_port, + port_max=self.p1_src_end_udp_port, + name=u"tuple" + ), + STLVmWrFlowVar( + fv_name=u"tuple.ip", + pkt_offset=u"IP.src" + ), + STLVmFixIpv4( + offset=u"IP" + ), + STLVmWrFlowVar( + fv_name=u"tuple.port", + pkt_offset=u"UDP.sport" + ) + ] + ) + # Direction 0 --> 1 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"dport", + min_value=self.p2_dst_start_udp_port, + max_value=self.p2_dst_end_udp_port, + size=2, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"dport", + pkt_offset=u"UDP.dport" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst10000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst10000.py new file mode 100644 index 0000000000..f1b90350fb --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst10000.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::1 + - Destination IP address range: 2001:2::0 - 2001:2::270F + - Direction 1 --> 0: + - Source IP address range: 2001:2::1 + - Destination IP address range: 2001:1::0 - 2001:1::270F +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::1" + self.p1_dst_start_ip = u"2001:2::0" + self.p1_dst_end_ip = u"2001:2::270F" + + self.p2_src_start_ip = u"2001:2::1" + self.p2_dst_start_ip = u"2001:1::0" + self.p2_dst_end_ip = u"2001:1::270F" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_dst_start_ip, + self.p1_dst_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_dst_start_ip, + self.p2_dst_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst100000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst100000.py new file mode 100644 index 0000000000..87e76726b2 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst100000.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::1 + - Destination IP address range: 2001:2::0 - 2001:2::1:869F + - Direction 1 --> 0: + - Source IP address range: 2001:2::1 + - Destination IP address range: 2001:1::0 - 2001:1::1:869F +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::1" + self.p1_dst_start_ip = u"2001:2::0" + self.p1_dst_end_ip = u"2001:2::1:869F" + + self.p2_src_start_ip = u"2001:2::1" + self.p2_dst_start_ip = u"2001:1::0" + self.p2_dst_end_ip = u"2001:1::1:869F" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_dst_start_ip, + self.p1_dst_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_dst_start_ip, + self.p2_dst_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst1000000.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst1000000.py new file mode 100644 index 0000000000..c6870d89fa --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6dst1000000.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::1 + - Destination IP address range: 2001:2::0 - 2001:2::F:423F + - Direction 1 --> 0: + - Source IP address range: 2001:2::1 + - Destination IP address range: 2001:1::0 - 2001:1::F:423F +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::1" + self.p1_dst_start_ip = u"2001:2::0" + self.p1_dst_end_ip = u"2001:2::F:423F" + + self.p2_src_start_ip = u"2001:2::1" + self.p2_dst_start_ip = u"2001:1::0" + self.p2_dst_end_ip = u"2001:1::F:423F" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_dst_start_ip, + self.p1_dst_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_dst_start_ip, + self.p2_dst_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_dst", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_dst", + pkt_offset=u"IPv6.dst", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6src253.py b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6src253.py new file mode 100644 index 0000000000..fbe8b94ab3 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-3n-ethip6-ip6src253.py @@ -0,0 +1,129 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IPv6 / + - Direction 0 --> 1: + - Source IP address range: 2001:1::2 - 2001:1::FE + - Destination IP address range: 2001:2::2 + - Direction 1 --> 0: + - Source IP address range: 2001:2::2 - 2001:2::FE + - Destination IP address range: 2001:1::2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # IPs used in packet headers. + self.p1_src_start_ip = u"2001:1::2" + self.p1_src_end_ip = u"2001:1::FE" + self.p1_dst_start_ip = u"2001:2::2" + + self.p2_src_start_ip = u"2001:2::2" + self.p2_src_end_ip = u"2001:2::FE" + self.p2_dst_start_ip = u"2001:1::2" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IPv6 | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + base_p1, count_p1 = self._get_start_end_ipv6( + self.p1_src_start_ip, + self.p1_src_end_ip + ) + base_p2, count_p2 = self._get_start_end_ipv6( + self.p2_src_start_ip, + self.p2_src_end_ip + ) + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + IPv6( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + IPv6( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_src", + min_value=base_p1, + max_value=base_p1 + count_p1, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_src", + pkt_offset=u"IPv6.src", + offset_fixup=8 + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ipv6_src", + min_value=base_p2, + max_value=base_p2 + count_p2, + size=8, + op=u"inc" + ), + STLVmWrFlowVar( + fv_name=u"ipv6_src", + pkt_offset=u"IPv6.src", + offset_fixup=8 + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py new file mode 100644 index 0000000000..28ec10bf8b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254-bvi.py @@ -0,0 +1,170 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / + - Direction 0 --> 1: + - Destination MAC address: ba:dc:00:ff:ee:01 + - VLAN range: 100 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 - 20.20.20.254 + - Direction 1 --> 0: + - Destination MAC address: ba:dc:00:ff:ee:01 + - VLAN range: 200 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 - 10.10.10.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN IDs + self.p1_vlan_start = 100 + self.p2_vlan_start = 200 + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + + self.p1_dst_start_ip = u"20.20.20.1" + self.p1_dst_end_ip = u"20.20.20.254" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + + self.p2_dst_start_ip = u"10.10.10.1" + self.p2_dst_end_ip = u"10.10.10.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether( + dst=u"ba:dc:00:ff:ee:01" + ) / + Dot1Q( + vlan=self.p1_vlan_start + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether( + dst=u"ba:dc:00:ff:ee:01" + ) / + Dot1Q( + vlan=self.p2_vlan_start + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254.py new file mode 100644 index 0000000000..6ce351968c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4-vlan1ip4src254ip4dst254.py @@ -0,0 +1,164 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address range: 10.10.10.1 - 10.10.10.254 + - Destination IP address range: 20.20.20.1 - 20.20.20.254 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address range: 20.20.20.1 - 20.20.20.254 + - Destination IP address range: 10.10.10.1 - 10.10.10.254 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + # VLAN IDs + self.p1_vlan_start = 100 + self.p2_vlan_start = 200 + + # IPs used in packet headers. + self.p1_src_start_ip = u"10.10.10.1" + self.p1_src_end_ip = u"10.10.10.254" + + self.p1_dst_start_ip = u"20.20.20.1" + self.p1_dst_end_ip = u"20.20.20.254" + + self.p2_src_start_ip = u"20.20.20.1" + self.p2_src_end_ip = u"20.20.20.254" + + self.p2_dst_start_ip = u"10.10.10.1" + self.p2_dst_end_ip = u"10.10.10.254" + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether() / + Dot1Q( + vlan=self.p1_vlan_start + ) / + IP( + src=self.p1_src_start_ip, + dst=self.p1_dst_start_ip, + proto=61 + ) + ) + # Direction 1 --> 0 + base_pkt_b = ( + Ether() / + Dot1Q( + vlan=self.p2_vlan_start + ) / + IP( + src=self.p2_src_start_ip, + dst=self.p2_dst_start_ip, + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p1_src_start_ip, + max_value=self.p1_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p1_dst_start_ip, + max_value=self.p1_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"ip_src", + min_value=self.p2_src_start_ip, + max_value=self.p2_src_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_src", + pkt_offset=u"IP.src" + ), + STLVmFlowVar( + name=u"ip_dst", + min_value=self.p2_dst_start_ip, + max_value=self.p2_dst_end_ip, + size=4, + op=u"random" + ), + STLVmWrFlowVar( + fv_name=u"ip_dst", + pkt_offset=u"IP.dst" + ), + STLVmFixIpv4( + offset=u"IP" + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :returns: Traffic streams. + :rtype: Object + """ + return TrafficStreams() diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src10udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src10udpsrcrnd.py new file mode 100644 index 0000000000..32ca072154 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src10udpsrcrnd.py @@ -0,0 +1,287 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address: 172.17.[0..9].2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..9] + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].1 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address: 172.27.[0..9].2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..9] + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 10 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + Dot1Q( + vlan=100 + ) / + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + Dot1Q( + vlan=200 + ) / + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src1udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src1udpsrcrnd.py new file mode 100644 index 0000000000..1e78cd3cae --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src1udpsrcrnd.py @@ -0,0 +1,288 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address: 172.17.0.2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: 0 + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].1 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address: 172.27.0.2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: 0 + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks. +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 1 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + Dot1Q( + vlan=100 + ) / + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + Dot1Q( + vlan=200 + ) / + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src2udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src2udpsrcrnd.py new file mode 100644 index 0000000000..d195bc5b61 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src2udpsrcrnd.py @@ -0,0 +1,288 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address: 172.17.[0..1].2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..1] + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].1 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address: 172.27.[0..1].2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..1] + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 2 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + Dot1Q( + vlan=100 + ) / + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + Dot1Q( + vlan=200 + ) / + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src4udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src4udpsrcrnd.py new file mode 100644 index 0000000000..8a7bc08b1b --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src4udpsrcrnd.py @@ -0,0 +1,288 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address: 172.17.[0..3].2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..3] + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].1 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address: 172.27.[0..3].2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..3] + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 4 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + Dot1Q( + vlan=100 + )/ + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + Dot1Q( + vlan=200 + ) / + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src6udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src6udpsrcrnd.py new file mode 100644 index 0000000000..fe46844571 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src6udpsrcrnd.py @@ -0,0 +1,288 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address: 172.17.[0..5].2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..5] + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].1 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address: 172.27.[0..5].2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..5] + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 6 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + Dot1Q( + vlan=100 + ) / + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + Dot1Q( + vlan=200 + ) / + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src8udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src8udpsrcrnd.py new file mode 100644 index 0000000000..cf34818781 --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-dot1qip4vxlan-ip4src8udpsrcrnd.py @@ -0,0 +1,288 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / DOT1Q / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - VLAN range: 100 + - Source IP address: 172.17.[0..7].2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..7] + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].1 + - Direction 1 --> 0: + - VLAN range: 200 + - Source IP address: 172.27.[0..7].2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024..65535]) + - Destination UDP port: 4789 + - VXLAN VNI: [0..7] + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.[0..255].1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.[0..255].2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 8 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | DOT1Q | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + Dot1Q( + vlan=100 + ) / + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + Dot1Q( + vlan=200 + ) / + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=32 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=52 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=58 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=64 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=82 + ), + STLVmWrFlowVar( + fv_name=u"in_ip", + pkt_offset=86 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + diff --git a/GPL/traffic_profiles/trex/trex-sl-ethip4vxlan-ip4src1udpsrcrnd.py b/GPL/traffic_profiles/trex/trex-sl-ethip4vxlan-ip4src1udpsrcrnd.py new file mode 100644 index 0000000000..cd1a0a690c --- /dev/null +++ b/GPL/traffic_profiles/trex/trex-sl-ethip4vxlan-ip4src1udpsrcrnd.py @@ -0,0 +1,261 @@ +# Copyright (c) 2020 Cisco and/or its affiliates. +# 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. + +"""Stream profile for T-rex traffic generator. + +Stream profile: + - Two streams sent in directions 0 --> 1 and 1 --> 0 at the same time. + - Packet: ETH / IP / VXLAN / ETH / IP + - Direction 0 --> 1: + - Source IP address: 172.17.0.2 + - Destination IP address: 172.16.0.1 + - Source UDP port: random([1024-65535]) + - Destination UDP port: 4789 + - VXLAN VNI: 0 + - Payload source MAC address: 00:aa:aa:00:00:[00..ff] + - Payload source IP address: 10.0.0.2 + - Payload destination MAC address: 00:bb:bb:00:00:[00..ff] + - Payload destination IP address: 10.0.0.1 + - Direction 1 --> 0: + - Source IP address: 172.27.0.2 + - Destination IP address: 172.26.0.1 + - Source UDP port: random([1024-65535]) + - Destination UDP port: 4789 + - VXLAN VNI: 0 + - Payload source MAC address: 00:bb:bb:00:00:[00..ff] + - Payload source IP address: 10.0.0.1 + - Payload destination MAC address: 00:aa:aa:00:00:[00..ff] + - Payload destination IP address: 10.0.0.2 +""" + +from trex.stl.api import * +from profile_trex_stateless_base_class import TrafficStreamsBaseClass + +# RFC 7348 - Virtual eXtensible Local Area Network (VXLAN): +# A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks +# http://tools.ietf.org/html/rfc7348 +_VXLAN_FLAGS = list(u"R"*24 + u"RRRIRRRRR") + + +class VXLAN(Packet): + name=u"VXLAN" + fields_desc = [ + FlagsField(u"flags", 0x08000000, 32, _VXLAN_FLAGS), + ThreeBytesField(u"vni", 0), + XByteField(u"reserved", 0x00) + ] + + def mysummary(self): + return self.sprintf(u"VXLAN (vni=%VXLAN.vni%)") + + +bind_layers(UDP, VXLAN, dport=4789) +bind_layers(VXLAN, Ether) + + +class TrafficStreams(TrafficStreamsBaseClass): + """Stream profile.""" + + def __init__(self): + """Initialization and setting of streams' parameters.""" + + super(TrafficStreamsBaseClass, self).__init__() + + self.nf_chains = 1 + + def define_packets(self): + """Defines the packets to be sent from the traffic generator. + + Packet definition: | ETH | IP | VXLAN | ETH | IP + + :returns: Packets to be sent from the traffic generator. + :rtype: tuple + """ + + # Direction 0 --> 1 + base_pkt_a = ( + Ether()/ + IP( + src=u"172.17.0.2", + dst=u"172.16.0.1" + )/ + UDP( + sport=1024, + dport=4789)/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:aa:aa:00:00:00", + dst=u"00:bb:bb:00:00:00" + )/ + IP( + src=u"10.0.0.2", + dst=u"10.0.0.1", + proto=61 + ) + ) + + # Direction 1 --> 0 + base_pkt_b = ( + Ether()/ + IP( + src=u"172.27.0.2", + dst=u"172.26.0.1" + )/ + UDP( + sport=1024, + dport=4789 + )/ + VXLAN( + vni=0 + )/ + Ether( + src=u"00:bb:bb:00:00:00", + dst=u"00:aa:aa:00:00:00" + )/ + IP( + src=u"10.0.0.1", + dst=u"10.0.0.2", + proto=61 + ) + ) + + # Direction 0 --> 1 + vm1 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, + op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=28 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=48 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=54 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=60 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + # Direction 1 --> 0 + vm2 = STLScVmRaw( + [ + STLVmFlowVar( + name=u"nf_id", + size=1, + op=u"inc", + min_value=0, + max_value=self.nf_chains - 1 + ), + STLVmFlowVar( + name=u"in_mac", + size=2, op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"in_ip", + size=1, op=u"inc", + min_value=0, + max_value=255 + ), + STLVmFlowVar( + name=u"src_port", + size=2, + op=u"random", + min_value=1024, + max_value=65535 + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=28 + ), + STLVmWrFlowVar( + fv_name=u"src_port", + pkt_offset=u"UDP.sport" + ), + STLVmWrFlowVar( + fv_name=u"nf_id", + pkt_offset=48 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=54 + ), + STLVmWrFlowVar( + fv_name=u"in_mac", + pkt_offset=60 + ), + STLVmFixChecksumHw( + l3_offset="IP:{}".format(0), + l4_offset="UDP:{}".format(0), + l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP + ) + ] + ) + + return base_pkt_a, base_pkt_b, vm1, vm2 + +def register(): + """Register this traffic profile to T-rex. + + Do not change this function. + + :return: Traffic streams. + :rtype: Object + """ + return TrafficStreams() + -- cgit 1.2.3-korg