A comprehensive collection of network programming assignments implementing various socket-based applications and protocols. This project demonstrates fundamental networking concepts through practical implementations using TCP and UDP sockets.
- Overview
- Features
- Prerequisites
- Installation
- Project Structure
- Usage
- Available Programs
- Testing
- Implementation Details
- Learning Objectives
- Troubleshooting
- Contributing
- License
- Contact
This repository contains implementations of various socket programming assignments designed to provide hands-on experience with network programming concepts. The projects cover client-server architectures, protocol implementations, and network application development.
- TCP and UDP socket programming
- Client-server communication
- Protocol design and implementation
- Network application development
- Error handling and reliability
- Performance optimization
- Multi-language Support: Implementations available in Python, Java, and C
- Comprehensive Examples: Complete client-server applications
- Protocol Implementations: Custom protocols for various network services
- Error Handling: Robust error detection and recovery mechanisms
- Documentation: Detailed code documentation and usage examples
- Testing Tools: Built-in testing utilities and performance benchmarks
- Python 3.7+ (for Python implementations)
- Java 8+ (for Java implementations)
- GCC Compiler (for C implementations)
- Git (for version control)
- Access to localhost for testing
- Optional: Multiple machines for distributed testing
- Firewall permissions for socket communication
- Basic understanding of networking concepts
- Familiarity with chosen programming language
- Understanding of client-server architecture
git clone https://github.com/pronad1/Socket_Programming.git
cd Socket_Programming
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Linux/Mac:
source venv/bin/activate
# Install required packages (if any)
pip install -r requirements.txt
# Navigate to C source directory
cd src/c/
# Compile server and client
gcc -o server server.c
gcc -o client client.c
# Navigate to Java source directory
cd src/java/
# Compile Java files
javac *.java
Socket_Programming/
├── README.md # This comprehensive guide
├── requirements.txt # Python dependencies
├── src/ # Source code directory
│ ├── python/ # Python implementations
│ │ ├── simple_socket/ # Basic socket examples
│ │ │ ├── server.py # TCP server implementation
│ │ │ └── client.py # TCP client implementation
│ │ ├── web_server/ # HTTP server implementation
│ │ │ └── webserver.py # Basic HTTP web server
│ │ ├── udp_pinger/ # UDP ping implementation
│ │ │ ├── udp_pinger_server.py
│ │ │ └── udp_pinger_client.py
│ │ └── smtp_client/ # SMTP client implementation
│ │ └── smtp_client.py
│ ├── java/ # Java implementations
│ │ ├── SimpleSocket/ # Basic socket examples
│ │ ├── UDPPinger/ # UDP ping implementation
│ │ └── WebProxy/ # Web proxy server
│ ├── c/ # C implementations
│ │ ├── simple_socket/ # Basic socket examples
│ │ ├── rdt_protocol/ # Reliable data transfer
│ │ └── distance_vector/ # Distance vector routing
│ └── video_streaming/ # 🎬 Professional Video Streaming System
│ ├── server/ # RTSP/RTP streaming server
│ │ └── video_server.py # Main video streaming server
│ ├── client/ # GUI video streaming client
│ │ └── video_client.py # Professional video client
│ ├── protocols/ # Protocol implementations
│ │ ├── rtsp_protocol.py # RTSP protocol handling
│ │ └── rtp_protocol.py # RTP packet management
│ ├── utils/ # Video streaming utilities
│ │ └── video_utils.py # Video processing utilities
│ ├── media/ # Sample media files
│ │ └── create_samples.py # Media file generator
│ ├── tests/ # Comprehensive test suite
│ │ └── test_video_streaming.py
│ └── README.md # Video streaming documentation
├── assignments/ # Programming assignments
│ ├── udp_streaming/ # UDP streaming assignment
│ │ ├── streaming_server.py # UDP streaming server
│ │ ├── streaming_client.py # UDP streaming client
│ │ ├── test_streaming.py # Automated test suite
│ │ └── quick_test.py # Quick validation tool
│ ├── tcp_file_transfer/ # File transfer assignment
│ ├── multi_threading/ # Multi-threading exercises
│ └── network_protocols/ # Protocol implementation
├── docs/ # Documentation and guides
│ ├── protocol_specifications.md # Protocol documentation
│ ├── testing_guide.md # Testing procedures
│ └── performance_analysis.md # Performance metrics
├── tests/ # Test files and scripts
│ ├── unit_tests/ # Unit test cases
│ ├── integration_tests/ # Integration test cases
│ └── performance_tests/ # Performance benchmarks
└── examples/ # Example configurations
├── sample_configs/ # Sample configuration files
└── demo_scripts/ # Demonstration scripts
cd src/python/simple_socket/
python server.py [port_number]
cd src/python/simple_socket/
python client.py [server_host] [server_port]
# Terminal 1 (Server)
python server.py 12000
Server listening on port 12000...
# Terminal 2 (Client)
python client.py localhost 12000
Connected to server at localhost:12000
Enter message: Hello, Server!
Server response: HELLO, SERVER!
- Languages: Python, Java, C
- Protocol: TCP
- Description: Basic client-server communication with message exchange
- Location:
src/[language]/simple_socket/
- Language: Python
- Protocol: HTTP
- Description: Basic HTTP web server serving static files
- Location:
src/python/web_server/
- Languages: Python, Java
- Protocol: UDP
- Description: Ping client using UDP sockets with packet loss simulation
- Location:
src/[language]/udp_pinger/
- Languages: Python, Java
- Protocol: SMTP over TCP
- Description: Email client implementation using SMTP protocol
- Location:
src/[language]/smtp_client/
- Language: Python
- Protocols: RTSP/RTP
- Description: Complete video streaming solution with GUI client and RTSP/RTP server
- Features:
- RTSP control protocol implementation
- RTP real-time video streaming
- GUI client with playback controls
- Multiple quality profiles (480p-4K)
- Video library management
- Cross-platform media player integration
- Location:
src/video_streaming/
- Quick Start:
# Start server cd src/video_streaming/server python video_server.py # Launch client (in new terminal) cd src/video_streaming/client python video_client.py
- Languages: Python, Java
- Protocol: HTTP over TCP
- Description: Proxy server implementation with caching capabilities
- Location:
src/[language]/web_proxy/
🚀 Automated Test Runner (Recommended)
# Windows
run_tests.bat
# Linux/Mac
chmod +x run_tests.sh
./run_tests.sh
⚡ Quick Validation
# Check if everything is working
python validate_project.py
# Quick health check only
python validate_project.py --quick
📋 Component-Specific Testing
# Test UDP streaming assignment
cd my_part_udp_streaming
python quick_test.py
# Test video streaming system
cd src/video_streaming
python run_project_tests.py
# Start complete video streaming system
cd src/video_streaming
python start_streaming.py all
- Project Structure: Verify all files and directories exist
- Dependencies: Check Python version and required modules
- Network Connectivity: Test socket creation and port binding
- Assignment Functionality: UDP streaming with 1000-2000 byte chunks
- Video Streaming System: RTSP/RTP protocols, GUI client, server functionality
- Integration: End-to-end client-server communication
- Performance: Streaming throughput and latency benchmarks
📖 Detailed Testing Guide: See TESTING.md for comprehensive testing instructions.
# Run Python tests
python -m pytest tests/unit_tests/
# Run Java tests
cd tests/java/
javac -cp .:junit-4.12.jar *.java
java -cp .:junit-4.12.jar org.junit.runner.JUnitCore TestSuite
# Run integration test suite
cd tests/integration_tests/
python test_client_server_integration.py
# Run performance benchmarks
cd tests/performance_tests/
python benchmark_throughput.py
python benchmark_latency.py
-
TCP Sockets:
- Reliable connection-oriented communication
- Error detection and correction
- Flow control mechanisms
-
UDP Sockets:
- Connectionless communication
- Low-latency applications
- Packet loss handling
-
Protocol Design:
- Custom message formats
- State management
- Error handling strategies
-
Concurrency:
- Multi-threaded servers
- Asynchronous I/O
- Connection pooling
- Connection timeouts
- Network unreachability
- Malformed packets
- Resource exhaustion
After completing these assignments, students will understand:
- Socket API and system calls
- Network protocol implementation
- Client-server architecture patterns
- Error handling in distributed systems
- Performance considerations in network programming
- Security implications of network applications
-
Port Already in Use:
# Find process using the port netstat -ano | findstr :12000 # Kill the process taskkill /PID [process_id] /F
-
Firewall Blocking Connections:
- Add exception for your application
- Check Windows Defender Firewall settings
-
Permission Denied (Ports < 1024):
- Use ports above 1024 for testing
- Run as administrator if necessary
-
Module Import Errors:
# Ensure virtual environment is activated pip install --upgrade pip pip install -r requirements.txt
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-protocol
) - Commit your changes (
git commit -am 'Add new protocol implementation'
) - Push to the branch (
git push origin feature/new-protocol
) - Create a Pull Request
- Follow existing code style and conventions
- Add comprehensive documentation
- Include unit tests for new features
- Update README.md if adding new programs
This project is licensed under the MIT License - see the LICENSE file for details.
These programming assignments are adapted from materials by J.F. Kurose and K.W. Ross. Original assignments copyright 1993-2025, J.F. Kurose, K.W. Ross, All Rights Reserved.
Project Maintainer: [Prosenjit Mondol]
- GitHub: @pronad1
- Email: [prosenjit1156@gmail.com]
Course Information:
- Course: Computer Networks / Socket Programming
- Institution: [Patuakhali Science and Technology University]
- Semester: [5th]
Resources:
Note: This project is for educational purposes. Please ensure you understand your institution's academic integrity policies regarding programming assignments.