Based on your comments and sample provided, I woud summary/rephrase your question as:
How to create a Machine Learning model to classify Network Traffic?
The samples you have provided, suggest in general at least two possible approaches, one similar to Text Classification and the other like any generic supervised learning example.
The samples show as a function of time, the various packets to and from a destination, which may not be the same length or duration (i.e. the number of captured packets could vary). Both approaches require an input (typically referred to as features) and an output (typically called a target).
The first step is to organise the data such that one file/entry/capture containing multiple packets maps to a single classification label. Network traffic captured using wireshark
, or tcpdump
or similar tools use line breaks to denote different packets. These can be difficult to process for most ML frameworks so in the first instance these can be removed or replaced with something else. An example output may look the following:
Input |
Output |
1 0.000 192.168.0.5 192.168.0.2 HTTP 250 Get /HTTP/1.1 .... |
Social Media |
1 0.000 192.168.0.5 192.168.0.2 HTTP 250 Get /HTTP/1.1 .... |
Streaming Video |
Once data is in this format you can probably follow a Text Classification type approach 1. You need to be careful how these "words" are translated to the ML model itself. Most ML models can't read, so need to text to translated to numbers a process of vectorisation or tokenisation. You need to be careful of using some methods in Natural Language Processing (NLP) as they use existing models to map words to numbers. In your case, HTTP
, TCP
etc are not typically used in natural languages and may have no mapping 2.
I believe this answers your question.
However, as a Subject Matter Expert (SME) in network traffic, you may identify aspects in the data that you feel are important in classifying it. For example:
- Does the actual source and destination IP influence the classification? If not, you might to replace it with perhaps a direction or replace the IP addresses with the text "src" and "dest" instead.
- Does the sequence number matter?
- Does how long something took to respond a factor?
- If a HTTP Code is received, does that a have strong influence on the outcome?
If so, you could add them as extra columns e.g.
Traffic |
HTTP Code |
Output |
1 0.000 192.168.0.5 192.168.0.2 HTTP 250 Get /HTTP/1.1 .... |
200 |
Social Media |
1 0.000 192.168.0.5 192.168.0.2 HTTP 250 Get /HTTP/1.1 .... |
400 |
Streaming Video |
The idea of manipulating the input data to help the model is called feature engineering.
Based on my experience, using raw network traffic is likely to cause most ML models problems, without some modification or feature extraction.