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 is the reverse companion to NeT2I. It decodes RGB images created from network traffic data back into structured tabular form. This enhanced version supports both IPv4 and IPv6 network data with intelligent adaptive decoding.
๐งฉ Important: I2NeT decodes only the format output by NeT2I. Images from other tools will not decode correctly.
โจ Features
- ๐ Bi-directional Processing: Reverses RGB images generated by NeT2I into CSV-format network traffic data
- ๐ Dual IP Support: Handles both IPv4 and IPv6 network addresses seamlessly
- ๐ Timestamp Reconstruction: Automatically detects and merges 6-component datetime fields (Year, Month, Day, Hour, Minute, Second) into ISO format
- ๐ง Adaptive Decoding: Automatically detects data structure and adjusts decoding strategy
- ๐ฏ Smart Type Detection: Uses filename prefixes (
ipv4_,ipv6_) for automatic protocol detection - ๐ก Comprehensive Data Types:
- IPv4 addresses (4 octets from 8 RGB pixels)
- IPv6 addresses (16 bytes from 6 RGB pixels)
- MAC addresses (6 bytes from 4 RGB pixels)
- Integers and floats (IEEE 754 from 2 RGB pixels)
- Strings (via consistent hash representations)
- ๐ง Flexible Configuration: Supports separate type definitions for IPv4 and IPv6
- ๐ Batch Processing: Handles multiple image sets with progress tracking
- ๐ก๏ธ Error Resilience: Graceful handling of incomplete or corrupted data
๐ Requirements
- Python 3.9+
- Dependencies:
- Pillow
- NumPy
- Standard library modules (struct, json, csv, glob, ipaddress, dateutil)
๐ Installation
# Install required dependencies
pip install pillow numpy
# Clone the repository
git clone https://github.com/omeshF/I2NeT.git
cd I2NeT
๐ Directory Structure
Organize your PNG images with proper naming conventions:
data/
โโโ ipv4_0.png # IPv4 data images
โโโ ipv4_1.png
โโโ ipv4_2.png
โโโ ipv6_0.png # IPv6 data images
โโโ ipv6_1.png
โโโ ipv6_2.png
โโโ data_types.json # IPv4 type definitions (optional)
โโโ data_types_ipv6.json # IPv6 type definitions (optional)
๐ฏ Usage
Basic Usage
import i2net
# Decode all images in directory
results = i2net.decode(
data_directory='data',
output_csv='decoded_network_data.csv'
)
print(f"โ
Processed {results['total_images_processed']} images")
print(f"๐ Generated {results['total_rows']} data rows")
Advanced Configuration
import i2net
# Custom configuration with separate type files
results = i2net.decode(
data_directory='network_images',
output_csv='reconstructed_data.csv',
types_file_ipv4='ipv4_schema.json',
types_file_ipv6='ipv6_schema.json',
verbose=True
)
# Access detailed breakdown
print(f"IPv4 rows: {results['ipv4_rows']}")
print(f"IPv6 rows: {results['ipv6_rows']}")
print(f"Success: {results['success']}")
Single Image Decoding
import i2net
# Decode individual image
values = i2net.decode_single(
image_path='data/ipv6_0.png',
is_ipv6=True
)
print(f"Decoded values: {values}")
# Auto-detect from filename
values = i2net.decode_single('data/ipv4_5.png') # Auto-detects IPv4
Using the Enhanced Decoder Class
from i2net import EnhancedI2NeT_Decoder
# Create decoder instance
decoder = EnhancedI2NeT_Decoder(
types_file_ipv4='data_types.json',
types_file_ipv6='data_types_ipv6.json'
)
# Process different datasets
results = decoder.load_data('network_captures', verbose=True)
# Decode specific image
reconstructed = decoder.decode_single_image('capture_001.png', is_ipv6=False)
๐ Decoding Logic
| Data Type | Storage Method | Decoding Process |
|---|---|---|
| Float/Integer | 2 RGB pixels (6 bytes) | IEEE 754 float extraction |
| IPv4 Address | 8 RGB pixels (4 octets ร 2 pixels) | 4 floats โ 4 octets โ dotted decimal |
| IPv6 Address | 6 RGB pixels (18 bytes) | 16 bytes โ IPv6 address object |
| MAC Address | 4 RGB pixels (2 chunks ร 2 pixels) | 2 floats โ hex chunks โ colon notation |
| Timestamp | 12 RGB pixels | [Y,M,D,H,M,S] โ merged into YYYY-MM-DD HH:MM:SS |
| String | 2 RGB pixels | Hash value โ string representation |
Adaptive Decoding Features
- Truncation Handling: Gracefully processes incomplete data by treating remaining pixels as floats
- Type Detection: Automatically determines data structure from available RGB pixel count
- Fallback Strategy: Uses generic float decoding when type information is unavailable
- Mixed Protocol Support: Handles datasets containing both IPv4 and IPv6 addresses
๐ Output Files
| File | Description |
|---|---|
decoded_network_data.csv |
Final merged output with all decoded data |
data_types.json |
IPv4 type schema (optional) |
data_types_ipv6.json |
IPv6 type schema (optional) |
๐ ๏ธ Type Definition Files
Create JSON files to guide the decoding process:
data_types.json (IPv4):
{
"original_types": ["Float", "String", "IPv4 Address"],
"final_types": ["Float", "Float", "Float", "Float", "Float", "Float", "Float", "IPv4 Address", "IPv4 Address", "IPv4 Address", "IPv4 Address"],
"encoding_info": {
"description": "Data type mapping for decoding - IPv4 version",
"datetime_handling": "Detected timestamps split into 6 columns: Y,M,D,H,M,S"
}
}
data_types_ipv6.json (IPv6):
{
"original_types": ["Float", "String", "IPv6 Address", "MAC Address"],
"final_types": ["Float", "Float", "Float", "Float", "Float", "Float", "Float", "IPv6 Address", "MAC Address", "MAC Address", "Float"]
}
โก Performance & Compatibility
- Multi-format Support: PNG, JPG, JPEG, BMP, TIFF
- Batch Processing: Progress tracking for large datasets
- Memory Efficient: Processes images sequentially to minimize memory usage
- Error Recovery: Continues processing even if individual images fail
๐จ Important Notes
- NeT2I Compatibility: Only works with images generated by NeT2I
- Filename Conventions: Use
ipv4_andipv6_prefixes for automatic protocol detection - Type Files: Optional but recommended for accurate IP and MAC address reconstruction
- Image Order: Files are sorted numerically when possible, alphabetically otherwise
- Timestamps: Ensure your net2i version encodes timestamps as 6 components
๐ฏ Use Cases
This enhanced I2NeT decoder is ideal for:
- Network Security Analysis: Reconstructing network traffic from image-encoded datasets
- Machine Learning Workflows: Converting CNN-processed network images back to structured data
- Data Integrity Verification: Validating image-encoded datasets before training
- Mixed Protocol Datasets: Handling modern networks with both IPv4 and IPv6 traffic
- Forensic Analysis: Recovering network data from visual representations
- Temporal Traffic Analysis: Reconstructing timestamps for time-series analysis
๐ API Reference
Main Functions
decode(data_directory, output_csv, ...)- Main decoding functiondecode_single(image_path, ...)- Single image decoderload_data_with_ipv4_ipv6_support(...)- Enhanced loader with dual IP supportget_decoder(...)- Factory function for decoder instances
Classes
EnhancedI2NeT_Decoder- Main decoder class with advanced features
๐ Citation
If you use I2NeT or NeT2I in your research, 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
๐ License
This project is licensed under the MIT License.
๐ Related Project: NeT2I - Convert network data to images
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file i2net-2.6.tar.gz.
File metadata
- Download URL: i2net-2.6.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2de26e8a67d755f8a88b2d551b40d495f5007521f16170312b1b7a02685633a8
|
|
| MD5 |
097bb9d229f01a3cedb17a90205fd7af
|
|
| BLAKE2b-256 |
bac5865280327ca17c54deaaaedda89234f4aa87423ee7e037d820bbe6f6419d
|
File details
Details for the file i2net-2.6-py3-none-any.whl.
File metadata
- Download URL: i2net-2.6-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff6dee9b617b687ee4b7f1574d18b2df0558d99818616e57231e439417da9ae
|
|
| MD5 |
25c6787fc06a0928f20da44766dd178b
|
|
| BLAKE2b-256 |
5669bc3253f0bc37d7e982e02a2ce24e92a7c2985e48ba1974bd684a1dbef861
|