write a python program using the dkpt package to read a large pcapfile.
dpkt python package
Solution
//sample output
//copyable code
#python code
import dpkt
import socket
#display the pcap file
def print_Pcap(pcap):
for (ts1,buf1) in pcap:
try:
eth1 = dpkt.ethernet.Ethernet(buf1)
ip = eth1.data
# read source Ip address
sourcevalue = socket.inet_ntoa(ip.sourcevalue)
# read destination Ip address
destinationvalue = socket.inet_ntoa(ip.destinationvalue)
# Print Ip address
print ‘Source: ‘ +sourcevalue+ ‘ Destination: ‘+destinationvalue
except:
#pass the value
pass
#main function
def main():
# Open file
file1 =open(‘/home/code/Desktop/test.pcap’)
#pass