class STLRxStats(object):
def __init__ (self, user_id):
self.fields = {}
- self.fields['stream_id'] = user_id
- self.fields['enabled'] = True
- self.fields['seq_enabled'] = False
+
+ self.fields['enabled'] = True
+ self.fields['stream_id'] = user_id
+ self.fields['seq_enabled'] = False
self.fields['latency_enabled'] = False
+
def to_json (self):
return dict(self.fields)
def __parse_mode (self, mode_obj):
+ if not mode_obj:
+ return None
rate_parser = set(mode_obj).intersection(['pps', 'bps_L1', 'bps_L2', 'percentage'])
if len(rate_parser) != 1:
+ def __parse_rx_stats (self, rx_stats_obj):
+
+ # no such object
+ if not rx_stats_obj or rx_stats_obj.get('enabled') == False:
+ return None
+
+ user_id = rx_stats_obj.get('stream_id')
+ if user_id == None:
+ raise STLError("enabled RX stats section must contain 'stream_id' field")
+
+ return STLRxStats(user_id = user_id)
+
def __parse_stream (self, yaml_object):
s_obj = yaml_object['stream']
# mode
- mode_obj = s_obj.get('mode')
- if not mode_obj:
- raise STLError("YAML file must contain 'mode' field")
-
- mode = self.__parse_mode(mode_obj)
+ mode = self.__parse_mode(s_obj.get('mode'))
+ # rx stats
+ rx_stats = self.__parse_rx_stats(s_obj.get('rx_stats'))
- defaults = STLStream()
+ defaults = STLStream()
# create the stream
stream = STLStream(name = yaml_object.get('name'),
packet = builder,
mode = mode,
+ rx_stats = rx_stats,
enabled = s_obj.get('enabled', defaults.fields['enabled']),
self_start = s_obj.get('self_start', defaults.fields['self_start']),
isg = s_obj.get('isg', defaults.fields['isg']),
- rx_stats = s_obj.get('rx_stats', defaults.fields['rx_stats']),
next = yaml_object.get('next'),
action_count = s_obj.get('action_count', defaults.fields['action_count']),
mac_src_override_by_pkt = s_obj.get('mac_src_override_by_pkt', 0),
}
/**
- * copy instructions from this VM to 'other'
+ * clone VM from this VM to 'other'
*
* @author imarom (22-Dec-15)
*
* @param other
*/
void
-StreamVm::copy_instructions(StreamVm &other) const {
+StreamVm::clone(StreamVm &other) const {
/* clear previous if any exists */
for (auto instr : other.m_inst_list) {
delete instr;
for (auto instr : m_inst_list) {
StreamVmInstruction *new_instr = instr->clone();
+
other.m_inst_list.push_back(new_instr);
/* for the split instruction - find the right one */
}
}
+ other.m_is_random_var = m_is_random_var;
}
/**
StreamVm dummy;
- this->copy_instructions(dummy);
+ this->clone(dummy);
dummy.compile(regular_pkt_size);
assert(dummy.m_expected_pkt_size != 0);