@@ -67,9 +67,10 @@ def static_fwding_cycle_3_3():
67
67
68
68
class QueryTest (CountBucket ):
69
69
70
- def __init__ (self ):
70
+ def __init__ (self , test_num = None ):
71
71
super (QueryTest , self ).__init__ ()
72
72
self .register_callback (self .query_callback )
73
+ self .test_num = test_num if test_num else id (self )
73
74
import threading
74
75
self .query_thread = threading .Thread (target = self .query_thread )
75
76
self .query_thread .daemon = True
@@ -84,14 +85,14 @@ def query_thread(self):
84
85
output += self .get_matches ()
85
86
# print output
86
87
self .pull_stats ()
87
- print ">>>" , str (datetime .now ()), ('issued query %d , sleeping for %f' %
88
- (id (self ), interval ))
88
+ print ">>>" , str (datetime .now ()), ('issued query %s , sleeping for %f' %
89
+ (str (self . test_num ), interval ))
89
90
time .sleep (interval )
90
91
91
92
def query_callback (self , counts ):
92
93
print "***" , str (datetime .now ()), "| In user callback for bucket" ,
93
- print id ( self )
94
- print "Bucket" , id ( self ) , "(packet, byte) counts:" , counts
94
+ print self . test_num
95
+ print "Bucket" , self . test_num , "(packet, byte) counts:" , counts
95
96
print "-----------------------------------"
96
97
97
98
def test0 ():
@@ -112,7 +113,7 @@ def test0():
112
113
number of packets/bytes displayed by wireshark or tshark with these
113
114
filters. They are designed to work under topology and policy updates.
114
115
"""
115
- test_bucket = QueryTest ()
116
+ test_bucket = QueryTest (0 )
116
117
return test_bucket
117
118
118
119
def test1 ():
@@ -127,7 +128,7 @@ def test1():
127
128
arp.dst.proto_ipv4 == 10.0.2.0/24) ) or ipv6 ) ) and ( ip.src ==
128
129
10.0.0.1 || (arp && arp.src.proto_ipv4 == 10.0.0.1) )
129
130
"""
130
- test_bucket = QueryTest ()
131
+ test_bucket = QueryTest (1 )
131
132
return (match (srcip = ip1 ) >> test_bucket )
132
133
133
134
def test2 ():
@@ -153,7 +154,7 @@ def test2():
153
154
"""
154
155
b = [] # counting buckets
155
156
for i in range (0 ,2 ):
156
- b .append (QueryTest ())
157
+ b .append (QueryTest ('2.b%d' % i ))
157
158
time .sleep (0.2 )
158
159
159
160
pol1 = (match (ethtype = IP_TYPE ) & match (srcip = ip1 )) >> b [0 ]
@@ -186,7 +187,7 @@ def test3():
186
187
"""
187
188
b = [] # counting buckets
188
189
for i in range (0 ,2 ):
189
- b .append (QueryTest ())
190
+ b .append (QueryTest ('3.b%d' % i ))
190
191
time .sleep (0.2 )
191
192
192
193
pol1 = match (srcip = ip1 ) >> b [0 ]
@@ -221,7 +222,7 @@ def test4():
221
222
"""
222
223
b = [] # counting buckets
223
224
for i in range (0 ,3 ):
224
- b .append (QueryTest ())
225
+ b .append (QueryTest ('4.b%d' % i ))
225
226
time .sleep (0.2 )
226
227
227
228
query1 = match (srcip = ip1 ) >> match (dstip = ip2 ) >> b [0 ]
@@ -245,7 +246,7 @@ def test5():
245
246
(arp.dst.proto_ipv4 == 10.0.0.1 || arp.dst.proto_ipv4 == 10.0.0.2 ||
246
247
arp.dst.proto_ipv4 == 10.0.0.3) ) )
247
248
"""
248
- test_bucket = QueryTest ()
249
+ test_bucket = QueryTest (5 )
249
250
matched_traffic = ( (~ match (srcip = ip1 ) & match (dstip = ip2 )) +
250
251
(~ match (srcip = ip1 ) & match (dstip = ip3 )) +
251
252
(~ match (srcip = ip1 ) & match (dstip = ip1 )) )
@@ -264,7 +265,7 @@ def test6():
264
265
( (ip && ip.src == 10.0.0.1 ) or (arp && arp.src.proto_ipv4 == 10.0.0.1) or
265
266
ipv6))
266
267
"""
267
- test_bucket = QueryTest ()
268
+ test_bucket = QueryTest (6 )
268
269
matched_traffic = ~ match (srcip = ip1 )
269
270
return (matched_traffic >> test_bucket )
270
271
@@ -280,7 +281,7 @@ def test7():
280
281
arp.dst.proto_ipv4 == 10.0.2.0/24) ) or ipv6 ) ) and (ip.dst == 10.0.0.1 ||
281
282
(arp && (arp.dst.proto_ipv4 == 10.0.0.1 ) ) )
282
283
"""
283
- return ( (match (dstip = ip1 ) >> QueryTest ()) +
284
+ return ( (match (dstip = ip1 ) >> QueryTest (7 )) +
284
285
(match (dstip = ip1 ) >> Controller ) )
285
286
286
287
def parse_args (kwargs , defaults ):
0 commit comments