← Open Source
linwhitehat

ET-BERT

The repository of ET-BERT, a network traffic classification model on encrypted traffic. The work has been accepted as The Web Conference (WWW) 2022 accepted paper.

Model DevelopmentDomain-specific trainingPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
679
Stars
131
Forks
+-1
This week
1
Contributors
Created 2022-02-09 · Updated 2026-10-16 · #15104 today
Top developers

linwhitehat/ET-BERT is ranked 15,104 with 679 stars.

Same-category comparison

linwhitehat/ET-BERT is ranked 15,104 among these 8 peers; OpenDriveLab/OpenLane-V2 is ranked 15,105.

Same-category comparison
NameRankMetrics
cmusphinx/g2p-seq2seq15,090
Language:
Python
Stars:
680
Forks:
190
Description:
G2P with Tensorflow.
ShannonAI/mrc-for-flat-nested-ner15,098
Language:
Python
Stars:
679
Forks:
118
Description:
Code for ACL 2020 paper `A Unified MRC Framework for Named Entity Recognition`.
WillianFuks/tfcausalimpact15,099
Language:
Python
Stars:
679
Forks:
75
Description:
Python Causal Impact Implementation Based on Google's R Package. Built using TensorFlow Probability.
daiquocnguyen/Graph-Transformer15,100
Language:
Python
Stars:
679
Forks:
74
Description:
Universal Graph Transformer Self-Attention Networks (TheWebConf WWW 2022) (Pytorch and Tensorflow).
OpenDriveLab/OpenLane-V215,105
Language:
Jupyter Notebook
Stars:
678
Forks:
78
Description:
[NeurIPS 2023 Track Datasets and Benchmarks] OpenLane-V2: The First Perception and Reasoning Benchmark for Road Driving.
skumra/robotic-grasping15,120
Language:
Python
Stars:
678
Forks:
151
Description:
Antipodal Robotic Grasping using GR-ConvNet. IROS 2020.
EmuKit/emukit15,122
Language:
Python
Stars:
677
Forks:
135
Description:
A Python-based toolbox of various methods in decision making, uncertainty quantification and statistical emulation: multi-fidelity, experimental design, Bayesian optimisation, Bayesian quadrature, etc.
TalkingData/Fregata15,126
Language:
Scala
Stars:
677
Forks:
182
Description:
A light weight, super fast, large scale machine learning library on spark .
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryDomain-specific training
KeywordsSecurity
Stars679
Forks131
Contributors1
Created date2022-02-09
Updated date2026-10-16
Stars in 1 day0
Stars in 7 days-1
Rank15,104
Previous rank14,931
Rank change-173
7-day stars rank17,728
Previous 7-day stars rank17,682
7-day stars rank change-46
Total stars rank15,235
Previous total stars rank15,210
Total stars rank change-25
CountryChina
README summary

ET-BERT: A Contextualized Datagram Representation with Pre-training Transformers for Encrypted Traffic Classification **Note:** ⭐ **Please leave a STAR if you like this project! ** ⭐ If you find any incorrect / inappropriate / outdated content, please kindly consider opening an issue or a PR. **The repository of ET-BERT, a network traffic classification model on encrypted traffic. ** ET-BERT is a method for learning datagram contextual relationships from encrypted traffic, which could be **directly applied to different encrypted traffic scenarios and accurately identify

classes of traffic**. First, ET-BERT employs multi-layer attention in large scale unlabelled traffic to learn both inter-datagram contextual and inter-traffic transport relationships. Second, ET-BERT could be applied to a specific scenario to identify traffic types by fine-tuning the labeled encrypted traffic on a small scale. The work is introduced in the *31st The Web Conference*: Xinjie Lin, Gang Xiong, Gaopeng Gou, Zhen Li, Junzheng Shi and Jing Yu. ET-BERT: A Contextualized Datagram Representation

with Pre-training Transformers for Encrypted Traffic Classification. In Proceedings of The Web Conference (WWW) 2022, Lyon, France. Table of Contents ================= Requirements Datasets Using ET-BERT Reproduce ET-BERT Citation Contact Sponsor Requirements Python >= 3. 2 shutil, random, json, pickle, binascii, flowcontainer argparse packaging tshark SplitCap scikit-learn For the mixed precision training you will need apex from NVIDIA For the pre-trained model conversion (related with TensorFlow) you will need TensorFlow For the tokenization with wordpiece model you will

need WordPiece For the use of CRF in sequence labeling downstream task you will need pytorch-crf Datasets The real-world TLS 1. 3 dataset is collected from March to July 2021 on China Science and Technology Network (CSTNET). For privacy considerations, we only release the anonymous data (see in CSTNET-TLS 1. Other datasets we used for comparison experiments are publicly available, see the paper for more details. If you want to use your own data, please check if

the data format is the same as and specify the data path in . Using ET-BERT You can now use ET-BERT directly through the pre-trained model or download via: After obtaining the pre-trained model, ET-BERT could be applied to the spetic task by fine-tuning at packet-level with labeled network traffic: The default path of the fine-tuned classifier model is . Then you can do inference with the fine-tuned model: Reproduce ET-BERT Pre

-process To reproduce the steps necessary to pre-train ET-BERT on network traffic data, follow the following steps: 1. Run to generate the encrypted traffic corpus or directly use the generated corpus in . Note you'll need to change the file paths and some configures at the top of the file. Run to pre-process the encrypted traffic burst corpus. Run to generate the data for downstream tasks if there is a dataset in pcap format that needs to be

processed. The first is to split pcap files by setting in and save as datasets. Then the second is to

Frequently asked questions

How many stars and forks are recorded?

linwhitehat/ET-BERT has 679 stars and 131 forks.

What is the repository rank?

linwhitehat/ET-BERT is ranked 15,104.

What language and category are recorded?

linwhitehat/ET-BERT has 679 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

linwhitehat/ET-BERT is compared with OpenDriveLab/OpenLane-V2, ranked 15,105 with 678 stars.

README

ET-BERT: A Contextualized Datagram Representation with Pre-training Transformers for Encrypted Traffic Classification

![]('https://img.shields.io/badge/arXiv-1909.05658-

Note:

  • ⭐ Please leave a STAR if you like this project! ⭐
  • If you find any incorrect / inappropriate / outdated content, please kindly consider opening an issue or a PR.

The repository of ET-BERT, a network traffic classification model on encrypted traffic.

ET-BERT is a method for learning datagram contextual relationships from encrypted traffic, which could be directly applied to different encrypted traffic scenarios and accurately identify classes of traffic. First, ET-BERT employs multi-layer attention in large scale unlabelled traffic to learn both inter-datagram contextual and inter-traffic transport relationships. Second, ET-BERT could be applied to a specific scenario to identify traffic types by fine-tuning the labeled encrypted traffic on a small scale.

The work is introduced in the 31st The Web Conference:

Xinjie Lin, Gang Xiong, Gaopeng Gou, Zhen Li, Junzheng Shi and Jing Yu. 2022. ET-BERT: A Contextualized Datagram Representation with Pre-training Transformers for Encrypted Traffic Classification. In Proceedings of The Web Conference (WWW) 2022, Lyon, France. Association for Computing Machinery.

Note: this code is based on UER-py. Many thanks to the authors.

Table of Contents

Requirements

  • Python >= 3.6
  • CUDA: 11.4
  • GPU: Tesla V100S
  • torch >= 1.1
  • six >= 1.12.0
  • scapy == 2.4.4
  • numpy == 1.19.2
  • shutil, random, json, pickle, binascii, flowcontainer
  • argparse
  • packaging
  • tshark
  • SplitCap
  • scikit-learn
  • For the mixed precision training you will need apex from NVIDIA
  • For the pre-trained model conversion (related with TensorFlow) you will need TensorFlow
  • For the tokenization with wordpiece model you will need WordPiece
  • For the use of CRF in sequence labeling downstream task you will need pytorch-crf

Datasets

The real-world TLS 1.3 dataset is collected from March to July 2021 on China Science and Technology Network (CSTNET). For privacy considerations, we only release the anonymous data (see in CSTNET-TLS 1.3).

Other datasets we used for comparison experiments are publicly available, see the paper for more details. If you want to use your own data, please check if the data format is the same as datasets/cstnet-tls1.3/ and specify the data path in data_process/.

Using ET-BERT

You can now use ET-BERT directly through the pre-trained model or download via:

wget -O pretrained_model.bin https://drive.google.com/file/d/1r1yE34dU2W8zSqx1FkB8gCWri4DQWVtE/view?usp=sharing

After obtaining the pre-trained model, ET-BERT could be applied to the spetic task by fine-tuning at packet-level with labeled network traffic:

python3 fine-tuning/run_classifier.py --pretrained_model_path models/pre-trained_model.bin \
                                   --vocab_path models/encryptd_vocab.txt \
                                   --train_path datasets/cstnet-tls1.3/packet/train_dataset.tsv \
                                   --dev_path datasets/cstnet-tls1.3/packet/valid_dataset.tsv \
                                   --test_path datasets/cstnet-tls1.3/packet/test_dataset.tsv \
                                   --epochs_num 10 --batch_size 32 --embedding word_pos_seg \
                                   --encoder transformer --mask fully_visible \
                                   --seq_length 128 --learning_rate 2e-5

The default path of the fine-tuned classifier model is models/finetuned_model.bin. Then you can do inference with the fine-tuned model:

python3 inference/run_classifier_infer.py --load_model_path models/finetuned_model.bin \
                                          --vocab_path models/encryptd_vocab.txt \
                                          --test_path datasets/cstnet-tls1.3/packet/nolabel_test_dataset.tsv \
                                          --prediction_path datasets/cstnet-tls1.3/packet/prediction.tsv \
                                          --labels_num 120 \
                                          --embedding word_pos_seg --encoder transformer --mask fully_visible

Reproduce ET-BERT

Pre-process

To reproduce the steps necessary to pre-train ET-BERT on network traffic data, follow the following steps:

  1. Run vocab_process/main.py to generate the encrypted traffic corpus or directly use the generated corpus in corpora/. Note you'll need to change the file paths and some configures at the top of the file.
  2. Run main/preprocess.py to pre-process the encrypted traffic burst corpus.
       python3 preprocess.py --corpus_path corpora/encrypted_traffic_burst.txt \
                             --vocab_path models/encryptd_vocab.txt \
                             --dataset_path dataset.pt --processes_num 8 --target bert
    
  3. Run data_process/main.py to generate the data for downstream tasks if there is a dataset in pcap format that needs to be processed. This process includes two steps. The first is to split pcap files by setting splitcap=True in datasets/main.py:54 and save as npy datasets. Then the second is to generate the fine-tuning data. If you use the shared datasets, then you need to create a folder under the dataset_save_path named dataset and copy the datasets here.

Pre-training

To reproduce the steps necessary to finetune ET-BERT on labeled data, run pretrain.py to pre-train. If one wishes to continue training on an already pre-trained model, the parameter --pretrained_model_path a can be increased.

   python3 pre-training/pretrain.py --dataset_path dataset.pt --vocab_path models/encryptd_vocab.txt \
                       --output_model_path models/pre-trained_model.bin \
                       --world_size 8 --gpu_ranks 0 1 2 3 4 5 6 7 \
                       --total_steps 500000 --save_checkpoint_steps 10000 --batch_size 32 \
                       --embedding word_pos_seg --encoder transformer --mask fully_visible --target bert

Fine-tuning on downstream tasks

To see an example of how to use ET-BERT for the encrypted traffic classification tasks, go to the Using ET-BERT and run_classifier.py script in the fine-tuning folder.

Note: you'll need to change the path in programes.

Citation

If you are using the work (e.g. pre-trained model) in ET-BERT for academic work, please cite the paper published in WWW 2022:

@inproceedings{lin2022etbert,
  author    = {Xinjie Lin and
               Gang Xiong and
               Gaopeng Gou and
               Zhen Li and
               Junzheng Shi and
               Jing Yu},
  title     = {{ET-BERT:} {A} Contextualized Datagram Representation with Pre-training
               Transformers for Encrypted Traffic Classification},
  booktitle = {{WWW} '22: The {ACM} Web Conference 2022, Virtual Event, Lyon, France,
               April 25 - 29, 2022},
  pages     = {633--642},
  publisher = {{ACM}},
  year      = {2022}
}

Contact

Please post a Github issue if you have any questions. Welcome to discuss new ideas, techniques, and improvements!

Buy Me a Coffee

If you find it useful and want to say thanks, I'd appreciate it if you bought me a coffee! It helps keep the motivation and the energy high!

Nearby in the ranking
Similar items