t = sniff(iface=your_iface, count=1, filter="udp and host 10.220.64.207 and port 49153") # lfilter=lambda x: x.haslayer(UDP)) # and x[IP].src == broad_ip) t[0].show() # print (len(t[0].load)) # print (len(t[0][UDP])) # print (len(t[0][IP])) # print (len(t[0][Ether])) # print (type(t)) g = goose.GOOSE(t[0].load) pl1 = t[0].load[:39] # print (type(pl1)) # print (repr(g.load)) gpdu = goose.GOOSEPDU(g.load[31:]) print("The R-GOOSE payload is decoded as- ") print(gpdu.__dict__) try: stnum = gpdu.__dict__['stNum'].data except Exception as e: print("************************************") print() print(" DECODING ERROR") print() print("Key not found : ", e) print() print("************************************") stnum = gpdu.__dict__['stNum'].data if (stnum != prev_stnum):
from scapy.all import * import goose a = rdpcap("wireshark2.pcap") for i in a: try: if i.type == 0x88b8: g = goose.GOOSE(i.load) print repr(g.load) gpdu = goose.GOOSEPDU(g.load[4:]) print gpdu.__dict__ except AttributeError: continue