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

Commit 44ab90d

Browse files
authored
Merge pull request #1 from datthinh1801/dev
Dev
2 parents 416570e + abbff10 commit 44ab90d

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
numpy==1.18
2-
scipy==1.4.1
3-
scapy==2.4.3
1+
numpy==1.19.5
2+
scipy==1.6.0
3+
scapy==2.4.5
44
requests

src/cicflowmeter/features/context/packet_flow_key.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ def get_packet_flow_key(packet, direction) -> tuple:
3434
if direction == PacketDirection.FORWARD:
3535
dest_ip = packet["IP"].dst
3636
src_ip = packet["IP"].src
37+
dest_mac = packet["Ether"].dst
38+
src_mac = packet["Ether"].src
3739
src_port = packet[protocol].sport
3840
dest_port = packet[protocol].dport
3941
else:
4042
dest_ip = packet["IP"].src
4143
src_ip = packet["IP"].dst
44+
dest_mac = packet["Ether"].src
45+
src_mac = packet["Ether"].dst
4246
src_port = packet[protocol].dport
4347
dest_port = packet[protocol].sport
4448

45-
return dest_ip, src_ip, src_port, dest_port
49+
return dest_ip, src_ip, src_port, dest_port, src_mac, dest_mac

src/cicflowmeter/flow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def __init__(self, packet: Any, direction: Enum):
2828
self.src_ip,
2929
self.src_port,
3030
self.dest_port,
31+
self.src_mac,
32+
self.dest_mac,
3133
) = packet_flow_key.get_packet_flow_key(packet, direction)
3234

3335
self.packets = []
@@ -95,6 +97,8 @@ def get_data(self) -> dict:
9597
"dst_ip": self.dest_ip,
9698
"src_port": self.src_port,
9799
"dst_port": self.dest_port,
100+
"src_mac": self.src_mac,
101+
"dst_mac": self.dest_mac,
98102
"protocol": self.protocol,
99103
# Basic information from packet times
100104
"timestamp": packet_time.get_time_stamp(),

src/cicflowmeter/flow_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def on_packet_received(self, packet):
8383
break
8484
elif "F" in str(packet.flags):
8585
# If it has FIN flag then early collect flow and continue
86-
flow.add_packet(packet.flags)
86+
flow.add_packet(packet, direction)
8787
self.garbage_collect(packet.time)
8888
return
8989

0 commit comments

Comments
 (0)