|
From: <sul...@us...> - 2008-10-11 03:26:30
|
Revision: 253
http://gridsim.svn.sourceforge.net/gridsim/?rev=253&view=rev
Author: sulistio
Date: 2008-10-11 03:26:18 +0000 (Sat, 11 Oct 2008)
Log Message:
-----------
My work: clean up the code and add javadoc comments.
Agustin work: rename FnbDroppedUserPacket to FnbDroppedUserObject, and fix bugs in the fnb algorithms.
Modified Paths:
--------------
trunk/source/gridsim/net/fnb/ARED.java
trunk/source/gridsim/net/fnb/FIFO.java
trunk/source/gridsim/net/fnb/FnbEndToEndPath.java
trunk/source/gridsim/net/fnb/FnbNetPacket.java
trunk/source/gridsim/net/fnb/FnbOutput.java
trunk/source/gridsim/net/fnb/FnbRIPRouter.java
trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java
trunk/source/gridsim/net/fnb/RED.java
Removed Paths:
-------------
trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java
Modified: trunk/source/gridsim/net/fnb/ARED.java
===================================================================
--- trunk/source/gridsim/net/fnb/ARED.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/ARED.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -17,7 +17,7 @@
import gridsim.net.Link;
/**
- * This class implements the Adaptative Random Early Detection policy for
+ * This class implements the Adaptative Random Early Detection (ARED) policy for
* the management of network buffers at routers.
* Its basic functionality is as follows:
* <ul>
@@ -29,8 +29,8 @@
* user involved in the transmission about the dropping.
* </ul>
*
- * For more details refer to A. Caminero, A. Sulistio, B. Caminero, C. Carrion,
- * and R. Buyya,
+ * For more details, please refer to A. Caminero, A. Sulistio, B. Caminero,
+ * C. Carrion, and R. Buyya,
* <a href="http://www.gridbus.org/papers/BufferManagementNetGrids-ANSS41.pdf">
* Simulation of Buffer Management Policies in Networks for Grids</a>,
* Proceedings of the 41th Annual Simulation Symposium (ANSS-41, IEEE CS Press,
@@ -63,7 +63,7 @@
* @param max_buf_size maximum buffer size for routers
* @param queue_weight this parameter reflects how important is the last
* measurement of the buffer size on the calculation of the average buffer size
- * @param stats whether we want to store stats or not
+ * @param stats whether we want to record some stats or not
* @throws Exception This happens when the baud rate <= 0
* @pre baudRate > 0
* @post $none
@@ -76,9 +76,9 @@
}
/**
- * This function updates the value of max_p, which is the maximum dropping
- * probability for a packet.
- * It also updates ALPHA, as it depends on max_p.
+ * This function updates the value of <tt>max_p</tt>, which is the maximum
+ * dropping probability for a packet.
+ * It also updates <tt>ALPHA</tt>, as it depends on <tt>max_p</tt>.
*/
public void updateAREDParameters()
{
@@ -101,21 +101,8 @@
}
- /** Update the stats file of this scheduler.
- */
- /****
- public void updateStats()
- {
- fw_write(GridSim.clock() + ", " + getMaxP() + ", " + getMinTh() + ", " +
- getMaxTh() + ", " + getAvg() + ", " + this.size() + "\n",
- this.getSchedName() + "_Buffers.csv");
- }
- ****/
-
-
/**
- * This methods sets some parameters for the RED and ARED algorithms,
- * such as the thresholds.
+ * Sets the this class and {@link gridsim.net.fnb.RED} thresholds.
*/
public void setThresholds()
{
@@ -126,12 +113,10 @@
double term = -1 / C;
double term2 = Math.exp(term);
+ super.setQueueWeight(1 - term2);
- setQueueWeight(1 - term2);
-
double DELAY_TARGET = 0.005; // 5 milliseconds
double var = DELAY_TARGET * C / 2;
-
if (5 > var)
{
minTh = 5;
@@ -142,17 +127,15 @@
}
- setMinTh(minTh);
- setMaxTh(3 * minTh);
-
+ super.setMinTh(minTh);
+ super.setMaxTh(3 * minTh);
}
/**This function initializes the parameters of the buffers policies
- * */
- public void initialize()
+ */
+ protected void initialize()
{
super.initialize();
-
setThresholds();
if ((getMaxP() / 4) < 0.01)
@@ -161,7 +144,6 @@
ALPHA = 0.01;
BETA = 0.9;
-
}
@@ -174,13 +156,11 @@
*/
public boolean setBaudRate(double rate)
{
-
if (rate <= 0.0)
{
return false;
}
super.setBaudRateSCFQ(rate);
-
initialize();
return true;
Modified: trunk/source/gridsim/net/fnb/FIFO.java
===================================================================
--- trunk/source/gridsim/net/fnb/FIFO.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FIFO.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -33,8 +33,8 @@
* user involved in the transmission about the dropping.
* </ul>
*
- * For more details refer to A. Caminero, A. Sulistio, B. Caminero, C. Carrion,
- * and R. Buyya,
+ * For more details, please refer to A. Caminero, A. Sulistio, B. Caminero,
+ * C. Carrion, and R. Buyya,
* <a href="http://www.gridbus.org/papers/BufferManagementNetGrids-ANSS41.pdf">
* Simulation of Buffer Management Policies in Networks for Grids</a>,
* Proceedings of the 41th Annual Simulation Symposium (ANSS-41, IEEE CS Press,
@@ -45,19 +45,16 @@
* */
public class FIFO extends FnbSCFQScheduler
{
-
private double QUEUE_WEIGHT; // the queue weigth
private double AVG;
private double Q_TIME;
private double S;
+ private double MAX_AVG = 0.0;
- /** */
- public double MAX_AVG = 0.0;
-
/**
* Creates a new FIFO policy with the specified name and baud rate
- * (in bits/s). The name can be useful for debugging purposes, but serves
+ * (in bits/sec). The name can be useful for debugging purposes, but serves
* no functional purposes.
*
* @param name Name of this scheduler
@@ -81,12 +78,12 @@
if (name == null)
{
- throw new ParameterException("RED(): Name is null.");
+ throw new ParameterException("fnb.FIFO(): Name is null.");
}
if (baudRate <= 0)
{
- throw new ParameterException("RED(): Baudrate <= 0.");
+ throw new ParameterException("fnb.FIFO(): Baudrate <= 0.");
}
initialize();
@@ -125,7 +122,7 @@
* @pre pnp != null
* @post $none
*/
- public synchronized boolean checkAndInsertPacketIntoQueue(Packet pnp)
+ private synchronized boolean checkAndInsertPacketIntoQueue(Packet pnp)
{
if (size() < getMaxBufferSizeInPkts())
@@ -140,17 +137,15 @@
}
}
- /** If the queue is full, we have to drop a packet.
- * If the packet to get dropped is a control packet, the sim will stop.
- * Control packets will be those packets sent between the broker or the gis.
- * Normal packets are those belonging to a gridlet.
- * We are using the FIFO algorithm.
+ /** If the queue is full, we have to drop a packet. Note that packets going
+ * to/coming from entities that are listed in
+ * the {@link gridsim.GridSim#fnbWhiteList_} will not be dropped.
* @param pnp the new incoming packet
- * */
- public synchronized void dropPacketFIFO(Packet pnp)
+ */
+ private synchronized void dropPacketFIFO(Packet pnp)
{
// If the queue is full, we have to drop a packet, giving priority to the control packets
- // Control packets will be those packets sent between the broker or the gis.
+ // Control packets will be those packets sent between the broker or the GIS.
// Normal packets are those belonging to a gridlet.
// Control packets can only be dropped when the wue is full of control packets
@@ -160,8 +155,10 @@
// Check the source of the packet
int src_outputPort = ((FnbNetPacket) pnp).getSrcID();
- String src_outputPort_str = GridSim.getEntityName(
- src_outputPort);
+
+ boolean isFile = ((FnbNetPacket) pnp).isFile();
+
+ String src_outputPort_str = GridSim.getEntityName(src_outputPort);
// for example, src_outputPort_str = Output_SIM_0_User_0
// Check the destination, as I'm not sure if it works like that
@@ -174,10 +171,11 @@
{
- /*
- // This was the very first version of the Fnbs
- insertPacketIntoQueue(pnp);
- return true;*/
+ /***********
+ // This was the very first version of the Fnbs
+ insertPacketIntoQueue(pnp);
+ return true;
+ ***********/
if (makeRoomForPacket())
{
@@ -186,27 +184,27 @@
}
else
{
- // The control packet has to be dropped.
-
System.out.println("\n" + super.get_name() +
- ": buffer full, and a control packet has been dropped.\n" +
- " src.output: " + src_outputPort_str +
- ". dst_inputPort: " + dst_inputPort_str +
- "\n HENCE, SIMULATION FINISHED");
+ ": 271 A control packet has been dropped.\n" +
+ "src_output: " + src_outputPort_str +
+ ". dst_inputPort: " + dst_inputPort_str +
+ "\nHENCE, SIMULATION FINISHED AT SIM. TIME " + GridSim.clock());
+ //fw_write("MaxBufferSizeDuringSim, " + getMaxBufferSize() + "\n",
+ // this.get_name() + "_MaxBufferSize.csv");
+
System.exit(1);
// super.shutdownUserEntity();
// super.terminateIOEntities();
-
-
}
}
- /*
- // If u want more info on the progress of sims, uncomment this.
- System.out.println(super.get_name() + ": packet dropped. Src: " +
- src_outputPort_str + ", Dst: " + dst_str +
- ". Pkt num: " + ((FnbNetPacket) pnp).getPacketNum());*/
+ // If u want more info on the progress of sims, uncomment this.
+ /********************
+ System.out.println(super.get_name() + ": packet dropped. Src: " +
+ src_outputPort_str + ", Dst: " + dst_inputPort_str +
+ ". Pkt num: " + ((FnbNetPacket) pnp).getPacketNum());
+ ********************/
// In this case, we will have to remove the packet, and
// also, we will have to tell the source of the packet what has happened.
@@ -226,14 +224,11 @@
// for example, src_str = SIM_0_User_0
entity = GridSim.getEntityId(src_str);
-
}
else
{
// If the destination of the packet is the user, tell the user
-
entity = GridSim.getEntityId(dst_inputPort_str);
-
}
int pktID = ((FnbNetPacket) pnp).getID();
@@ -242,20 +237,33 @@
// for example, input_src_str = Input_SIM_0_User_0
// int input_src = GridSim.getEntityId(input_src_str);
- super.send(src_outputPort, GridSimTags.SCHEDULE_NOW,
+ int glID;
+ if (pnp instanceof InfoPacket)
+ {
+ glID = 99999;
+ }
+ else
+ {
+ // check the user and the gl this packet belongs to
+ glID = ((FnbNetPacket) pnp).getObjectID();
+ //filename = ((FnbNetPacket) pnp).getFileName();
+ }
+
+ //super.send(src_outputPort, GridSimTags.SCHEDULE_NOW,
+ super.sim_schedule(src_outputPort, GridSimTags.SCHEDULE_NOW,
GridSimTags.FNB_PACKET_DROPPED,
- new FnbDroppedUserPacket(entity, pktID));
+ new FnbDroppedUserObject(entity, glID, isFile));
// We tell the output entity of the sender of this packet
// that the packet has been dropped.
pnp = null; // remove the packet.
-
}
/** Calculate the avg queue size for the FIFO algorithm.
*
- * @return the average queue size of this queue, which has been calculated in this function*/
+ * @return the average queue size of this queue,
+ * which has been calculated in this function*/
public double avgQueueSize()
{
@@ -279,6 +287,12 @@
} // avgQueueSize()
+ /**This function initializes the parameters of FIFO policy
+ */
+ protected void initialize()
+ {
+ // empty
+ }
/**
* Prints out the given message into stdout.
@@ -319,15 +333,6 @@
}
}
- /**This function initializes the parameters of the buffers policies (RED, ARED)
- * */
- public void initialize()
- {
- // empty
-
-
- }
-
/**
* Sets the baud rate that this scheduler will be sending packets at.
* @param rate the baud rate of this scheduler (in bits/s)
@@ -343,7 +348,6 @@
return false;
}
super.setBaudRateSCFQ(rate);
-
return true;
}
Deleted: trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -1,160 +0,0 @@
-/*
- * Title: GridSim Toolkit
- * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation
- * of Parallel and Distributed Systems such as Clusters and Grids
- * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
- *
- * Author: Agustin Caminero
- * Organization: Universidad de Castilla La Mancha (UCLM), Spain.
- * Copyright (c) 2008, The University of Melbourne, Australia and
- * Universidad de Castilla La Mancha (UCLM), Spain
- */
-
-package gridsim.net.fnb;
-
-import gridsim.net.*;
-
-/**
- * This class is used by a router to inform users of a dropped packet.
- * @author Agustin Caminero, Universidad de Castilla La Mancha (Spain).
- * @since GridSim Toolkit 4.2
- */
-public class FnbDroppedUserPacket implements Packet
-{
- private int userID;
- private int pktID;
-
- /**
- * Create an object of this class.
- * @param userID the user id
- * @param pktID the packet id
- */
- public FnbDroppedUserPacket(int userID, int pktID)
- {
- this.userID = userID;
- this.pktID = pktID;
- }
-
- /**
- * Gets the user id
- * @return user id
- */
- public int getUserID()
- {
- return userID;
- }
-
- /**
- * Gets this packet tag.
- * @return -1 since no packet tag has been stored in this class.
- * @pre $none
- * @post $none
- */
- public int getTag()
- {
- return -1;
- }
-
- /**
- * Sets an entity ID from the last hop that this packet has traversed.<br>
- * Note that this method is not used.
- * @param last an entity ID from the last hop
- * @pre last > 0
- * @post $none
- */
- public void setLast(int last)
- {
- // empty or not used
- }
-
- /**
- * Gets an entity ID from the last hop that this packet has traversed.
- * @return -1 since no entity ID has been stored in this class.
- * @pre $none
- * @post $none
- */
- public int getLast()
- {
- return -1;
- }
-
- /**
- * Sets the network service type of this packet.<br>
- * Note that this method is not used.
- * @param serviceType this packet's service type
- * @pre serviceType >= 0
- * @post $none
- */
- public void setNetServiceType(int serviceType)
- {
- // not used
- }
-
- /**
- * Gets the network service type of this packet
- * @return -1 since no network service type has been stored in this class.
- * @pre $none
- * @post $none
- */
- public int getNetServiceType()
- {
- return -1;
- }
-
- /**
- * Returns the ID of the source of this packet.
- * @return -1 since no source ID has been stored in this class.
- * @pre $none
- * @post $none
- */
- public int getSrcID()
- {
- return -1;
- }
-
- /**
- * Returns the ID of this packet
- * @return packet ID
- * @pre $none
- * @post $none
- */
- public int getID()
- {
- return pktID;
- }
-
- /**
- * Returns the destination id of this packet.
- * @return -1 since no destination ID has been stored in this class.
- * @pre $none
- * @post $none
- */
- public int getDestID()
- {
- return -1;
- }
-
- /**
- * Sets the size of this packet. <br>
- * Note that this method is not used.
- * @param size size of the packet
- * @return <tt>false</tt> since this method is not used.
- * @pre size >= 0
- * @post $none
- */
- public boolean setSize(long size)
- {
- return false;
- }
-
- /**
- * Returns the size of this packet
- * @return size of the packet
- * @pre $none
- * @post $none
- */
- public long getSize()
- {
- return -1;
- }
-}
Modified: trunk/source/gridsim/net/fnb/FnbEndToEndPath.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbEndToEndPath.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FnbEndToEndPath.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -16,7 +16,7 @@
* This class keeps information which are common to all network packets.
* When a packet is dropped in a router, the router must inform the user/owner
* about this case.
- * Since many packets from the same gridlet may be dropped, the router only
+ * Since many packets from the same gridlet may be dropped, the router only
* sends one event for the whole process, not for each packet.
* Thus, we put all of the common information (e.g. source and destination IDs)
* into this class.
@@ -30,32 +30,49 @@
private int srcID;
private int classtype;
private int totalPkts; // total num of packet that belongs to a group
-
- // the id of the gridlet/file this packet belongs to, or
+ private boolean isFile; // true if this is a file, false otherwise
+
+ // the id of the gridlet/file this packet belongs to, or
// GridSimTags.FNB_PKT_CONTAINS_FILE if the pkt contains a file
private int glID;
-
- /**Creates a new object of this class. Tihs is used by
+
+ /**Creates a new object of this class. This is used by
* the {@link gridsim.net.fnb.FnbOutput} class.
- * @param destID destination id
- * @param srcID source id
+ * @param destID destination id
+ * @param srcID source id
* @param classType network service level
* @param totalPkts total number of packets this connection is made of
- * @param glID the gridlet/file id
+ * @param glID the gridlet/file id
* */
public FnbEndToEndPath(int destID, int srcID, int classType, int totalPkts,
int glID)
{
+ this(destID, srcID, classType, totalPkts, glID, false);
+ }
+
+ /**Creates a new object of this class. This is used by
+ * the {@link gridsim.net.fnb.FnbOutput} class.
+ * @param destID destination id
+ * @param srcID source id
+ * @param classType network service level
+ * @param totalPkts total number of packets this connection is made of
+ * @param glID the gridlet/file id
+ * @param isFile <tt>true</tt> if it contains a file, <tt>false</tt> otherwise
+ * */
+ public FnbEndToEndPath(int destID, int srcID, int classType, int totalPkts,
+ int glID, boolean isFile)
+ {
this.destID = destID;
this.srcID = srcID;
this.classtype = classType;
this.totalPkts = totalPkts;
this.glID = glID;
+ this.isFile = isFile;
}
- /**Creates a new object of this class. This is used by
+ /**Creates a new object of this class. This is used by
* the {@link gridsim.net.fnb.FnbOutput} class.
* @param destID destination id
* @param srcID source id
@@ -64,11 +81,7 @@
* */
public FnbEndToEndPath(int destID, int srcID, int classType, int totalPkts)
{
- this.destID = destID;
- this.srcID = srcID;
- this.classtype = classType;
- this.totalPkts = totalPkts;
- this.glID = -1;
+ this(destID, srcID, classType, totalPkts, -1, false);
}
/** Sets the destination id for a connection.
@@ -106,6 +119,15 @@
totalPkts = total;
}
+
+ /** Checks whether this packet contains a file or not
+ * @return <tt>true</tt> if this is a file, <tt>false</tt> otherwise
+ */
+ public boolean isFile()
+ {
+ return isFile;
+ }
+
/** Gets the source id of a connection.
* @return the source id of the connection
* */
Modified: trunk/source/gridsim/net/fnb/FnbNetPacket.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbNetPacket.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FnbNetPacket.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -16,11 +16,11 @@
import gridsim.net.*;
/**
- * This class contains the structure of a packet
+ * This class contains the structure of a packet
* for the purpose of finite network buffers.
* <p>
- * In order to minimise duplications, hence, to reduce memory consumption,
- * common attributes to all packets have been stored in the
+ * In order to minimise duplications, hence, to reduce memory consumption,
+ * common attributes to all packets have been stored in the
* {@link gridsim.net.fnb.FnbEndToEndPath} class.
* The common attributes are destination ID, source ID, class type and total
* number of packets.
@@ -314,7 +314,7 @@
}
/** Establishes the end to end path to another entity
- * @param connection an end-to-end connection path
+ * @param connection an end-to-end connection path
*/
public void setPath(FnbEndToEndPath connection)
{
@@ -329,5 +329,14 @@
return conn.getObjectID();
}
+ /** Checks whether this packet contains a file or not
+ * @return <tt>true</tt> if this is a file, <tt>false</tt> otherwise
+ */
+ public boolean isFile()
+ {
+ return conn.isFile();
+ }
+
} // end class
+
Modified: trunk/source/gridsim/net/fnb/FnbOutput.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbOutput.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FnbOutput.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -56,14 +56,14 @@
private boolean hasStarted_; // a flag for background traffic has started
private static final int BITS = 8; // 1 byte = 8 bits
- private ArrayList packetsGridletsList_; // list of firstLastPacketsGridlet objects
+ // private ArrayList packetsGridletsList_; // list of firstLastPacketsGridlet objects
// This list contains the first/last packets belonging to each gridlet
private ArrayList filesname_fileMyIDs_; // keep a list of FileName_FileMyID objects
-
+
////////////////////////// INTERNAL CLASS /////////////////////////
-
+
private class FileName_FileMyID
{
// Since files don't have an id until they are registered, we need an id for them.
@@ -88,11 +88,11 @@
return fileMyID;
}
}
-
-
+
+
////////////////////////// INTERNAL CLASS /////////////////////////
-
-
+
+
/**
* Allocates a new Output object
* @param name the name of this object
@@ -121,7 +121,7 @@
list_ = null;
random_ = null;
hasStarted_ = false;
- packetsGridletsList_ = new ArrayList();
+ // packetsGridletsList_ = new ArrayList();
filesname_fileMyIDs_ = new ArrayList();
@@ -319,6 +319,7 @@
break;
default:
+ //System.out.println("346: "+super.get_name()+": tag: "+ev.get_tag());
defaultSend(ev, gisID, statID, shutdownID);
break;
}
@@ -332,40 +333,47 @@
* */
private void processPacketDropped(Sim_event ev)
{
- FnbDroppedUserPacket userPkt = (FnbDroppedUserPacket) ev.get_data();
- int pkt_dropped_id = userPkt.getID();
+ FnbDroppedUserObject userPkt = (FnbDroppedUserObject) ev.get_data();
+
+ // the id of object (gridlet/file) to which the dropped pkt belonged
+ int object_dropped_id = userPkt.getID();
int user_id = userPkt.getUserID();
- FnbMessage msgDrop = lookForEntity(pkt_dropped_id);
+ boolean isFile = userPkt.getIsFile();
+ FnbMessage msgDrop;
+ //FnbMessage msgDrop = lookForEntity(gl_dropped_id);
+
+ if (isFile)
+ {
+ // Tell the user that the file is failed because of the dropping of a packet
+ msgDrop = new FnbMessageDropFile(object_dropped_id, getFilename(object_dropped_id));
- int glID;
- if (msgDrop != null)
+ /****************
+ System.out.println(super.get_name() +
+ ": Sending FNB_FILE_FAILED_BECAUSE_PACKET_DROPPED to " +
+ GridSim.getEntityName(user_id) + ". File: " + object_dropped_id);
+ ****************/
+
+ super.sim_schedule(user_id, GridSimTags.SCHEDULE_NOW,
+ GridSimTags.FNB_FILE_FAILED_BECAUSE_PACKET_DROPPED, msgDrop);
+ }
+ else
{
- glID = msgDrop.getEntityID();
+ // we dropped a gridlet
+ // Tell the user that the gridlet is failed because of the dropping of a packet
+ msgDrop = new FnbMessageDropGridlet(object_dropped_id);
- if (glID != 9999)
- {
- // Check if it is a file or a gridlet
- if (msgDrop instanceof FnbMessageDropFile)
- {
- // Tell the user that the file is failed because of the dropping of a packet
- super.sim_schedule(user_id, GridSimTags.SCHEDULE_NOW,
- GridSimTags.
- FNB_FILE_FAILED_BECAUSE_PACKET_DROPPED,
- msgDrop);
- }
- else if (msgDrop instanceof FnbMessageDropGridlet)
- {
- // Tell the user that the gridlet is failed because of the dropping of a packet
- super.sim_schedule(user_id, GridSimTags.SCHEDULE_NOW,
- GridSimTags.
- FNB_GRIDLET_FAILED_BECAUSE_PACKET_DROPPED,
- msgDrop);
- }
- }
- ev = null; // new, to call the garbage collector
+ /****************
+ System.out.println(super.get_name() +
+ ": Sending FNB_GRIDLET_FAILED_BECAUSE_PACKET_DROPPED to " +
+ GridSim.getEntityName(user_id) + ". GL: " + object_dropped_id);
+ ****************/
+
+ super.sim_schedule(user_id, GridSimTags.SCHEDULE_NOW,
+ GridSimTags.FNB_GRIDLET_FAILED_BECAUSE_PACKET_DROPPED, msgDrop);
}
+ ev = null; // new, to call the garbage collector
}
@@ -514,7 +522,16 @@
private synchronized void defaultSend(Sim_event ev, int gisID, int statID,
int shutdownID)
{
- IO_data io = (IO_data) ev.get_data();
+ IO_data io = null;
+ try
+ {
+ io = (IO_data) ev.get_data();
+
+ }catch (ClassCastException e)
+ {
+ System.out.println("549 " + super.get_name() + ": ClassCastException. ev.tag: " + ev.get_tag());
+ }
+
int destId = io.getDestID();
/***** // DEBUG info
@@ -581,7 +598,7 @@
int numPackets = (int) Math.ceil(size / (MTU * 1.0));
int glID = 9999;
int fileID = 9999;
- firstLastPacketsGridlet packGl = new firstLastPacketsGridlet();
+ //firstLastPacketsGridlet packGl = new firstLastPacketsGridlet();
FnbEndToEndPath conn = null;
try{
@@ -590,11 +607,11 @@
glID = ((Gridlet) obj).getGridletID();
// Here we will keep the packets belonging to each gridlet
- packGl.setFirstPacketID(pktID_); // the first packet of this gridlet
- packGl.setGridletID(glID);
+ //packGl.setFirstPacketID(pktID_); // the first packet of this gridlet
+ //packGl.setGridletID(glID);
conn = new FnbEndToEndPath(destId, super.get_id(),
- netServiceType, numPackets, glID);
+ netServiceType, numPackets, glID, false);
}
else if (obj instanceof DataGridlet) // For the datagrid extension
@@ -603,11 +620,11 @@
// Here we will keep the packets belonging to each gridlet
- packGl.setFirstPacketID(pktID_); // the first packet of this gridlet
- packGl.setGridletID(glID);
+ //packGl.setFirstPacketID(pktID_); // the first packet of this gridlet
+ //packGl.setGridletID(glID);
conn = new FnbEndToEndPath(destId, super.get_id(),
- netServiceType, numPackets, glID);
+ netServiceType, numPackets, glID, false);
}
else if (obj instanceof Object[]) // For the datagrid extension (File)
@@ -647,11 +664,11 @@
}*/
glID = checkFilename(fileName); // get a id for the file
- packGl.setFirstPacketID(pktID_); // the first packet of this file
- packGl.setFileID(glID); // the name of the file
+ //packGl.setFirstPacketID(pktID_); // the first packet of this file
+ //packGl.setFileID(glID); // the name of the file
conn = new FnbEndToEndPath(destId, super.get_id(),
- netServiceType, numPackets, glID);
+ netServiceType, numPackets, glID, true);
//GridSimTags.FNB_PKT_CONTAINS_FILE);
//System.out.println(super.get_name() + ": fileName: " + fileName);
@@ -689,18 +706,18 @@
super.get_id(),
destId, netServiceType, numPackets, numPackets);*/
- if ((obj instanceof Gridlet) || (obj instanceof DataGridlet) ||
+ /*if ((obj instanceof Gridlet) || (obj instanceof DataGridlet) ||
(obj instanceof Object[]))
{
packGl.setLastPacketID(pktID_); // the last packet of this gridlet
packetsGridletsList_.add(packGl); // put this firstLastPacketsGridlet entity into the list
- /*System.out.println(">>>>>>>>>> "+super.get_name() +
- ": submitting entity: " + glID + " .(First, last): (" +
- packGl.getFirst() + ", " + packGl.getLast() + ")");*/
+ //System.out.println(">>>>>>>>>> "+super.get_name() +
+ // ": submitting entity: " + glID + " .(First, last): (" +
+ // packGl.getFirst() + ", " + packGl.getLast() + ")");
- }
+ }*/
enque(np, GridSimTags.SCHEDULE_NOW);
@@ -832,8 +849,7 @@
if (obj instanceof Gridlet)
{
glID = ((Gridlet) obj).getGridletID();
- conn = new FnbEndToEndPath(destId, super.get_id(), netServiceType, numPackets,
- glID);
+ conn = new FnbEndToEndPath(destId, super.get_id(), netServiceType, numPackets, glID, false);
}
else
{
@@ -899,8 +915,7 @@
if (obj instanceof Gridlet)
{
glID = ((Gridlet) obj).getGridletID();
- conn = new FnbEndToEndPath(destId, super.get_id(), netServiceType, numPackets,
- glID);
+ conn = new FnbEndToEndPath(destId, super.get_id(), netServiceType, numPackets, glID, false);
}
else
{
@@ -1018,15 +1033,18 @@
* to know which gridlet a packet belongs to.
* @return the packetsGridletsList_ of this output entity
*/
+ /*********************
private ArrayList getPacketsGridletsList()
{
return packetsGridletsList_;
}
+ *********************/
/** This function returns the entity (gridlet/file) to which a packet belongs
* @param pktID the ID of the packet of interest
* @return a FnbMessage object
*/
+ /*********************
private FnbMessage lookForEntity(int pktID)
{
FnbMessage msgDrop = null; // = new FnbMessage(9999, false);
@@ -1035,29 +1053,31 @@
firstLastPacketsGridlet flPktGl = (firstLastPacketsGridlet)
packetsGridletsList_.get(i);
- if ( (flPktGl.getFirstPacketID() <= pktID) &&
+ if ( (flPktGl.getFirstPacketID() <= pktID) &&
(flPktGl.getLastPacketID() > pktID) )
{
if (flPktGl.isFile() == true) {
- msgDrop = new FnbMessageDropFile(flPktGl.getID(),
+ msgDrop = new FnbMessageDropFile(flPktGl.getID(),
getFilename(flPktGl.getID()) );
}
- else {
- msgDrop = new FnbMessageDropGridlet( flPktGl.getID() );
- }
-
- /*****
- System.out.println(super.get_name() + ": lookForEntity: entiyID: " +
- flPktGl.getGridletID() + ". isFile " + flPktGl.getIsFile() +
- ". filename " + getFilename(msgDrop.getEntityID()));
- *****/
-
+ //else {
+ // msgDrop = new FnbMessageDropGridlet( flPktGl.getID() );
+ //}
+
+
+ //System.out.println(super.get_name() + ": lookForEntity: entiyID: " +
+ // flPktGl.getGridletID() + ". isFile " + flPktGl.getIsFile() +
+ // ". filename " + getFilename(msgDrop.getEntityID()));
+
+
return msgDrop;
}
}
return msgDrop;// if there is no entity, return this
}
+ *********************/
} // end class
+
Modified: trunk/source/gridsim/net/fnb/FnbRIPRouter.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbRIPRouter.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FnbRIPRouter.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -9,6 +9,24 @@
* Author: Gokul Poduval & Chen-Khong Tham
* Copyright (c) 2008, The University of Melbourne, Australia and
* Universidad de Castilla La Mancha (UCLM), Spain
+ *
+ * Based on class RIPRouter, by Gokul Poduval & Chen-Khong Tham,
+ * National University of Singapore.
+ * Things added or modified:
+ * private int my_id_;
+ * MIN,
+ * INTERVAL,
+ * getRoutingTable()
+ * getMyID()
+ * packetCounter_HighPriority,
+ * packetCounter_LowPriority,
+ * nextInterval
+ * fw_write(...)
+ * dequeue(...)
+ * init(...)
+ * processNetPacket(...) : FnbNetPacket
+ * processCountDroppedPkts()
+ * processEndOfSimulation(...)
*/
package gridsim.net.fnb;
@@ -25,7 +43,8 @@
* protocol used here is similar to <a
* href="http://www.ietf.org/rfc/rfc1058.txt">Routing Information Protocol
* (RIP) </a>. The routing protocol is run before Gridlets etc. can be
- * submitted.
+ * submitted. Note that this class is based on
+ * {@link gridsim.net.RIPRouter} class.
* <p>
* In case there are more than two routes to a destination, the
* route with the lower hopcount is used. Since in this simulation routers
@@ -35,23 +54,6 @@
* @invariant $none
* @since GridSim Toolkit 4.2
* @author Agustin Caminero, University of Castilla La Mancha, Spain.
- * Based on class RIPRouter, by Gokul Poduval & Chen-Khong Tham,
- * National University of Singapore.
- * Things added or modified:
- * private int my_id_;
- * MIN,
- * INTERVAL,
- * getRoutingTable()
- * get_my_id()
- * packetCounter_HighPriority,
- * packetCounter_LowPriority,
- * nextInterval
- * fw_write(...)
- * dequeue(...)
- * init(...)
- * processNetPacket(...) : FnbNetPacket
- * processCountDroppedPkts()
- * processEndOfSimulation(...)
*/
public class FnbRIPRouter extends Router
{
@@ -61,15 +63,12 @@
private Hashtable routerTable;
private Hashtable forwardTable;
private int id;
-
private int my_id_; // for a router named "router0", its my_id will be 0
-
- private final int MIN = 60; // 1 minute in seconds
- private final double INTERVAL = 2 * MIN;
- // the interval to update (reset) the packet counters
-
+
+ // the interval (in seconds) to update (reset) the packet counters
+ private static final double INTERVAL = 120;
+
private double nextInterval_dropped;
-
private boolean storeStats;
/**
@@ -78,7 +77,8 @@
* entity, please use {@link #FnbRIPRouter(String, boolean, int)}.
*
* @param name Name of this router
- * @param my_id the my_id of this router. For a router named "router0", its my_id will be 0
+ * @param my_id the user specified router ID.
+ * For a router named "router0", <tt>my_id</tt> will be 0.
* @throws NullPointerException This happens when name is empty or null
* @see #FnbRIPRouter(String, boolean, int)
* @pre name != null
@@ -98,7 +98,8 @@
* @param name Name of this router
* @param trace <tt>true</tt> if you want to record this router's
* activity, <tt>false</tt> otherwise
- * @param my_id the my_id of this router. For a router named "router0", its my_id will be 0
+ * @param my_id the user specified router ID.
+ * For a router named "router0", <tt>my_id</tt> will be 0.
* @throws NullPointerException This happens when name is empty or null
* @pre name != null
* @post $none
@@ -118,7 +119,8 @@
* entity, please use {@link #FnbRIPRouter(String, boolean, int)}.
*
* @param name Name of this router
- * @param my_id for a router named "Router0", its my_id will be 0
+ * @param my_id the user specified router ID.
+ * For a router named "router0", <tt>my_id</tt> will be 0.
* @param stats true if we want to record statistics
* @throws NullPointerException This happens when name is empty or null
* @see #FnbRIPRouter(String, boolean, int)
@@ -141,7 +143,8 @@
* @param name Name of this router
* @param trace <tt>true</tt> if you want to record this router's
* activity, <tt>false</tt> otherwise
- * @param my_id for a router named "Router0", its my_id will be 0
+ * @param my_id the user specified router ID.
+ * For a router named "router0", <tt>my_id</tt> will be 0.
* @param stats true if we want to recor statistics
* @throws NullPointerException This happens when name is empty or null
* @pre name != null
@@ -164,9 +167,7 @@
private void init()
{
this.id = super.get_id();
-
nextInterval_dropped = INTERVAL;
-
linkTable = new Hashtable();
hostTable = new Hashtable();
routerTable = new Hashtable();
@@ -358,11 +359,6 @@
processInternalEvent(ev);
break;
- case GridSimTags.END_OF_SIMULATION:
- //processEndOfSimulation(ev);
- processEndSimulation(ev);
- break;
-
case GridSimTags.FNB_UPDATE_ARED_PARAMETERS:
updateAREDParameters();
break;
@@ -376,62 +372,49 @@
}
/**
- * This function updates the value of max_p, which is the maximum dropping probability for a packet */
- public void updateAREDParameters()
+ * This function updates the value of max_p, which is the maximum
+ * dropping probability for a packet
+ */
+ private void updateAREDParameters()
{
String link;
-
FnbSCFQScheduler sched;
for (Enumeration e = schedTable.keys(); e.hasMoreElements(); )
{
link = (String) e.nextElement();
-
sched = (FnbSCFQScheduler) schedTable.get(link);
if ((schedTable.get(link)) instanceof ARED)
{
((ARED) sched).updateAREDParameters();
}
-
+
if (storeStats == true)
{
sched.updateStats();
- }
+ }
} //for (Enumeration e = schedTable.keys(); e.hasMoreElements(); )
super.sim_schedule(super.get_id(),
- GridSimTags.SCHEDULE_NOW +
- GridSimTags.FNB_UPDATE_ARED_PARAMETERS_PERIOD,
- GridSimTags.FNB_UPDATE_ARED_PARAMETERS);
-
+ GridSimTags.SCHEDULE_NOW + GridSimTags.FNB_UPDATE_ARED_PARAMETERS_PERIOD,
+ GridSimTags.FNB_UPDATE_ARED_PARAMETERS);
}
-
+
//////////////////////////////////////////////////////////////////
/**At the end of simulations, write the counters into files.
- * @param ev an event*/
- protected void processEndSimulation(Sim_event ev)
- {
- processCountDroppedPkts(ev);
-
- }
-
- // todo
+ */
protected void processEndSimulation()
{
- // empty
+ processCountDroppedPkts();
}
-
- // todo
- public ArrayList getRoutingTable()
+
+ /** Sends an initial event to itself regarding to the ARED parameters.
+ */
+ protected void sendInitialEvent()
{
- return null;
- }
-
- protected void sendInitialEvent()
- {
// This random is to avoid the initial stages of sims, where nothing happens
// (as users have not started to send gridlets).
Random random = new Random();
@@ -439,22 +422,24 @@
GridSimTags.SCHEDULE_NOW + (200 * random.nextDouble()),
GridSimTags.FNB_UPDATE_ARED_PARAMETERS);
}
-
+
//////////////////////////////////////////////////////////////////
/**
* This event is used to write in a file the current number of packets
* dropped at the schedulers of this router
- * @param ev an event*/
- private void processCountDroppedPkts(Sim_event ev)
+ */
+ private void processCountDroppedPkts()
{
- /*System.out.println(super.get_name() +
- ": COUNT_DROPPED_PKTS event arrived. Clock: " +
- GridSim.clock() + "Next event will be in (delay) " +
- (GridSimTags.SCHEDULE_NOW + 3600));*/
+ /*********************************
+ System.out.println(super.get_name() +
+ ": COUNT_DROPPED_PKTS event arrived. Clock: " +
+ GridSim.clock() + "Next event will be in (delay) " +
+ (GridSimTags.SCHEDULE_NOW + 3600));
+ ********************/
+
double clock = GridSim.clock();
-
String link;
int bufferSize;
double maxBufferSize;
@@ -507,12 +492,16 @@
*/
private synchronized void processNetPacket(Sim_event ev, int tag)
{
- processCountDroppedPkts(ev);
+ processCountDroppedPkts();
double nextTime = 0;
Packet pkt = (Packet) ev.get_data();
PacketScheduler sched = getScheduler(pkt);
-
+
+ boolean isFile = false;
+ if (pkt instanceof FnbNetPacket)
+ isFile = ((FnbNetPacket)pkt).isFile();
+
// if a packet scheduler is not found, then try reschedule this packet
// in the future
if (sched == null)
@@ -563,28 +552,24 @@
// break a large packet into smaller ones that fit into MTU
// by making null or empty packets except for the last one
FnbNetPacket np = null;
+
for (int i = 0; i < numPackets - 1; i++)
{
FnbEndToEndPath conn;
if (pkt instanceof FnbNetPacket)
{
conn = new FnbEndToEndPath(pkt.getDestID(), pkt.getSrcID(),
- pkt.getNetServiceType(),
- numPackets,
- ((FnbNetPacket) pkt).getObjectID());
+ pkt.getNetServiceType(), numPackets,
+ ((FnbNetPacket) pkt).getObjectID(), isFile);
}
else
{
conn = new FnbEndToEndPath(pkt.getDestID(), pkt.getSrcID(),
- pkt.getNetServiceType(),
- numPackets);
-
+ pkt.getNetServiceType(), numPackets);
}
- np = new FnbNetPacket(null, pkt.getID(), MTU, tag,
- conn.getSrc());
-
+
+ np = new FnbNetPacket(null, pkt.getID(), MTU, tag, conn.getSrc());
np.setPath(conn);
-
np.setLast(id);
if (super.reportWriter_ != null) {
super.write("enqueing, " + np);
@@ -695,7 +680,7 @@
{
// need to forward to another router
Object[] data = (Object[]) forwardTable.get(dest);
-
+
// in case the forwarding table is incomplete
if (data == null) {
return null;
@@ -709,7 +694,7 @@
catch (Exception e) {
sched = null;
}
-
+
return sched;
}
@@ -818,13 +803,12 @@
}
/**
- * Returns the my_id_ of this router
+ * Returns the user specified ID of this router
* @pre $none
* @post $none
- * @return the my_id_ of he entity
+ * @return the user specified ID of this router
*/
-
- public int get_my_id()
+ public int getMyID()
{
return my_id_;
}
@@ -866,7 +850,7 @@
private synchronized void receiveAd(Sim_event ev)
{
if (super.reportWriter_ != null) {
- super.write("receive router ad from, " +
+ super.write("receive router ad from, " +
GridSim.getEntityName(ev.get_src()));
}
Modified: trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java 2008-10-11 03:22:27 UTC (rev 252)
+++ trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java 2008-10-11 03:26:18 UTC (rev 253)
@@ -27,12 +27,11 @@
* - Everything regarding RED dropping algorithm
* - DROPPED_PKTS_COUNTER
* - getMaxBufferSize()
- * - setMaxBufferSize()
+ * - setMaxBufferSize()
*/
package gridsim.net.fnb;
-
import eduni.simjava.*;
import gridsim.*;
import java.util.*;
@@ -48,6 +47,7 @@
* WFQ because it does not need to compute round numbers at every iteration.
* For more details refer to <b>S. R. Golestani's</b> INFOCOM '94 paper
* <i>A self-clocked fair queueing scheme for broadband applications</i>.
+ * Note that this class is based on {@link gridsim.net.SCFQScheduler} class.
* <p>
* A SCFQ scheduler can provide differentiated service to traffic by changing
* the weights associated with a certain class of traffic. The higher the weight
@@ -69,7 +69,7 @@
* @since GridSim Toolkit 4.2
* @author Agustin Caminero, Universidad de Castilla-La Mancha (UCLM) (Spain)
*/
-public abstract class FnbSCFQScheduler extends GridSim implements PacketScheduler
+public abstract class FnbSCFQScheduler extends Sim_entity implements PacketScheduler
{
private String name_; // this scheduler name
private double baudRate_; // baud rate of this scheduler
@@ -79,41 +79,39 @@
private double CF ; // current finish number
private Hashtable flowTable;
- private int maxBufferSize = 0; // the maximum buffer size used this scheduler in the experiment
+ private int maxBufferSize = 0; // max buffer size used this scheduler in the experiment
+ private boolean storeStats; // record stats or not
- private boolean storeStats; // whether we want to store stats for this sim or not
-
private int DROPPED_PKTS_COUNTER = 0;
+ private int MAX_BUFF_SIZE_PK; // max number of packets that fit into a buffer
- private int MAX_BUFF_SIZE_PK; //max number of packets that fit into a buffer
-
private ArrayList droppedGl_user;
// in this array, we keep the list of FnbDroppedPacketInfo objects, showing the (gridlets, userID)
// already dropped in this scheduler.
// This way, we will only send a PACKET_DROPPED event for the first dropped packet of a gridlet.
// This way, we will avoid a lot of events, thus saving memory.
- public double MAX_AVG = 0.0;
+ //public double MAX_AVG = 0.0;
-
+
/**
- * Creates a new SCFQ packet scheduler with the specified name and baud rate
- * (in bits/s). The name can be useful for debugging purposes, but serves
- * no functional purposes.
- *
- * @param name Name of this scheduler
- * @param baudRate baud rate in bits/s of the port that is using
- * this scheduler.
- * @param max_buf_size maximum buffer size for routers
- * @param stats whether we want to store stats or not
- * @throws Exception This happens when the name is null or
- * the baud rate <= 0
- * @pre name != null
- * @pre baudRate > 0
- * @post $none
- */
- public FnbSCFQScheduler(String name, double baudRate, int max_buf_size, boolean stats)
- throws Exception
+ * Creates a new SCFQ packet scheduler with the specified name and baud rate
+ * (in bits/s). The name can be useful for debugging purposes, but serves
+ * no functional purposes.
+ *
+ * @param name Name of this scheduler
+ * @param baudRate baud rate in bits/s of the port that is using
+ * this scheduler.
+ * @param max_buf_size maximum buffer size for routers
+ * @param stats whether we want to store stats or not
+ * @throws Exception This happens when the name is null or
+ * the baud rate <= 0
+ * @pre name != null
+ * @pre baudRate > 0
+ * @post $none
+ */
+ public FnbSCFQScheduler(String name, double baudRate, int max_buf_size,
+ boolean stats) throws Exception
{
super(name);
@@ -122,66 +120,59 @@
}
if (baudRate <= 0) {
- throw new ParameterException("FnbSCFQScheduler(): Baudrate <= 0.");
+ throw new ParameterException("FnbSCFQScheduler(): Baudrate <= 0.");
}
-
name_ = name;
baudRate_ = baudRate;
-
MAX_BUFF_SIZE_PK = max_buf_size;
-
storeStats = stats;
-
droppedGl_user = new ArrayList();
-
init();
}
/**
- * Creates a new SCFQ packet scheduler with the specified baud rate
- * (bits/s). The name is set to a generic name: <b>"FnbSCFQScheduler"</b>.
- *
- * @param baudRate baud rate in bits/s of the port that is using
- * this scheduler.
- * @param max_buf_size maximum buffer size for routers
- * @param stats whether we want to store stats or not
- * @throws Exception This happens when the baud rate <= 0
- * @pre baudRate > 0
- * @post $none
- */
+ * Creates a new SCFQ packet scheduler with the specified baud rate
+ * (bits/s). The name is set to a generic name: <b>"FnbSCFQScheduler"</b>.
+ *
+ * @param baudRate baud rate in bits/s of the port that is using
+ * this scheduler.
+ * @param max_buf_size maximum buffer size for routers
+ * @param stats whether we want to store stats or not
+ * @throws Exception This happens when the baud rate <= 0
+ * @pre baudRate > 0
+ * @post $none
+ */
public FnbSCFQScheduler(double baudRate, int max_buf_size, boolean stats) throws Exception
{
super("FnbSCFQScheduler");
if (baudRate <= 0) {
- throw new ParameterException("FnbSCFQScheduler(): Baudrate <= 0.");
+ throw new ParameterException("FnbSCFQScheduler(): Baudrate <= 0.");
}
name_ = "FnbSCFQScheduler";
baudRate_ = baudRate;
-
MAX_BUFF_SIZE_PK = max_buf_size;
storeStats = stats;
-
droppedGl_user = new ArrayList();
init();
}
/**
- * Creates a new SCFQ packet scheduler with the specified name.
- * The baud rate is left at 0, and should be set with
- * {@link gridsim.net.PacketScheduler#setBaudRate(double)}
- * before the simulation starts.
- *
- * @param name Name of this scheduler
- * @param max_buf_size maximum buffer size for routers
- * @param stats whether we want to store stats or not
- * @throws Exception This happens when the name is null
- * @see gridsim.net.PacketScheduler#setBaudRate(double)
- * @pre name != null
- * @post $none
- */
+ * Creates a new SCFQ packet scheduler with the specified name.
+ * The baud rate is left at 0, and should be set with
+ * {@link gridsim.net.PacketScheduler#setBaudRate(double)}
+ * before the simulation starts.
+ *
+ * @param name Name of this scheduler
+ * @param max_buf_size maximum buffer size for routers
+ * @param stats whether we want to store stats or not
+ * @throws Exception This happens when the name is null
+ * @see gridsim.net.PacketScheduler#setBaudRate(double)
+ * @pre name != null
+ * @post $none
+ */
public FnbSCFQScheduler(String name, int max_buf_size, boolean stats) throws Exception
{
super(name);
@@ -192,85 +183,73 @@
name_ = name;
baudRate_ = 0;
-
MAX_BUFF_SIZE_PK = max_buf_size;
-
storeStats = stats;
-
droppedGl_user = new ArrayList();
-
init();
}
/**
- * Creates a new packet scheduler with the name <b>"FnbSCFQScheduler"</b>.
- * The baud rate is left at 0, and should be set with
- * {@link gridsim.net.PacketScheduler#setBaudRate(double)}
- * before the simulation starts.
- * @param stats whether we want to store stats or not
- * @throws Exception This happens when the name is null
- * @see gridsim.net.PacketScheduler#setBaudRate(double)
- * @pre $none
- * @post $none
- */
+ * Creates a new packet scheduler with the name <b>"FnbSCFQScheduler"</b>.
+ * The baud rate is left at 0, and should be set with
+ * {@link gridsim.net.PacketScheduler#setBaudRate(double)}
+ * before the simulation starts.
+ * @param stats whether we want to store stats or not
+ * @throws Exception This happens when the name is null
+ * @see gridsim.net.PacketScheduler#setBaudRate(double)
+ * @pre $none
+ * @post $none
+ */
public FnbSCFQScheduler(boolean stats) throws Exception
{
super("FnbSCFQScheduler");
name_ = "FnbSCFQScheduler";
baudRate_ = 0;
-
storeStats = stats;
-
droppedGl_user = new ArrayList();
-
init();
}
-
-
/**
- * Creates a new SCFQ packet scheduler with the specified baud rate
- * (bits/s). The name is set to a generic name: <b>"FnbSCFQScheduler"</b>.
- *
- * @param baudRate baud rate in bits/s of the port that is using
- * this scheduler.
- * @param max_buf_size maximum buffer size for routers
- * @throws Exception This happens when the baud rate <= 0
- * @pre baudRate > 0
- * @post $none
- */
+ * Creates a new SCFQ packet scheduler with the specified baud rate
+ * (bits/s). The name is set to a generic name: <b>"FnbSCFQScheduler"</b>.
+ *
+ * @param baudRate baud rate in bits/s of the port that is using
+ * this scheduler.
+ * @param max_buf_size maximum buffer size for routers
+ * @throws Exception This happens when the baud rate <= 0
+ * @pre baudRate > 0
+ * @post $none
+ */
public FnbSCFQScheduler(double baudRate, int max_buf_size) throws Exception
{
super("FnbSCFQScheduler");
if (baudRate <= 0) {
- throw new ParameterException("FnbSCFQScheduler(): Baudrate <= 0.");
+ throw new ParameterException("FnbSCFQScheduler(): Baudrate <= 0.");
}
name_ = "FnbSCFQScheduler";
baudRate_ = baudRate;
-
MAX_BUFF_SIZE_PK = max_buf_size;
-
droppedGl_user = new ArrayList();
-
init();
}
/**
- * Creates a new SCFQ packet scheduler with the specified name.
- * The baud rate is left at 0, and should be set with
- * {@link gridsim.net.PacketScheduler#setBaudRate(double)}
- * before the simulation starts.
- *
- * @param name Name of this scheduler
- * @param max_buf_size maximum buffer size for routers
- * @throws Exception This happens when the name is null
- * @see gridsim.net.PacketScheduler#setBaudRate(double)
- * @pre name != null
- * @post $none
- */
+ * Creates a new SCFQ packet scheduler with the specified name.
+ * The baud rate is left at 0, and should be set with
+ * {@link gridsim.net.PacketScheduler#setBaudRate(double)}
+ * before the simulation starts.
+ *
+ * @param name Name of this scheduler
+ * @param max_buf_size maximum buffer size for routers
+ * @throws Exception This happens when the name is null
+ * @see gridsim.net.PacketScheduler#setBaudRate(double)
+ * @pre name != null
+ * @post $none
+ */
public FnbSCFQScheduler(String name, int max_buf_size) throws Exception
{
super(name);
@@ -281,20 +260,16 @@
name_ = name;
baudRate_ = 0;
-
MAX_BUFF_SIZE_PK = max_buf_size;
-
droppedGl_user = new ArrayList();
-
init();
}
-
/**
- * Initialises all the attributes
- * @pre $none
- * @post $none
- */
+ * Initialises all the attributes
+ * @pre $none
+ * @post $none
+ */
private void init()
{
flowTable = new Hashtable();
@@ -306,37 +281,35 @@
if (storeStats)
{
fw_write("Interval, BufferSize, AvgBufferSize, MaxBufferSize\n",
- getSchedName() + "_MaxBufferSize.csv", false);
+ getSchedName() + "_MaxBufferSize.csv", false);
fw_write("Interval, DroppedPackets\n",
- this.getSchedName() + "_DroppedPkts.csv", false);
+ this.getSchedName() + "_DroppedPkts.csv", false);
fw_write("Clock, MAX_P, MIN_TH, MAX_TH, AVG, QUEUE_SIZE\n",
- this.getSchedName() + "_Buffers.csv", false);
-
+ this.getSchedName() + "_Buffers.csv", false);
}
-
}
- /**This function initializes the parameters of the buffers policies (RED, ARED)
- * */
- public abstract void initialize();
+ /**This function initializes the parameters of the buffers policies (RED, ARED)
+ */
+ protected abstract void initialize();
/**
- * This method allows you to set different weights for different types of
- * traffic. Traffic of class <tt>n</tt> are assigned a weight of
- * <tt>weights[n]</tt>. The ...
[truncated message content] |