Link to home
Start Free TrialLog in
Avatar of oggiemc
oggiemcFlag for Ireland

asked on

Packet Switched Network Discrete Event Simulation

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

ASKER CERTIFIED SOLUTION
Avatar of sweetfa2
sweetfa2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oggiemc

ASKER

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..
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oggiemc

ASKER

>>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".

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial