Solved

Packet Switched Network Discrete Event Simulation

Posted on 2010-11-26
5
738 Views
Last Modified: 2012-05-10
Hi Guys,

I have to do a Single-Queue Simulator design for a Packet Switched Network which involves modelling a single transmission link to measure packet-loss rate and delay. I have been given some EventListManager code on which to base the simulation code (attached). I would appreciate it if someone could give me a general overview of what way i should go about implementing this, as at the moment im a little bit lost.

Thanks in advance
//package yourPackage...



import java.util.LinkedList;

import java.util.ListIterator;



/**

 * This class implements the functionalities of an event list in the "event

 * advance" simulation design. It provides methods to manage the insertion, the

 * sorting and the removal of an event in the list. Only one instance of this

 * class is admissible (Singleton java pattern). To create an instance of this class 

 * use the method getInstance() and not the constructor. For Example :

 * 

 * EventList myEventList = EventList.getInstance();

 * 

 * 

 * @author Daniele Tafani 10/10/09

 * 

 */

public class EventListManager {



	/**

	 * The instance of the EventList class.

	 */

	private static EventListManager instance;



	/**

	 * The event list implemented as a Java LinkedList object.

	 */

	private static LinkedList<Event> eventList;



	/**

	 * Constructor of the class. It creates a LinkedList object.

	 */

	private EventListManager() {

		eventList = new LinkedList<Event>();

	}



	/**

	 * Returns the singleton instance.

	 * 

	 * @return instance : The EventListManager instance.

	 */

	public static synchronized EventListManager getInstance() {

		if (instance == null)

			instance = new EventListManager();

		return instance;

	}



	/**

	 * Insert and sort an event to the list of events according to its

	 * associated clock value.

	 * 

	 * If the list is empty, it adds the event as the first element of the list.

	 * If the list is not empty, it inserts and sorts the event according to its

	 * clock value (for example if the list has 2 events which will occur at

	 * CLOCK_1 = 1.5 and CLOCK_2 = 2.4 and if the event to be inserted has CLOCK

	 * = 1.6, the method will insert the event between the 2 events). If the

	 * event clock is greater than all the event clocks of the list, the method

	 * will insert it as the last element.

	 * 

	 * @param event (Event) : the event to be inserted in the list.

	 * 

	 */

	public void insertEvent(Event event){



		boolean isInserted = false;

		

		if(isEmpty()) {

			eventList.addFirst(event);

			isInserted = true;

		}



		else {

			ListIterator<Event> iterator = eventList.listIterator();

			while (iterator.hasNext()) {



				Event listEvent = iterator.next();

				if (event.getEventClock() <= listEvent.getEventClock()) {

					

					iterator.previous();

					iterator.add(event);

					isInserted = true;

					break;

				}

			}

		}



		if (!isInserted)

			eventList.addLast(event);

	}



	/**

	 * Removes and returns the first event from the list.

	 * 

	 * @return firstEvent (Event) : the first event of the list.

	 * 

	 */

	public Event poll() {

		Event firstEvent = eventList.removeFirst();

		return firstEvent;

	}



	/**

	 * Check if the list does not contain events.

	 *

	 * @return isEmpty (boolean) : "true" if the list is empty, "false" viceversa.

	 * 

	 */

	public boolean isEmpty() {

		boolean isEmpty = eventList.isEmpty();

		return isEmpty;

	}

}

Open in new window

//package yourPackage...



/**

 * This class is an implementation of the event object to be inserted in the

 * event list. In the current version it contains just an attribute, the clock value

 * at which the event occurs.

 * It also contains a set of get() and set() methods to retrieve and modify its clock value. 

 * The student has to define the constructor of this class and other eventual additional attributes

 * that are necessary to uniquely define the event.

 * 

 * @author Daniele Tafani 10/10/09

 * 

 */

public class Event {



	/**

	 * The clock value of the event.

	 */

	private double eventClock;



	/**

	 * Constructor of the class: to be developed by the student...

	 * 

	 */

	public Event(double eventClock) { 

		

		// Fill in with your code....

	}



	/**

	 * Returns the event clock value.

	 * 

	 * @return (double) eventClock : the even clock value (double).

	 */

	public double getEventClock() {

		return eventClock;

	}



	/**

	 * Modifies the event clock value.

	 * 

	 * @param (double) eventClock

	 *            : the new event clock value (double).

	 */

	public void setEventClock(double eventClock) {

		this.eventClock = eventClock;

	}

	

	

	//Add attributes that are necessary to uniquely define the event object.

	// ....

}

Open in new window

0
Comment
Question by:oggiemc
  • 3
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
sweetfa2 earned 500 total points
Comment Utility
Well the coments in the Event class indicate that the event object is to be inserted in the event list.

Your assignment is to be able to measure response times, traffic lost, etc.

What attributes do you think would EACH transmission provide that would enable this detail to be extracted from a list at a later time?

Think of the event list as a store of all events that have occurred.

What are the triggers for your event - what makes one happen?

What information is provided to your event?

What comments are in the event list code about your clock than you can use to identify what extra attributes are required?

How much of the question you have been asked is more than what the example code gives you?

0
 

Author Comment

by:oggiemc
Comment Utility
Hi sweetfa, thanks for response and sorry for lateness in reply..

>>What attributes do you think would EACH transmission provide that would enable this detail to be extracted from a list at a later time?
Arrival time, queuing time, departure time..

>>What are the triggers for your event - what makes one happen?
the mean interarrival times of packets has to be set according to the mean offered loads given.

What information is provided to your event?

>>What comments are in the event list code about your clock than you can use to identify what extra attributes are required?
Previous event clock times of other packets? Not to sure what uniquely defines an event appart from its clock time.

>>How much of the question you have been asked is more than what the example code gives you?
The example code gives method of inserting/sorting events in the EventList according to occurrence times..I have to determine packet loss rate and delay..Packetloss rate be determined by keeping track of current number of packets in the queue.. delay = dep time of packet out of queue - arr time into the queue..
0
 
LVL 17

Assisted Solution

by:sweetfa2
sweetfa2 earned 500 total points
Comment Utility
So you need to add arrival time and departure time attributes.

I can't give you a code solution as this is an assignment.

How does an event get created?  How does an event get put in the queue?

How does an event get removed from the queue?

You have the code for your queue, and your event.  Are you supposed to develop some code to generate the events and cause them to be pulled off the queue?

Do you need to modify your time attributes, or do you need to identify events by an event type.  For example, is a separate event generated when sending a message, and another event when receiving notification of transmission, or is it the same event that gets reused when sending, in which case you would already have a clock value when the event was initially created, which would then allow you to create a time-difference by using the current time minus existing event time
0
 

Author Comment

by:oggiemc
Comment Utility
>>How does an event get created?
We are to use a random number generator to generate the events (we are able to use the in built java random number generator for this)..

>> How does an event get put in the queue?
The EventListManager insertEvent() code does this..

>>How does an event get removed from the queue?
I dont know this..We are given the following parameters:

Offered load = 0.8 Erlangs      (=arrival rate * mean holding time)
Mean Packet Length = 8000 bits
Max Queue Length (K) = 10
Link Rate = 100Gbps
Queue = FIFO

So i guess that the departure time of a packet = mean holding time + arrival time?

>>Do you need to modify your time attributes, or do you need to identify events by an event type.  For example, is a separate event generated when sending a message, and another event when receiving notification of transmission, or is it the same event that gets reused when sending, in which case you would already have a clock value when the event was initially created, which would then allow you to create a time-difference by using the current time minus existing event time
Not too sure what your asking here but:
"Traffic from the network is assumed to have negative-exponentially distributed inter-arrival times".

0
 
LVL 17

Assisted Solution

by:sweetfa2
sweetfa2 earned 500 total points
Comment Utility
>>The EventListManager insertEvent() code does this..
What calls this?


0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article is a step by step guide on how to create a basic PTP link using Ubiquiti airOS devices. This guide can be used on the following Ubiquiti AirMAX devices. Nanostation, Bullets, AirBridge, Nanobeam, NanoBridge to name a few. Please review …
AWS has developed and created its highly available global infrastructure allowing users to deploy and manage their estates all across the world through the use of the following geographical components   RegionsAvailability ZonesEdge Locations  Wh…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now