Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the background and diagrams to write a java program that is an implementat

ID: 3866844 • Letter: G

Question

Given the background and diagrams to write a java program that is an implementation of the diagrams created below. Background: CSMACD stands for carrier Sense, Multiple Access, and Collision Detection. We use a simplified version where the protocol is: If a station is ready to send a message (according to a random probability p1) it senses the carrier. A station can only sense a part of the carrier (in this simulation it is a one-meter part of the carrier directly attached to the station). a. If the carrier is deemed to be free, the station start transmission of a random message (length R2 ticks) b. Otherwise, the station delays sensing the carrier by a random (R3) number of ticks. If a station detects collision it stops the current transmission and delays sensing the carrier by a random number of ticks (R4) As long as a station is attempting to send a message it does not generate new messages. The number and location of stations on the carrier, the carrier length in meters (RS), and the propagation time of a message through the carrier in tics/meter are given. Note that a tick is an abstract atomic time unit. In this assignment we assume that a tic is the time that it takes for a message to propagate a distance of one meter in the carrier. In other words, a message propagates in the carrier at a speed of one meter per tick. The goal (which will be accomplished in the next assignment) is to write a single thread simulation of the simplified CSMACD scenario with 3 stations {S0, S1, S2, } assuming that S0 and S2 are at the two ends of the carrier and S1 is at a distance of 8 meters from S0, Your program should use a random number generator that generates random numbers in the appropriate ranges as specified below. A station is ready to send a message if p1 > 0.9 R2 elementof [1, 3]: R3 elementof [2, 16]: R4 elementof [1, 24]: R5 elementof [16, 24]: The simulation should run for 1500 ticks and output the simulation throughput, defined as the number of successfully transmitted messages per the number of messages generated. Simulation Pseudo Code: /* Generate RS */ For (I = 0: I

Explanation / Answer

Providing a simpler program for you to first understand CSMA/CD -

import java.io.*;

import java.net.*;

class CSMA extends Thread

{

Thread t3,t2,t1;

String th;

static int x=0;

CSMA(String name)

{

super(name);

start();

}

int get() {

return x;

}

void put() {

x++;

}

public void run()

{

try

{

int x,y,i=0;

while(true){

x=get();

y=get();

if(x == y) {put();x=get();

System.out.println("x= " + x);

th = Thread.currentThread().getName();

System.out.println("Station Transmitting from " + th + " from " + i++);

Thread.sleep(2000);

}

b=get();

System.out.println("b= " + b);

System.out.println("x after sleeps " + x);

if(x!=b){

System.out.println("Station " + th + " Collision Occured form " + (i-1));

Thread.sleep(2000);

}

else

{

System.out.println("Station "+ th + " | Success frame "+i);

}

}

}

catch(Exception e){

//log something here

}

}

public static void main(String[] args)

{

csma c1=new csma("X");

csma c2=new csma("Y");

csma c3=new csma("Z");

while(true);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote