diff options
author | ahothan <ahothan@cisco.com> | 2018-04-24 10:06:34 -0700 |
---|---|---|
committer | ahothan <ahothan@cisco.com> | 2018-04-24 10:39:33 -0700 |
commit | ca854882fe536396857ca25e84d7f18ea769c595 (patch) | |
tree | 4070e998b598f6634d74a28d82a7a729b933360f /nfvbench/network.py | |
parent | 3918ebaca624bf6d58559d602eed8e33881e7ce0 (diff) |
[NFVBENCH-86] In case of lossy loopback device, packet drops are reported incorrectly1.4.0
This is only for fixed rate runs, the chain analysis table at end of run may contain
incorrect drops.
Change-Id: I6656528ed695a60003c672132624a7284db60497
Signed-off-by: ahothan <ahothan@cisco.com>
Diffstat (limited to 'nfvbench/network.py')
-rw-r--r-- | nfvbench/network.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/nfvbench/network.py b/nfvbench/network.py index e097c2b..6c02f04 100644 --- a/nfvbench/network.py +++ b/nfvbench/network.py @@ -15,8 +15,10 @@ class Interface(object): + """A class to hold the RX and TX counters for a virtual or physical interface.""" def __init__(self, name, device, tx_packets, rx_packets): + """Create a new interface instance.""" self.name = name self.device = device self.packets = { @@ -25,38 +27,65 @@ class Interface(object): } def set_packets(self, tx, rx): + """Set tx and rx counters for this interface.""" self.packets = { 'tx': tx, 'rx': rx } def set_packets_diff(self, tx, rx): + """Subtract current counters from new set of counters and update with results.""" self.packets = { 'tx': tx - self.packets['tx'], 'rx': rx - self.packets['rx'], } def is_no_op(self): + """Check if this interface is a no-opn interface.""" return self.name is None def get_packet_count(self, traffic_type): + """Get packet count for given direction.""" return self.packets.get(traffic_type, 0) @staticmethod def no_op(): + """Return an interface that doe snot pass any traffic.""" return Interface(None, None, 0, 0) class Network(object): + """This class holds all interfaces that make up a logical neutron network. + + A loopback packet path has exactly 2 networks. + The first interface is always one of the 2 traffic gen interface. + Subsequent interfaces are sorted along the path from the TG to the loopback point + which could be interfaces in a switch, a vswitch or a VM. + """ def __init__(self, interfaces=None, reverse=False): + """Create a network with initial interface list and direction. + + :param interfaces: initial interface list + :param reverse: specifies the order of interfaces returned by get_interfaces + """ if interfaces is None: interfaces = [] self.interfaces = interfaces self.reverse = reverse def add_interface(self, interface): + """Add one more interface to this network. + + Order if important as interfaces must be added from traffic generator ports towards then + looping back device. + """ self.interfaces.append(interface) def get_interfaces(self): + """Get interfaces associated to this network. + + Returned interface list is ordered from traffic generator port towards looping device if + reverse is false. Else returms the list in the reverse order. + """ return self.interfaces[::-1] if self.reverse else self.interfaces |