Merge "test_spec: LTD: MatchAction Performance testing"
[vswitchperf.git] / tools / pkt_gen / ixia / pass_fail.tcl
index 63d4d91..79b7f10 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env tclsh
 
 # Copyright (c) 2014, Ixia
-# Copyright (c) 2015, Intel Corporation
+# Copyright (c) 2015-2016, Intel Corporation
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -213,14 +213,14 @@ proc sendTraffic { flowSpec trafficSpec } {
     # Parameters:
     #   flowSpec - a dict detailing how the packet should be sent. Should be
     #     of format:
-    #         {type, numpkts, time, framerate}
+    #         {type, numpkts, duration, framerate}
     #   trafficSpec - a dict describing the packet to be sent. Should be
     #     of format:
     #         { l2, vlan, l3}
     #     where each item is in turn a dict detailing the configuration of each
     #     layer of the packet
     # Returns:
-    #   Output from Rx end of Ixia if time != 0, else 0
+    #   Output from Rx end of Ixia if duration != 0, else 0
 
     ##################################################
     ################# Initialisation #################
@@ -238,7 +238,7 @@ proc sendTraffic { flowSpec trafficSpec } {
 
     set streamType              [dict get $flowSpec type]
     set numPkts                 [dict get $flowSpec numpkts]
-    set time                    [expr {[dict get $flowSpec time] * 1000}]
+    set duration                [expr {[dict get $flowSpec duration] * 1000}]
     set frameRate               [dict get $flowSpec framerate]
 
     # traffic spec
@@ -246,18 +246,24 @@ proc sendTraffic { flowSpec trafficSpec } {
     # extract nested dictionaries
     set trafficSpec_l2          [dict get $trafficSpec l2]
     set trafficSpec_l3          [dict get $trafficSpec l3]
+    set trafficSpec_l4          [dict get $trafficSpec l4]
     set trafficSpec_vlan        [dict get $trafficSpec vlan]
 
     set frameSize               [dict get $trafficSpec_l2 framesize]
     set srcMac                  [dict get $trafficSpec_l2 srcmac]
     set dstMac                  [dict get $trafficSpec_l2 dstmac]
-    set srcPort                 [dict get $trafficSpec_l2 srcport]
-    set dstPort                 [dict get $trafficSpec_l2 dstport]
+    set srcPort                 [dict get $trafficSpec_l4 srcport]
+    set dstPort                 [dict get $trafficSpec_l4 dstport]
 
     set proto                   [dict get $trafficSpec_l3 proto]
     set srcIp                   [dict get $trafficSpec_l3 srcip]
     set dstIp                   [dict get $trafficSpec_l3 dstip]
 
+    if {[dict exists $trafficSpec_l3 protocolpadbytes]} {
+        set protocolPad             [dict get $trafficSpec_l4 protocolpad]
+        set protocolPadBytes        [dict get $trafficSpec_l4 protocolpadbytes]
+    }
+
     set vlanEnabled             [dict get $trafficSpec_vlan enabled]
     if {$vlanEnabled == 1 } {
         # these keys won't exist if vlan wasn't enabled
@@ -306,6 +312,10 @@ proc sendTraffic { flowSpec trafficSpec } {
         protocol config -enable802dot1qTag            vlanSingle
     }
 
+    if {[info exists protocolPad]} {
+        protocol config -enableProtocolPad                $protocolPad
+    }
+
     ip setDefault
     ip config -ipProtocol                             ipV4Protocol[string totitle $proto]
     ip config -checksum                               "f6 75"
@@ -328,6 +338,26 @@ proc sendTraffic { flowSpec trafficSpec } {
         errorMsg "Error calling $proto set $::chassis $::card $::port"
     }
 
+    if {[info exists protocolPad]} {
+        protocolPad setDefault
+        # VxLAN header with VNI 99 (0x63)
+        # Inner SRC 01:02:03:04:05:06
+        # Inner DST 06:05:04:03:02:01
+        # IP SRC 192.168.0.2
+        # IP DST 192.168.240.9
+        # SRC port 3000 (0x0BB8)
+        # DST port 3001 (0x0BB9)
+        # length 26
+        # UDP Checksum 0x2E93
+
+        # From encap case capture
+        protocolPad config -dataBytes "$protocolPadBytes"
+        if {[protocolPad set $::chassis $::card $::port1]} {
+            errorMsg "Error calling protocolPad set $::chassis $::card $::port"
+            set retCode $::TCL_ERROR
+        }
+    }
+
     if {$vlanEnabled == 1 } {
         vlan setDefault
         vlan config -vlanID                               $vlanId
@@ -392,9 +422,15 @@ proc sendTraffic { flowSpec trafficSpec } {
         udp setDefault
         udp config -sourcePort                            $srcPort
         udp config -destPort                              $dstPort
+        set packetSize               [dict get $trafficSpec_l3 packetsize]
+        stream config -framesize                          $packetSize
         if {[udp set $::chassis $::card $::port1]} {
             errorMsg "Error setting udp on port $::chassis.$::card.$::port1"
         }
+        errorMsg "frameSize: $frameSize, packetSize: $packetSize, srcMac: $srcMac, dstMac: $dstMac, srcPort: $srcPort, dstPort: $dstPort"
+        if {[info exists protocolPad]} {
+            errorMsg "protocolPad: $protocolPad, protocolPadBytes: $protocolPadBytes"
+        }
     }
 
     if {[stream set $::chassis $::card $::port1 $streamId]} {
@@ -427,18 +463,18 @@ proc sendTraffic { flowSpec trafficSpec } {
     logMsg "Starting transmit on port $::port1"
     ixStartPortTransmit $::chassis $::card $::port1
 
-    # If time=0 is passed, exit after starting transmit
+    # If duration=0 is passed, exit after starting transmit
 
-    if {$time == 0} {
+    if {$duration == 0} {
         logMsg "Sending traffic until interrupted"
         return
     }
 
-    logMsg "Waiting for $time ms"
+    logMsg "Waiting for $duration ms"
 
-    # Wait for time - 1 second to get traffic rate
+    # Wait for duration - 1 second to get traffic rate
 
-    after [expr "$time - 1"]
+    after [expr "$duration - 1"]
 
     # Get result
 
@@ -639,7 +675,10 @@ proc rfcThroughputTest { testSpec trafficSpec } {
 
     # testSpec
 
-    set numTrials               [dict get $testSpec trials]  ;# we don't use this yet
+    # RFC2544 to IXIA terminology mapping (it affects Ixia configuration below):
+    # Test    => Trial
+    # Trial   => Iteration
+    set numTrials               [dict get $testSpec tests]  ;# we don't use this yet
     set duration                [dict get $testSpec duration]
     set lossRate                [dict get $testSpec lossrate]
     set multipleStream          [dict get $testSpec multipleStreams]  ;# we don't use this yet
@@ -668,7 +707,7 @@ proc rfcThroughputTest { testSpec trafficSpec } {
     for {set i 0} {$i < 20} {incr i} {
         dict set flowSpec type                        "contPacket"
         dict set flowSpec numpkts                     100 ;# this can be bypassed
-        dict set flowSpec time                        $duration
+        dict set flowSpec duration                    $duration
         dict set flowSpec framerate                   $percentRate
 
         set flowStats [sendTraffic $flowSpec $trafficSpec]