This project aims to analyze network communications by monitoring and logging details of all communications. The project includes scripts for broadcasting messages, receiving messages, and analyzing network packets. It leverages Docker for containerization, Python for scripting, and Scapy for packet analysis.
- Broadcast Messages: The
master.py
script broadcasts messages to all nodes in the network. - Receive Messages: The
node.py
script listens for messages broadcasted by the master. - Network Analysis: The
network_analyzer.py
script analyzes network packets and logs detailed information about communications. - Docker Support: All scripts can be containerized using Docker, making it easy to deploy and run on any system with Docker installed.
- Docker: To build and run the project containers.
- Python: For script execution.
- Scapy: For packet analysis.
Follow the official Docker documentation to install Docker on your system. Docker Installation Guide
- Navigate to the Project Directory: Open a terminal and navigate to the root directory of your project.
- Build the Docker Images:
docker build -t master-image .
docker build -t node-image .
- Run the Containers:
docker run -d --name master master-image
docker run -d --name node1 node-image
docker run -d --name node2 node-image
docker run -d --name node3 node-image
docker run -d --name node4 node-image
- Start the Master Container:
docker start master
- Start the Node Containers:
docker start node1 node2 node3 node4
- Check Logs: To verify that messages are being sent and received, check the logs of the master and node containers:
docker logs master
docker logs node1
docker logs node2
docker logs node3
docker logs node4
- Build the
network_analyzer.py
Script: Ensure thatnetwork_analyzer.py
is in the correct directory as per your project structure. - Run the Script: Execute the script using Python. You might need to adjust the script to capture packets from the correct interface or network.
python3 network_analyzer.py
To ensure that your network analysis scripts can communicate effectively, you may need to configure your firewall to allow traffic on specific ports. The exact steps depend on your operating system and firewall software. Generally, you would need to add rules to allow incoming and outgoing traffic on the ports used by your scripts.
- Python UDP Broadcast
- Scapy Documentation
- Docker Documentation
- Docker containers using ipc sockets
- Multi threaded tcp server
- Tried creating one network for all nodes
- Python sockets for multicast using threading
This project is open-source intended for Networks and Distributed Systems
In my master.py, I am using UDP broadcast to send a message to all devices on the network. The key part of my code that enables broadcasting is:
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(message.encode(), ('<broadcast>', 12345))
In node.py, I am using threading to listen for messages in the background while the main thread continues to execute other tasks. This is achieved by:
threading.Thread(target=receive_messages).start()