I am combining Scapy with Volttron and I want to publish to a topic when a packet comes in and has certain features. However, I keep running into this error:
Traceback (most recent call last): File "sniff.py", line 373, in sys.exit(main()) File "sniff.py", line 342, in main utils.vip_main(sniffer, version=version) File "/home/jenny/workspace/volttron/volttron/platform/agent/utils.py",
line 314, in vip_main version=version, **kwargs) File "sniff.py", line 336, in sniffer Sniffer(**kwargs) File "sniff.py", line 138, in init self.vip.pubsub.publish('pubsub', "some/topic", message="blah")
File "/home/jenny/workspace/volttron/volttron/platform/vip/agent/subsystems/pubsub.py",line 602, in publish self._save_parameters(result.ident, **kwargs)
File "/home/jenny/workspace/volttron/volttron/platform/vip/agent/subsystems/pubsub.py", line 706, in _save_parameters event = self.core().schedule(end_time, self._cancel_event, result_id)
File "/home/jenny/workspace/volttron/volttron/platform/vip/agent/core.py", line 409, in schedule self._schedule_callback(deadline, event) File "/home/jenny/workspace/volttron/volttron/platform/vip/agent/core.py", line 417, in _schedule_callback self._schedule_event.set()AttributeError: 'NoneType' object has no attribute 'set'
The closest to a solution I found is here RPC crashes with AttributeError: 'NoneType' object has no attribute 'call'. However, I notice they aren't exactly the same issue and so there isn't much surprise when I tried the solution offered there and it didn't work for me.
My code looks like this:
def sniffer(config_path, **kwargs):
''' Initializations '''
global pkt_counter
global IP_counter
# Defined other parameters here
class Sniffer(Agent):
def __init__(self, **kwargs):
super(Sniffer, self).__init__(**kwargs)
# I am just testing the publish function here
self.vip.pubsub.publish('pubsub', "some/topic", message="blah")
sniff(count=0, iface=conf.iface, prn = self.pkt_action, store=0)
def pkt_action(self, pkt):
#Process every packet, updates values and rises and alert if necessary
# some checks are run here and later a publish is called
Can someone please let me know what I'm doing wrong?
Edit: I didn't add that I want to run this script as I would a simple python script on the terminal (eg. python somescript.py): no installation. The reason I'm trying to do this is that I get an error when I install the agent and start it. The platform doesn't allow Scapy to create and connect to sockets.