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
15 from nfvbench.log import LOG
17 from traffic_base import AbstractTrafficGenerator
18 import traffic_utils as utils
22 class DummyTG(AbstractTrafficGenerator):
23 """Experimental dummy traffic generator.
25 This traffic generator will pretend to generate traffic and return fake data.
26 Useful for unit testing without actually generating any traffic.
29 def __init__(self, runner):
30 AbstractTrafficGenerator.__init__(self, runner)
34 def get_version(self):
41 ports = list(self.config.generator_config.ports)
42 self.port_handle = ports
44 def is_arp_successful(self):
47 def config_interface(self):
50 def create_traffic(self, l2frame_size, rates, bidirectional, latency=True):
53 def modify_rate(self, rate, reverse):
54 port_index = int(reverse)
55 port = self.port_handle[port_index]
56 self.rates[port_index] = utils.to_rate_str(rate)
57 LOG.info('Modified traffic stream for %s, new rate=%s.' % (port, utils.to_rate_str(rate)))
59 def clear_streamblock(self):
64 for ph in self.port_handle:
68 'total_pkt_bytes': 100000,
70 'pkt_bit_rate': 1000000
74 'total_pkt_bytes': 100000,
76 'pkt_bit_rate': 1000000,
80 result[ph]['rx']['max_delay_usec'] = 10.0
81 result[ph]['rx']['min_delay_usec'] = 1.0
82 result[ph]['rx']['avg_delay_usec'] = 2.0
85 def clear_stats(self):
88 def start_traffic(self):
91 def stop_traffic(self):