0% found this document useful (0 votes)
117 views

Ihlp Report PDF

This document contains a project report submitted by three students for an Internet and Higher Layer Protocols course. It includes three questions related to simulating and analyzing the CSMA/CD MAC protocol, modeling CSMA/CD mathematically using MATLAB code, and writing a chat application using Java socket programming. Code and explanations are provided for each question along with results like graphs or console outputs.

Uploaded by

Dipika Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

Ihlp Report PDF

This document contains a project report submitted by three students for an Internet and Higher Layer Protocols course. It includes three questions related to simulating and analyzing the CSMA/CD MAC protocol, modeling CSMA/CD mathematically using MATLAB code, and writing a chat application using Java socket programming. Code and explanations are provided for each question along with results like graphs or console outputs.

Uploaded by

Dipika Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

INTERNET AND HIGHER

LAYER PROTOCOLS
(ECE 637-001)
FALL 2014

PROJECT REPORT
SUBMITTED BY:
DIPIKA GHOSH
(UCID: dg294, NJIT ID: 31260299)

YAGNA PATEL
(UCID: ypp5, NJIT ID: 31327569)

SHIVA KUMAR singanayakanahalli


(UCID: ss2554 , NJIT ID:31323675)

Question 1:
Aim: To the study the performance 802.11 MAC mechanism (CSMA/CD) by writing java
simulation code which describes how the MAC mechanism works.
Java code and its explanation:

In this code first we define the variables which will take the number of hosts, total number of hosts
transmitting, and the total execution time as an input. Then we define a host array variable which
are to be connected via Ethernet to transmit inside the inbuilt class called Threads.

Next, we define a class called Host, which will inherit all the variables present in class Thread.
In this class, we define variables to keep a count of number of collision, to check the status of the
channel whether its idle or busy, and to learn the number of hosts willing to transmit at that time,
and to define delay.

Then as per the, CSMA/CD protocol, whenever there is no collision, this java code will be
executed as:
1) If the channel is free/idle, then transmit, else, do nothing and go to the next.
2) If the channel is busy, keep listening to it until it is idle, once idle then transmit
immediately.
3) If a collision is detected during transmission, then send a small jam signal named Line
Not Idle, to let all stations know about that collision has occurred and then stop the
transmission.
4) After the transmission of the jam signal, wait for some random amount of time, then
attempt to retransmit the collided packet and follow the steps as mentioned since step 1.

Below code shows retransmission takes place 10 times, if still the packet is not send then display
failed to send the packet.

Result:
Output 1:

Output 2:

Question 2:
Aim: To analyze the simulation and mathematical modeling of CSMA/CD and obtaining output.
Description:
The Carrier Sense Multiple Access/Collision Detection (CSMA/CD) protocol is a fundamental
distributed protocol and is the protocol for carrier transmission access in Ethernet networks
(international standard IEEE 802.3). On Ethernet, any host can try to send a packet in a channel at
any time. If another host tries to send a packet at the same time, a collision is said to occur and the
packets are discarded. The CSMA/CD protocol was designed to avoid this problem, more precisely
to allow a host to send its packet without collision. This is done by way of a randomized
exponential back-off process. In Ethernet, multiple hosts may be connected via the same channel.
Since two hosts may send packets simultaneously, collisions may occur, thus discarding both
packets. Both the hosts will detect this collision, but cannot re-send the packets at once, since it
would induce a new collision. So, when a collision happens, the CSMA/CD protocol forces each
hosts to pick at random an integer-valued delay from a bounded interval, and to wait for a length
of time proportional to this integer-valued delay before re-sending the packet. The Mathematical
model is shown in the following matlab code.
Matlab Code:
Code and its explanation:

In this code first we are checking whether channel is busy or idle, if channel is busy then we will
check if the data packet has been sent or not and if the data packet has been sent, without any
collision. If incase collision takes place then a variable named collision index will keep a count of
the host at which the collision took place. After encountering the collision, transmission will wait
for some time, thus stations in queuing side will increase. When the collision is detected then
retransmission of that frame takes place after a wait. And after a successful transmission of packet
from sender, the variable at sender named transmission counter will keep a count of the successful
transmission and thus transmission queue on the sender side will reduce.

Now after a successful transmission, again we will check the status of the channel, if it idle, we
will try to send the packet and thus keep a record of the data in their respective variables.

Now graph of CSMA/CD has been obtained, with throughput on x-axis and arrival rate on yaxis.
Graph obtained:

Question 3:
Aim: To write a talk application for computer network communications using socket programming
that allows testing of the protocols in in the TCP/IP suite.
Elucidation of the code:
Our socket programming is Chat communication the process of exchanging messages between
two systems continuously using the TCP socket. There is a fixed connection line between the
Client and Server. There are two separate programs; a Client program and a Server program
contain the server and the client source code. The server listens to port 3000 at the localhost. When
we send a message from the client application the server receive the message and send a reply to
the client. Both programs are using the same streams and objects. The Client application must
know IP address of server and port number.
Running the code:
Change the host name or IP address of Server in Client.java program. Now run the Server.java
first and then the Client.java. You can run the client on any machine on your network; it doesnt
have to run on same machine as server. Once both connected, connected message will be displayed
on the client side console Start the chitchat, type and press Enter key and on the server side
console Server is ready for chatting. Now type messages on each console and press enter button.
Messages will be transmitted through socket.
If you run the Client before Server has a chance to initialize itself and begin listening on the port.
If this happens you will see the following error message when you try to start the client:
Exception in thread "main" java.net.ConnectException: Connection refused: connect

Socket Code:
Server code:

Client code:

Result:
Output window obtained at server side:

Output window obtained at client side:

You might also like