1 # Copyright 2016 Cisco Systems, Inc. All rights reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
17 class TrafficGeneratorException(Exception):
21 class AbstractTrafficGenerator(object):
23 # src_mac (6) + dst_mac (6) + mac_type (2) + frame_check (4) = 18
26 imix_l2_sizes = [64, 594, 1518]
27 imix_l3_sizes = [size - l2_header_size for size in imix_l2_sizes]
28 imix_ratios = [7, 4, 1]
29 imix_avg_l2_size = sum(map(
30 lambda imix: 1.0 * imix[0] * imix[1],
31 zip(imix_l2_sizes, imix_ratios))) / sum(imix_ratios)
33 def __init__(self, config):
38 # Must be implemented by sub classes
43 # Must be implemented by sub classes
48 # Must be implemented by sub classes
52 def config_interface():
53 # Must be implemented by sub classes
58 # Must be implemented by sub classes
63 # Must be implemented by sub classes
68 # Must be implemented by sub classes
73 # Must be implemented by sub classes
78 # Must be implemented by sub classes
83 # Must be implemented by sub classes
88 # Must be implemented by sub classes