Skip to content

MichiasShiferaw/ceg-3185_lab3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CEG Lab : 3 Socket Programming & the IPv4

This lab demonstrates the importance of IP protocol; with the use of Network Socket programming.

 

Project Objectives

  • ✓ Implement two programs, a client and a server and two func (methods), one to encode (at the client side), one to decode (at the server side)
  • The Client: PacketSender.java
    • ✓ Reads the data from user
    • ✓ Sends the encoded stream to the server through socket
  • The Server: PacketReceiver.java
    • ✓ Acknowledges the client that the encoded stream has been received
    • ✓ Decodes the stream and prints it on the screen

Class Description

Class Description
PacketSender The user will decide to use default or provide custom data to represent the payload and the source/destination IP addresses. Afterwards, the class will initiate a request for a connection to the server with a specified IP address and port number. Afterwards, the data is converted into a hex-format datagram and sent to the server for decoding.
PacketReciever Waits for incoming client/sender requests by listening to a specified port (4999), once accepted, the server performs a decoding function involving the checksum function to determine if there are no errors. If no errors are found, the program unveils the datagram including the source IP and message/payload as well as their respective length in bytes.

 

Usage/Examples

 

To run this project:

Open up two seperate terminals

 

Server

In one terminal run;

javac PacketReceiver.java

to read and compile the server class file.

 

java PacketReceiver

to execute the server side component.

 

Client

In the other terminal run;

javac PacketSender.java

to read and compile the client class file.

 

java PacketSender -server {DEST_IP} -payload "{custom_payload}"

#  example
java PacketSender -server 127.000.0.3 -payload "SPAIN 2 - RONALDO 5"

OR

For default outputs

java PacketSender 

to execute the client side

 

Demo

Default Data

Custom Data

 

Directory Structure

├── Output
│   ├── Output1.png 
│   └── Output2.png
├── PacketReciever.java
├── PacketSender.java
└── README.md

 

Authors

 

References

https://docs.oracle.com/javase/tutorial/networking/sockets/cIientServer.html

Releases

No releases published

Packages

No packages published

Languages