Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from datthinh1801/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
datthinh1801 authored Jun 21, 2021
2 parents 416570e + abbff10 commit 44ab90d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy==1.18
scipy==1.4.1
scapy==2.4.3
numpy==1.19.5
scipy==1.6.0
scapy==2.4.5
requests
6 changes: 5 additions & 1 deletion src/cicflowmeter/features/context/packet_flow_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ def get_packet_flow_key(packet, direction) -> tuple:
if direction == PacketDirection.FORWARD:
dest_ip = packet["IP"].dst
src_ip = packet["IP"].src
dest_mac = packet["Ether"].dst
src_mac = packet["Ether"].src
src_port = packet[protocol].sport
dest_port = packet[protocol].dport
else:
dest_ip = packet["IP"].src
src_ip = packet["IP"].dst
dest_mac = packet["Ether"].src
src_mac = packet["Ether"].dst
src_port = packet[protocol].dport
dest_port = packet[protocol].sport

return dest_ip, src_ip, src_port, dest_port
return dest_ip, src_ip, src_port, dest_port, src_mac, dest_mac
4 changes: 4 additions & 0 deletions src/cicflowmeter/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(self, packet: Any, direction: Enum):
self.src_ip,
self.src_port,
self.dest_port,
self.src_mac,
self.dest_mac,
) = packet_flow_key.get_packet_flow_key(packet, direction)

self.packets = []
Expand Down Expand Up @@ -95,6 +97,8 @@ def get_data(self) -> dict:
"dst_ip": self.dest_ip,
"src_port": self.src_port,
"dst_port": self.dest_port,
"src_mac": self.src_mac,
"dst_mac": self.dest_mac,
"protocol": self.protocol,
# Basic information from packet times
"timestamp": packet_time.get_time_stamp(),
Expand Down
2 changes: 1 addition & 1 deletion src/cicflowmeter/flow_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def on_packet_received(self, packet):
break
elif "F" in str(packet.flags):
# If it has FIN flag then early collect flow and continue
flow.add_packet(packet.flags)
flow.add_packet(packet, direction)
self.garbage_collect(packet.time)
return

Expand Down

0 comments on commit 44ab90d

Please sign in to comment.