#!/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
# 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 #################
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
# 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
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"
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
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]} {
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
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]