Minor updates for pkt in monitoring
Response to comment for rename of packet count
Clarified periodic_task name
Indentation
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index 404b185..935adce 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -697,10 +697,10 @@
Clear the input queue and report the number of messages
that were in it
"""
- enqueued_pkts = len(self.packets)
+ enqueued_pkt_count = len(self.packets)
with self.packets_cv:
self.packets = []
- return enqueued_pkts
+ return enqueued_pkt_count
def __str__(self):
string = "Controller:\n"
diff --git a/tests/cxn.py b/tests/cxn.py
index 13a9771..d1f5db8 100644
--- a/tests/cxn.py
+++ b/tests/cxn.py
@@ -139,7 +139,7 @@
self.report_pkts = report_pkts
# These functions provide per-tick processing
- def periodic_init(self, tick_time):
+ def periodic_task_init(self, tick_time):
"""
Assumes tick_time is in seconds, usually 1/10 of a sec
"""
@@ -150,7 +150,7 @@
self.pkt_in_count = 0 # Total packet in count
self.periodic_pkt_in_count = 0 # Packet-ins this cycle
- def periodic_tick(self, con):
+ def periodic_task_tick(self, con):
"""
Process one tick. Currently this just counts pkt-in msgs
"""
@@ -158,25 +158,25 @@
return
if con.cstate != 4:
return
- if self.report_pkts:
- # Gather packets from control cxn
- current_time = time.time()
- new_pkts = con.packet_in_count - self.pkt_in_count
- self.pkt_in_count = con.packet_in_count
- self.periodic_pkt_in_count += new_pkts
- con.clear_queue()
- # Report every second or so
- if (current_time - self.last_report >= 1):
- if self.periodic_pkt_in_count:
- print "%7.2f: pkt/sec last period: %6d. Total %10d." % (
- current_time - self.start_time,
- self.periodic_pkt_in_count/(current_time - self.last_report),
- self.pkt_in_count)
- self.last_report = current_time
- self.periodic_pkt_in_count = 0
+ # Gather packets from control cxn
+ current_time = time.time()
+ new_pkts = con.packet_in_count - self.pkt_in_count
+ self.pkt_in_count = con.packet_in_count
+ self.periodic_pkt_in_count += new_pkts
+ con.clear_queue()
- def periodic_done(self):
+ # Report every second or so
+ if (current_time - self.last_report >= 1):
+ if self.periodic_pkt_in_count:
+ print "%7.2f: pkt/sec last period: %6d. Total %10d." % (
+ current_time - self.start_time,
+ self.periodic_pkt_in_count/(current_time - self.last_report),
+ self.pkt_in_count)
+ self.last_report = current_time
+ self.periodic_pkt_in_count = 0
+
+ def periodic_task_done(self):
if not self.report_pkts:
return
print "Received %d pkt-ins over %d seconds" % (
@@ -190,7 +190,7 @@
self.controllers[i].keep_alive = self.keep_alive
self.controllers[i].saved_switch_addr = None
tick = 0.1 # time period in seconds at which controllers are handled
- self.periodic_init(tick)
+ self.periodic_task_init(tick)
disconnected_count = 0
cycle = 0
@@ -269,7 +269,7 @@
con.cstate = 0
states.append(con.cstate)
- self.periodic_tick(con)
+ self.periodic_task_tick(con)
logging.debug("Cycle " + str(cycle) +
", states " + str(states) +
@@ -289,7 +289,7 @@
if cycle > self.cxn_cycles:
break
time.sleep(tick)
- self.periodic_done()
+ self.periodic_task_done()
@disabled
class HandshakeAndKeepalive(CompleteHandshake):