Skip to main content

I2NeT (Images to Network Traffic), extract and reconstruct data from RGB-encoded PNG images into CSV format. Suitable for CNN-based anomaly detection.

Project description

I2NeT - Image to Network

I2NeT (Image to Network) is the reverse companion to NeT2I. It decodes RGB images created from network traffic data back into structured tabular form.

This tool is purpose-built to only decode .png images generated using NeT2I. It restores data types including IPs, MACs, integers, floats, and hashed strings, ensuring accurate reconstruction for further analysis.

🧩 I2NeT decodes only the format output by NeT2I. Images from other tools will not decode correctly.


🎯 Key Features

  • 🔁 Reverses RGB images generated by NeT2I into CSV-format network traffic data
  • 🧠 Supports automatic or guided decoding using data_types.json
  • 💡 Recognizes and reconstructs:
    • IP addresses
    • MAC addresses
    • Integers and floats (via IEEE 754)
    • Strings (via consistent hash representations)
  • 🖼️ Processes one .png image per data row

🛠️ Requirements

  • Python 3.9+
  • Pillow
  • NumPy

Install dependencies:

pip install pillow numpy

🚀 Getting Started

1. Prepare Your Images

Ensure that .png images are located in a data/ directory:

data/
├── 0.png
├── 1.png
├── ...

You may optionally include a data_types.json file for better reconstruction accuracy (especially for IP and MAC decoding).

2. Run the Decoder

python i2net.py

This will:

  • Load all PNG images in data/
  • Decode the pixel data back to floats
  • Reconstruct column types (with or without a schema)
  • Write the output to:
from_image.csv

🧬 How It Works

Encoded Type Decoding Logic
🧾 Float / Int Extracted from 2 RGB pixels → 6 bytes → IEEE 754
🌐 IP Address 4 octets → 4 floats → 2 pixels each
🕸️ MAC Address 2 hex chunks → floats → decoded as 12-char hex
🔐 String Hash (SHA-1→int) → float → approximate reconstruction (optional)

Each 6-byte chunk (2 pixels) is read and unpacked into a float using struct.unpack(). Typed decoding relies on type hints stored in data_types.json.


📁 Output Structure

File Description
from_image.csv Final decoded output
data_types.json (optional) Guides the decoder in assigning column types
data/*.png Input image files, one per data row (from NeT2I)

🔄 Compatible Only With NeT2I

I2NeT only works on RGB images generated by NeT2I. These images are structured using a two-pixel-per-float strategy that preserves byte precision. Any other source of images will result in invalid outputs.


🧪 Example Use Case

This decoding tool is ideal for:

  • Verifying the integrity of image-encoded datasets before CNN training
  • Debugging failed predictions by mapping CNN outputs back to raw features
  • Regenerating partial data from anomaly-detected image samples

⚙️ Config Options

You can modify these variables at the top of the script:

INPUT_DIR = "data"
OUTPUT_FILE = "from_image.csv"
TYPES_FILE = "data_types.json"

📖 Citation

If you use I2NeT or NeT2I in your work, please cite:

@inproceedings{fernando2023new,
  title={New algorithms for the detection of malicious traffic in 5g-mec},
  author={Fernando, Omesh A and Xiao, Hannan and Spring, Joseph},
  booktitle={2023 IEEE Wireless Communications and Networking Conference (WCNC)},
  pages={1--6},
  year={2023},
  organization={IEEE}
}

👤 Authors

  • Omesh Fernando
  • Sajid Fadlelseed

📜 License

This project is licensed under the MIT License.


🌐 Project Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

i2net-2.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

i2net-2.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file i2net-2.0.0.tar.gz.

File metadata

  • Download URL: i2net-2.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for i2net-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1658358939a3f3777b304cffa9d17589ad6f291b4f7d77c4a604f51fe67bf4e0
MD5 9c043600ce8bdfa5c97110a9d961be53
BLAKE2b-256 f25bee95a1672d5296b55e926003bdd24ccf6d0a8c8f2e75297b8878d211700a

See more details on using hashes here.

File details

Details for the file i2net-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: i2net-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for i2net-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 967ef9bf9b23db53f2e7eaf7a8a2fa6546aefdc927b32d1b8fefc62fa7e36694
MD5 8ddd7bd05250c4e339e4b9d810627a72
BLAKE2b-256 dd4c16faad7f4c8b7bed767b5ab26d1982f0536bebaf79e53a801db97b777c33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page