intracom-telecom-sdn / oftraf

pcap-based, RESTful OpenFlow traffic monitor
Eclipse Public License 1.0
6 stars 1 forks source link

Handle malformed packets #1

Closed pavlosantoniou closed 9 years ago

pavlosantoniou commented 9 years ago

Under load, the probability of a malformed packet becomes non-trivial. The oftraf tool needs to somehow handle these malformed packets, or else exceptions are thrown and the program execution stops.

A packet may be malformed at the transport layer, in which case exceptions such as the below are thrown:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "oftraf.py", line 135, in of_sniff
if tcp.dport == int(ofport):
AttributeError: 'str' object has no attribute 'dport' 

A packet may also be malformed at the application layer, in which case exceptions such as the below are thrown:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "oftraf.py", line 151, in of_sniff
if not of13_types[of_type] in of13_counts:
KeyError: '\xe3'

With this commit, the packet processing stops when the packet is detected to be malformed. A relevant counter is also stepped. We can discuss whether we wish to print these new counters.