|
From: <sul...@us...> - 2008-08-31 09:29:59
|
Revision: 239
http://gridsim.svn.sourceforge.net/gridsim/?rev=239&view=rev
Author: sulistio
Date: 2008-08-31 09:30:07 +0000 (Sun, 31 Aug 2008)
Log Message:
-----------
integrate the gridsim.net.fnb package (done by Agustin Caminero, UCLM) from /branches/gridsim4.0-branch2/ into this directory.
Added Paths:
-----------
trunk/source/gridsim/net/fnb/
trunk/source/gridsim/net/fnb/ARED.java
trunk/source/gridsim/net/fnb/FIFO.java
trunk/source/gridsim/net/fnb/FnbDroppedPacketInfo.java
trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java
trunk/source/gridsim/net/fnb/FnbEndToEndPath.java
trunk/source/gridsim/net/fnb/FnbInput.java
trunk/source/gridsim/net/fnb/FnbMessage.java
trunk/source/gridsim/net/fnb/FnbMessageDropFile.java
trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.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/FnbRouter.java
trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java
trunk/source/gridsim/net/fnb/FnbWhiteList.java
trunk/source/gridsim/net/fnb/Fnb_FileName_FileMyID.java
trunk/source/gridsim/net/fnb/RED.java
trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java
trunk/source/gridsim/net/fnb/source_pktNum.java
Added: trunk/source/gridsim/net/fnb/ARED.java
===================================================================
--- trunk/source/gridsim/net/fnb/ARED.java (rev 0)
+++ trunk/source/gridsim/net/fnb/ARED.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,220 @@
+/*
+ * 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.GridSim;
+import java.io.FileWriter;
+import gridsim.net.Link;
+
+/**
+ * This class implements the Adaptative Random Early Detection policy for
+ * the management of network buffers at routers.
+ * Its basic functionality is as follows:
+ * <ul>
+ * <li> There is a <tt>ARED</tt> object at each outport in routers.
+ * <li> For each incoming packet that reaches that outport port, the policy
+ * decides whether it is enqueued or dropped. This is done by calculating the
+ * average buffer size and comparing it with two thresholds.
+ * <li> If the packet is dropped, and it is not a junk packet, we must inform the
+ * 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,
+ * <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,
+ * Los Alamitos, CA, USA), April 14-16, 2008, Ottawa, Canada.
+ *
+ * @author Agustin Caminero
+ * @since GridSim Toolkit 4.2
+ */
+public class ARED extends RED
+{
+ /** Decrease factor*/
+ private double BETA;
+
+ /** Increment*/
+ private double ALPHA;
+
+ /** Target for AVG */
+ private double TARGET_LOW;
+
+ /** Target for AVG*/
+ private double TARGET_HIGH;
+
+
+ /**
+ * Creates a new Adaptative Random Early Detection (ARED) policy.
+ * @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
+ * @throws ParameterException This happens when the baud rate <= 0
+ * @pre baudRate > 0
+ * @post $none
+ */
+ public ARED(String name, double baudRate, double max_p, int max_buf_size,
+ double queue_weight, boolean stats) throws Exception
+ {
+ super(name, baudRate, max_buf_size, 0.0, 0.0, max_p, queue_weight, stats);
+ initialize();
+ }
+
+ /**
+ * 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.
+ */
+ public void updateAREDParameters()
+ {
+ double max_p = getMaxP();
+ if ((getAvg() > TARGET_HIGH) && (getMaxP() <= 0.5))
+ {
+ // increase max_p
+ setMaxP(max_p + ALPHA);
+ }
+ else if ((getAvg() < TARGET_LOW) && (max_p >= 0.01))
+ {
+ // decrease max_p
+ setMaxP(max_p * BETA);
+ }
+
+ if ((max_p / 4) < 0.01)
+ ALPHA = max_p / 4;
+ else
+ ALPHA = 0.01;
+
+ }
+
+ /** Update the stats file of this scheduler.
+ */
+ public void updateStats()
+ {
+ fw_write(GridSim.clock() + "\t" + getMaxP() + "\t" + getMinTh() + "\t" +
+ getMaxTh() + "\t" + getAvg() + "\t" + this.size() + "\n",
+ this.getSchedName() + "_Buffers");
+ }
+
+
+ /**
+ * This methods sets some parameters for the RED and ARED algorithms,
+ * such as the thresholds.
+ */
+ public void setThresholds()
+ {
+ double minTh;
+
+ double C = super.getBaudRate() / (Link.DEFAULT_MTU * 8);
+ // baudRate_is in bits per second, MTU is in bytes.
+
+ double term = -1 / C;
+ double term2 = Math.exp(term);
+
+ setQueueWeight(1 - term2);
+
+ double DELAY_TARGET = 0.005; // 5 milliseconds
+ double var = DELAY_TARGET * C / 2;
+
+ if (5 > var)
+ {
+ minTh = 5;
+ }
+ else
+ {
+ minTh = var;
+
+ }
+
+ setMinTh(minTh);
+ setMaxTh(3 * minTh);
+
+ }
+
+ /**This function initializes the parameters of the buffers policies
+ * */
+ public void initialize()
+ {
+ super.initialize();
+
+ setThresholds();
+
+ if ((getMaxP() / 4) < 0.01)
+ ALPHA = getMaxP() / 4;
+ else
+ ALPHA = 0.01;
+
+ BETA = 0.9;
+
+ }
+
+
+ /**
+ * Sets the baud rate that this scheduler will be sending packets at.
+ * @param rate the baud rate of this scheduler (in bits/s)
+ * @pre rate > 0
+ * @post $none
+ */
+ public boolean setBaudRate(double rate)
+ {
+
+ if (rate <= 0.0)
+ {
+ return false;
+ }
+ super.setBaudRateSCFQ(rate);
+
+ initialize();
+
+ return true;
+ }
+
+ /**
+ * Prints out the given message into stdout.
+ * In addition, writes it into a file.
+ * @param msg a message
+ * @param file file where we want to write
+ */
+ private static void fw_write(String msg, String file)
+ {
+ FileWriter fwriter = null;
+
+ try
+ {
+ fwriter = new FileWriter(file, true);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while opening file " + file);
+ }
+
+ try
+ {
+ fwriter.write(msg);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while writing on file " + file);
+ }
+
+ try
+ {
+ fwriter.close();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while closing file " + file);
+ }
+ }
+}
+
Added: trunk/source/gridsim/net/fnb/FIFO.java
===================================================================
--- trunk/source/gridsim/net/fnb/FIFO.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FIFO.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,362 @@
+/*
+ * 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.fnb.*;
+import gridsim.net.Packet;
+import gridsim.GridSimTags;
+import gridsim.ParameterException;
+import gridsim.GridSim;
+import java.io.FileWriter;
+import gridsim.net.*;
+
+/**
+ * This class implements the FIFO policy for the management
+ * of network buffers at routers.
+ * Its basic functionality is as follows:
+ * <ul>
+ * <li> There is a FIFO object at each outport in routers.
+ * <li> For each incoming packet that reaches that outport port, the policy
+ * decides whether it is enqueued or dropped. This is done by calculating the
+ * average buffer size and comparing it with two thresholds.
+ * <li> If the packet is dropped, and it is not a junk packet, we must inform the
+ * 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,
+ * <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,
+ * Los Alamitos, CA, USA), April 14-16, 2008, Ottawa, Canada.
+ *
+ * @author Agustin Caminero
+ * @since GridSim Toolkit 4.2
+ * */
+public class FIFO extends FnbSCFQScheduler
+{
+
+ private double QUEUE_WEIGHT; // the queue weigth
+ private double AVG;
+ private double Q_TIME;
+ private double S;
+
+ /** */
+ 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
+ * 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
+ * @throws ParameterException This happens when the name is null or
+ * the baud rate <= 0
+ * @pre name != null
+ * @pre baudRate > 0
+ * @post $none
+ */
+ public FIFO(String name, double baudRate, int max_buf_size,
+ double queue_weight, boolean stats) throws Exception
+ {
+ super(name, baudRate, max_buf_size, stats);
+
+ QUEUE_WEIGHT = queue_weight;
+
+ if (name == null)
+ {
+ throw new ParameterException("RED(): Name is null.");
+ }
+
+ if (baudRate <= 0)
+ {
+ throw new ParameterException("RED(): Baudrate <= 0.");
+ }
+
+ initialize();
+
+ }
+
+
+ /**
+ * Checks queue size and puts a packet into the queue
+ *
+ * @param pnp A Packet to be enqued by this scheduler.
+ * @return <tt>true</tt> if enqued, <tt>false</tt> otherwise
+ * @pre pnp != null
+ * @post $none
+ */
+ public synchronized boolean enque(Packet pnp)
+ {
+ /*double clock = GridSim.clock();
+ if (clock > nextInterval)
+ {
+ updateAFIFOParameters();
+ nextInterval = clock + INTERVAL;
+ }*/
+
+ checkAndInsertPacketIntoQueue(pnp); /// insert the pkt into the queue
+ //double avgQueueSize = avgQueueSize();
+ return true;
+ }
+
+
+ /**
+ * Puts a packet into the queue, checking the queue size before that.
+ *
+ * @param pnp A Packet to be enqued by this scheduler.
+ * @return <tt>true</tt> if enqued, <tt>false</tt> otherwise
+ * @pre pnp != null
+ * @post $none
+ */
+ public synchronized boolean checkAndInsertPacketIntoQueue(Packet pnp)
+ {
+
+ if (size() < getMaxBufferSizeInPkts())
+ {
+ insertPacketIntoQueue(pnp);
+ return true;
+ }
+ else
+ {
+ dropPacketFIFO(pnp);
+ return false;
+ }
+ }
+
+ /** 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.
+ * @param pnp the new incoming packet
+ * */
+ public synchronized boolean 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.
+ // Normal packets are those belonging to a gridlet.
+ // Control packets can only be dropped when the wue is full of control packets
+
+ increaseDroppedPktCounter(); // increase the counter of dropped packets
+
+ // First: check if the new incoming packet is a control packet or not.
+
+ // Check the source of the packet
+ int src_outputPort = ((FnbNetPacket) pnp).getSrcID();
+ 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
+ int dst_inputPort = ((FnbNetPacket) pnp).getDestID();
+ String dst_inputPort_str = GridSim.getEntityName(dst_inputPort);
+
+ // if neither the src or the dest of the packet are in the whitelist, then drop the packet
+ if ((GridSim.fnbWhiteList_.checkList(dst_inputPort) == false) &&
+ (GridSim.fnbWhiteList_.checkList(src_outputPort) == false))
+
+ {
+
+ /*
+ // This was the very first version of the Fnbs
+ insertPacketIntoQueue(pnp);
+ return true;*/
+
+ if (makeRoomForPacket())
+ {
+ // If we have been able of dropping a data packet, then we have room for this control packet
+ insertPacketIntoQueue(pnp);
+ }
+ 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");
+
+ System.exit(1);
+ // super.shutdownUserEntity();
+ // super.terminateIOEntities();
+
+ return false;
+ }
+ }
+
+ /*
+ // 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());*/
+
+ // 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.
+ // The source of a packet is the user/resource which sent it.
+ // So, in order to contact the entity, we do it through its output port.
+ // This is done through an event, not through the network
+
+ int entity;
+ if (src_outputPort_str.indexOf("User") != -1)
+ {
+ // if the src of the packet is an user, tell him what has happened
+
+ // NOTE: this is a HACK job. "Output_" has 7 chars. So,
+ // the idea is to get only the entity name by removing
+ // "Output_" word in the outName string.
+ String src_str = src_outputPort_str.substring(7);
+ // 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();
+
+ // String input_src_str = "Input_" + src_str;
+ // 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,
+ GridSimTags.FNB_PACKET_DROPPED,
+ new FnbDroppedUserPacket(entity, pktID));
+ // We tell the output entity of the sender of this packet
+ // that the packet has been dropped.
+
+ pnp = null; // remove the packet.
+
+ return true;
+
+ }
+
+
+ /** Calculate the avg queue size for the FIFO algorithm.
+ * */
+ public double avgQueueSize()
+ {
+
+ int q = size();
+ double time = GridSim.clock();
+
+ // Only this if is necesary for the algo
+ if (q != 0)
+ {
+ AVG = AVG + QUEUE_WEIGHT * (q - AVG);
+ }
+ else
+ {
+ AVG = Math.pow((1 - QUEUE_WEIGHT), (time - Q_TIME) / S) * AVG;
+ }
+
+ if (AVG > MAX_AVG)
+ MAX_AVG = AVG;
+
+ return AVG;
+
+ } // avgQueueSize()
+
+
+ /**
+ * Prints out the given message into stdout.
+ * In addition, writes it into a file.
+ * @param msg a message
+ * @param file file where we want to write
+ */
+ private static void fw_write(String msg, String file)
+ {
+ //System.out.print(msg);
+ FileWriter fwriter = null;
+
+ try
+ {
+ fwriter = new FileWriter(file, true);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while opening file " + file);
+ }
+
+ try
+ {
+ fwriter.write(msg);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while writing on file " + file);
+ }
+
+ try
+ {
+ fwriter.close();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while closing file " + file);
+ }
+ }
+
+ /**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)
+ * @pre rate > 0
+ * @post $none
+ */
+ public boolean setBaudRate(double rate)
+ {
+
+ if (rate <= 0.0)
+ {
+ return false;
+ }
+ super.setBaudRateSCFQ(rate);
+
+ return true;
+ }
+
+ /** Returns the avg buffer size*/
+ public double getAvg()
+ {
+ return AVG;
+ }
+
+ /** Update the stats file of this scheduler.
+ */
+ public void updateStats()
+ {
+ fw_write(GridSim.clock() + "\t\t\t\t" + AVG + "\t" + this.size() + "\n",
+ this.getSchedName() + "_Buffers");
+ }
+}
+
Added: trunk/source/gridsim/net/fnb/FnbDroppedPacketInfo.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbDroppedPacketInfo.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbDroppedPacketInfo.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+// fixme - TODO check whether can be used for dropping replicas or datasets
+
+/**This class is used by routers when they inform users of the dropping of a packet.
+ * Thus, routers tell users which gridlet got the dropped packet. This is done
+ * to minimize the network overhead caused by this informations.
+ * @author Agustin Caminero
+ * @since GridSim Toolkit 4.1
+ */
+public class FnbDroppedPacketInfo
+{
+ private int glID; // TODO try to be more general, not just gridlet
+
+ private int userID;
+
+ // private String fileName;
+
+
+
+ /**Creates a new object of this class. This is used by FnbSCFQScheduler
+ * @param g the gridlet id
+ * @param u user id
+ * */
+ public FnbDroppedPacketInfo(int g, int u)
+ {
+ glID = g;
+ userID = u;
+ }
+
+ /** Sets the filename.
+ * */
+ /*public void setFilename(String f)
+ {
+ fileName = f;
+ }*/
+
+ /** Gets the filename.
+ * @return the gridlet id.
+ * */
+ /*public String getFilename()
+ {
+ return fileName;
+ }*/
+
+ /** Gets the gridlet id.
+ * @return the gridlet id.
+ * */
+ public int getGlID()
+ {
+ return glID;
+ }
+
+
+ /** Gets the user id.
+ * @return the user id.
+ * */
+ public int getUserID()
+ {
+ return userID;
+ }
+
+}
Added: trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbDroppedUserPacket.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,170 @@
+/*
+ * 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 for the routers to tell users when one of their packets is dropped.
+ * @author Agustin Caminero, Universidad de Castilla La Mancha (Spain).
+ * @since GridSim Toolkit 4.1
+ * */
+public class FnbDroppedUserPacket implements Packet
+{
+ int userID;
+ 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 getUser()
+ {
+ return userID;
+ }
+
+
+ /** Gets the packet id
+ * @return packet id */
+ public int getPkt()
+ {
+ return pktID;
+ }
+
+
+ /**
+ * Gets this packet tag
+ * @return this packet tag
+ * @pre $none
+ * @post $none
+ */
+ public int getTag()
+ {
+ return -1;
+ }
+
+ /**
+ * Sets an entity ID from the last hop that this packet has traversed.
+ * @param last an entity ID from the last hop
+ * @pre last > 0
+ * @post $none
+ */
+ public void setLast(int last)
+ {
+
+ }
+
+ /**
+ * Gets an entity ID from the last hop that this packet has traversed.
+ * @return an entity ID
+ * @pre $none
+ * @post $none
+ */
+ public int getLast()
+ {
+ return -1;
+ }
+
+
+ /**
+ * Sets the network service type of this packet.
+ * <p>
+ * By default, the service type is 0 (zero). It is depends on the packet
+ * scheduler to determine the priority of this service level.
+ * @param serviceType this packet's service type
+ * @pre serviceType >= 0
+ * @post $none
+ */
+ public void setNetServiceType(int serviceType)
+ {
+
+ }
+
+ /**
+ * Gets the network service type of this packet
+ * @return the network service type
+ * @pre $none
+ * @post $none
+ */
+ public int getNetServiceType()
+ {
+ return -1;
+ }
+
+
+ /**
+ * Returns the ID of the source of this packet.
+ * @return source id
+ * @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 destination id
+ * @pre $none
+ * @post $none
+ */
+ public int getDestID()
+ {
+ return -1;
+ }
+
+ /**
+ * Sets the size of this packet
+ * @param size size of the packet
+ * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise
+ * @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;
+ }
+}
Added: trunk/source/gridsim/net/fnb/FnbEndToEndPath.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbEndToEndPath.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbEndToEndPath.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,202 @@
+/*
+ * 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;
+
+/**
+ * This class keeps some information which are common to all the packets of a gridlet.
+ * When a packet is dropped in a router, the router must inform the user/owner
+ * about this scenario.
+ * Since many packets from the same gridlet may get dropped, the router only sends
+ * one event for the whole process, not for each dropped packet.
+ * Thus, we put all of the common information (e.g. source and destination IDs)
+ * into this class.
+ *
+ * @since GridSim Toolkit 4.1
+ * @author Agustin Caminero
+ */
+public class FnbEndToEndPath
+{
+ private int destID;
+ private int srcID;
+ private int classtype;
+ private int totalPkts; // total num of packet that belongs to a group
+ private int glID;
+ // the id of the gridlet/file this packet belongs to, or GridSimTags.FNB_PKT_CONTAINS_FILE
+ // if the pkt contains a file
+
+ /*private String fileName; // the name of the file contained in this pkt.
+ //We have to use the file name since files may not have a id, if they've not been registered yet.*/
+
+ //private int fileMyID;// This is a temporary id for the file. This is necesary as files dont have
+ // id unteil they are registered.
+
+
+ /**Creates a new object of this class. Tihs is used in the FnbOutput class.
+ * @param destID destination id
+ * @param sourceID source id
+ * @param classType network service level
+ * @param totalPkts total number of packets this connection is made of
+ * @param glID the gridlet/file id
+ * */
+ public FnbEndToEndPath(int destID, int srcID, int classtype, int totalPkts,
+ int glID)
+ {
+ this.destID = destID;
+ this.srcID = srcID;
+ this.classtype = classtype;
+ this.totalPkts = totalPkts;
+ this.glID = glID;
+ //this.fileName = null;
+ //this.fileMyID = -1;
+ }
+
+
+ /**Creates a new object of this class. Tihs is used in the FnbOutput class.
+ * @param destID destination id
+ * @param sourceID source id
+ * @param classType network service level
+ * @param totalPkts total number of packets this connection is made of
+ * @param glID the gridlet id
+ * */
+ 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.fileName = null;
+ //this.fileMyID = -1;
+ }
+
+ /** Sets the fileName for a connection, in the case it carries a file.
+ * @param d the destination id
+ * */
+ /*public void setFileName(String f)
+ {
+ fileName = f;
+ }*/
+
+ /** Returns the fileName for a connection, in the case it carries a file.
+ * @param d the destination id
+ * */
+ /*public String getFileName()
+ {
+ return fileName;
+ }*/
+
+ /** Sets the file my_id.
+ * @param d the destination id
+ * */
+ /*public void setFileMyID(int d)
+ {
+ fileMyID = d;
+ }*/
+
+ /** Returns the file my_id.
+ * @param d the destination id
+ * */
+ /*public int getFileMyID()
+ {
+ return fileMyID;
+ }*/
+
+
+ /** Sets the destination id for a connection.
+ * @param d the destination id
+ * */
+ public void setDest(int d)
+ {
+ destID = d;
+ }
+
+
+ /** Sets the source id for a connection.
+ * @param s the source id
+ * */
+ public void setSrc(int s)
+ {
+ srcID = s;
+ }
+
+
+ /** Sets the network service level (or classtype) for a connection.
+ * @param c the network service level id
+ * */
+ public void setClasstype(int c)
+ {
+ classtype = c;
+ }
+
+
+ /** Sets the total packets for a connection.
+ * @param t total packets
+ * */
+ public void setTotalPkts(int t)
+ {
+ totalPkts = t;
+ }
+
+ /** Gets the source id of a connection.
+ * @return the source id of the connection
+ * */
+ public int getSrc()
+ {
+ return srcID;
+ }
+
+
+ /** Gets the destination id of a connection.
+ * @return the destination id of the connection
+ * */
+ public int getDest()
+ {
+ return destID;
+ }
+
+
+ /** Gets the classtype of a connection.
+ * @return the classtype of the connection
+ * */
+ public int getClasstype()
+ {
+ return classtype;
+ }
+
+
+ /** Gets the total number of packets of a connection.
+ * @return the total number of packets of the connection
+ * */
+ public int getTotalPkts()
+ {
+ return totalPkts;
+ }
+
+
+ /** Sets the gridlet/file id of a connection.
+ * @param g the gridlet id of the connection
+ * */
+ public void setObjectID(int g)
+ {
+ glID = g;
+ }
+
+
+ /** Gets the gridlet/file id of a connection.
+ * @return the gridlet id of the connection
+ * */
+ public int getObjectID()
+ {
+ return glID;
+ }
+}
Added: trunk/source/gridsim/net/fnb/FnbInput.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbInput.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbInput.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,546 @@
+/*
+ * 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 (based on Input.java)
+ * 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.fnb.*;
+import gridsim.*;
+import gridsim.net.*;
+import eduni.simjava.*;
+import java.util.*;
+import java.io.FileWriter;
+import gridsim.util.TrafficGenerator;
+
+/**
+ * GridSim FnbInput class defines a port through which a simulation entity
+ * receives data from the simulated network.
+ * <p>
+ * It maintains an event queue
+ * to serialize the data-in-flow and delivers to its parent entity.
+ * It accepts messages that comes from GridSim entities 'FnbOutput' entity
+ * and passes the same to the GridSim entity.
+ * It simulates Network communication delay depending on Baud rate
+ * and data length. Simultaneous inputs can be modeled using multiple
+ * instances of this class.
+ *
+ * @author Agustin Caminero, Universidad de Castilla La Mancha (Spain).
+ * Based on Input class, by Manzur Murshed and Rajkumar Buyya.
+ * @since GridSim Toolkit 4.1
+ *
+ * Things added or modifyed:
+ * - getDataFromLink(...)
+ * - source_PktNum_array
+ * - FnbNetPacket instead of NetPacket
+ *
+ */
+public class FnbInput extends Sim_entity implements NetIO
+{
+ private Sim_port inPort_;
+ private Link link_;
+ private double baudRate_;
+ private static final int BITS = 8; // 1 byte = 8 bits
+
+ private ArrayList source_PktNum_array;
+
+ /**
+ * Allocates a new Input object
+ * @param name the name of this object
+ * @param baudRate the communication speed
+ * @throws NullPointerException This happens when creating this entity
+ * before initializing GridSim package or this entity name
+ * is <tt>null</tt> or empty
+ * @pre name != null
+ * @pre baudRate >= 0.0
+ * @post $none
+ */
+ public FnbInput(String name, double baudRate) throws NullPointerException
+ {
+ super(name);
+ this.baudRate_ = baudRate;
+ link_= null;
+
+ inPort_ = new Sim_port("input_buffer");
+ super.add_port(inPort_);
+
+ source_PktNum_array = new ArrayList();
+ }
+
+ /**
+ * Sets the Input entities link. This should be used only if the network
+ * extensions are being used.
+ * @param link the link to which this Input entity should send data
+ * @pre link != null
+ * @post $none
+ */
+ public void addLink(Link link) {
+ this.link_ = link;
+ }
+
+ /**
+ * Gets the baud rate
+ * @return the baud rate
+ * @deprecated As of GridSim 2.1, replaced by {@link #getBaudRate()}
+ * @pre $none
+ * @post $result >= 0.0
+ */
+ public double GetBaudRate() {
+ return this.getBaudRate();
+ }
+
+ /**
+ * Gets the baud rate
+ * @return the baud rate
+ * @pre $none
+ * @post $result >= 0.0
+ */
+ public double getBaudRate() {
+ return baudRate_;
+ }
+
+ /**
+ * Gets the I/O real number based on a given value
+ * @param value the specified value
+ * @return real number
+ * @deprecated As of GridSim 2.1, replaced by {@link #realIO(double)}
+ * @pre value >= 0.0
+ * @post $result >= 0.0
+ */
+ public double real_io(double value) {
+ return this.realIO(value);
+ }
+
+ /**
+ * Gets the I/O real number based on a given value
+ * @param value the specified value
+ * @return real number
+ * @pre value >= 0.0
+ * @post $result >= 0.0
+ */
+ public double realIO(double value) {
+ return GridSimRandom.realIO(value);
+ }
+
+ /**
+ * This is an empty method and only applicable to
+ * {@link gridsim.net.Output} class.
+ * @param gen a background traffic generator
+ * @param userName a collection of user entity name (in String object).
+ * @return <tt>false</tt> since this method is not used by this class.
+ * @pre gen != null
+ * @pre userName != null
+ * @post $none
+ * @see gridsim.net.Output
+ */
+ public boolean setBackgroundTraffic(TrafficGenerator gen,
+ Collection userName)
+ {
+ return false;
+ }
+
+ /**
+ * This is an empty method and only applicable to
+ * {@link gridsim.net.Output} class.
+ * @param gen a background traffic generator
+ * @return <tt>false</tt> since this method is not used by this class.
+ * @pre gen != null
+ * @post $none
+ * @see gridsim.net.Output
+ */
+ public boolean setBackgroundTraffic(TrafficGenerator gen)
+ {
+ return false;
+ }
+
+ /**
+ * A method that gets one process event at one time until the end
+ * of a simulation, then delivers an event to the entity (its parent)
+ * @pre $none
+ * @post $none
+ */
+ public void body()
+ {
+ // Process events
+ Object obj = null;
+ while ( Sim_system.running() )
+ {
+ Sim_event ev = new Sim_event();
+ super.sim_get_next(ev); // get the next event in the queue
+ obj = ev.get_data(); // get the incoming data
+
+ // if the simulation finishes then exit the loop
+ if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) {
+ break;
+ }
+
+ // if this entity is not connected in a network topology
+ if (obj != null && obj instanceof IO_data) {
+ getDataFromEvent(ev);
+ }
+
+ // if this entity belongs to a network topology
+ else if (obj != null && link_ != null) {
+ getDataFromLink(ev);
+ }
+
+ ev = null; // reset to null for gc to collect
+ }
+ }
+
+ /**
+ * Process incoming event for data without using the network extension
+ * @param ev a Sim_event object
+ * @pre ev != null
+ * @post $none
+ */
+ private void getDataFromEvent(Sim_event ev)
+ {
+ IO_data io = (IO_data) ev.get_data();
+
+ // if the sender is not part of the overall network topology
+ // whereas this entity is, then need to return back the data,
+ // since it is not compatible.
+ if (link_ != null)
+ {
+ // outName = "Output_xxx", where xxx = sender entity name
+ String outName = GridSim.getEntityName( ev.get_src() );
+
+ // NOTE: this is a HACK job. "Output_" has 7 chars. So,
+ // the idea is to get only the entity name by removing
+ // "Output_" word in the outName string.
+ String name = outName.substring(7);
+
+ // if the sender is not system GIS then ignore the message
+ if (GridSim.getEntityId(name) != GridSim.getGridInfoServiceEntityId())
+ {
+ // sends back the data to "Input_xxx", where
+ // xxx = sender entity name. If not sent, then the sender
+ // will wait forever to receive this data. As a result,
+ // the whole simulation program will be hanged or does not
+ // terminate successfully.
+ int id = GridSim.getEntityId("Input_" + name);
+ super.sim_schedule(id, 0.0, ev.get_tag(), io);
+
+ // print an error message
+ System.out.println(super.get_name() + ".body(): Error - " +
+ "incompatible message protocol.");
+ System.out.println(" Sender: " + name + " is not part " +
+ "of this entity's network topology.");
+ System.out.println(" Hence, sending back the received data.");
+ System.out.println();
+ return;
+ }
+ }
+
+ // NOTE: need to have a try-catch statement. This is because,
+ // if the above if statement holds, then Input_receiver will send
+ // back to Input_sender without going through Output_receiver entity.
+ // Hence, a try-catch is needed to prevent exception of wrong casting.
+ try
+ {
+ // Simulate Transmission Time after Receiving
+ // Hold first then dispatch
+ double senderBaudRate = ( (Output)
+ Sim_system.get_entity(ev.get_src()) ).getBaudRate();
+
+ // NOTE: io is in byte and baud rate is in bits. 1 byte = 8 bits
+ // So, convert io into bits
+ double minBaudRate = Math.min(baudRate_, senderBaudRate);
+ double communicationDelay = GridSimRandom.realIO(
+ (io.getByteSize() * BITS) / minBaudRate);
+
+ // NOTE: Below is a deprecated method for SimJava 2
+ //super.sim_hold(communicationDelay);
+ super.sim_process(communicationDelay); // receiving time
+ }
+ catch (Exception e) {
+ // .... empty
+ }
+
+ // Deliver Event to the entity (its parent) to which
+ // it is acting as buffer
+ super.sim_schedule( inPort_, GridSimTags.SCHEDULE_NOW,
+ ev.get_tag(), io.getData() );
+ }
+
+ /**
+ * Process incoming events from senders that are using the network
+ * extension
+ * @param ev a Sim_event object
+ * @pre ev != null
+ * @post $none
+ */
+ private void getDataFromLink(Sim_event ev)
+ {
+ Object obj = ev.get_data();
+ if (obj instanceof Packet)
+ {
+ // decrypt the packet into original format
+ Packet pkt = (Packet) ev.get_data();
+
+ /*System.out.println(super.get_name() + ": >>>> FnbInput. PktID: " +
+ ((FnbNetPacket) pkt).getID() + ". glID: " +
+ ((FnbNetPacket) pkt).getGlID());*/
+
+ if (pkt instanceof InfoPacket)
+ {
+ processPingRequest( (InfoPacket) pkt);
+ return;
+ }
+
+ source_pktNum srcPktNum;
+ // all except last packet in a data session are null packets
+ if (pkt instanceof FnbNetPacket)
+ {
+ FnbNetPacket np = (FnbNetPacket) pkt;
+ int tag = np.getTag();
+
+ // ignore incoming junk packets
+ if (tag == GridSimTags.JUNK_PKT) {
+ return;
+ }
+
+
+ // We have to count the gridlet packets arriving at a resource/user,
+ // so that we make sure all the packets belonging to a gridlet arrive.
+ // If any of those packets of a gridlet don't arrive, then the gridlet is failed.
+ // In that case, the router where those packets have been dropped will have told
+ // the user about the dropping.
+ String name = super.get_name();
+
+
+ int src_outputPort = ((FnbNetPacket) np).getSrcID();
+ //String src_outputPort_str = GridSim.getEntityName(src_outputPort);
+
+ /*
+ // Uncomment this for more info on the progress of sims
+ if (name.compareTo("Input_SIM_0_Res_0") == 0)
+ System.out.println(super.get_name() +
+ ": packet arrived to the res" +
+ ". Pkt num: " +
+ ((FnbNetPacket) np).getPacketNum() +
+ " from " + src_outputPort_str);*/
+
+ //int pktID = ((FnbNetPacket) np).getID();
+ //int PrevPktNum; // The pkt Num of the previous packet
+ int pktNum = ((FnbNetPacket) np).getPacketNum();
+ int glID = ((FnbNetPacket) np).getObjectID();
+ srcPktNum = lookForSrcPktNum(src_outputPort, glID);
+
+ if (srcPktNum == null)
+ {
+ // Not correct anymore
+ // Remove form the source_PktNum_array the items whose src is the
+ // src_outputPort, as those gridlets will be failed (dropped packets)
+ // removeFromSrcPktNum(src_outputPort);
+
+ // We create a new source_pktNum object only if the packet is the first in this gridlet.
+ // This means that if the gridlet is failed (as some packets have been dropped),
+ // no source_pktNum wil be created.
+
+ if (pktNum == 1)
+ {
+ srcPktNum = new source_pktNum(src_outputPort, glID);
+
+ source_PktNum_array.add(srcPktNum);
+
+ /*System.out.println(super.get_name() +
+ ": >>>> FnbInput. First pkt of a gl has just arrived . PktID: " +
+ ((FnbNetPacket) pkt).getID() + ". glID: " +
+ ((FnbNetPacket) pkt).getGlID());*/
+
+ }
+ }//if (srcPktNum == null)
+
+ if (srcPktNum != null)
+ {
+ // If srcPktNum != null this means that the srcPktNum object is correct.
+ // We have not lost any packet, so the gridlet is ok up to now.
+ // Hence, update the pktNum in the array.
+ //srcPktNum.setPktNum(pktNum);
+ //srcPktNum.setPktID(pktID);
+
+ // Increase the number of pkts already received
+ //srcPktNum.setNumOfPkts(srcPktNum.getNumOfPkts() + 1);
+ srcPktNum.increaseNumOfArrivedPkts();
+
+ // If this is the last packet of the gridlet, then the gridlet is ok
+ int totalPkt = ((FnbNetPacket) np).getTotalPackets();
+ if (srcPktNum.getNumOfPkts() == totalPkt)
+ srcPktNum.setOk(true);
+
+
+
+ // ignore incoming null dummy packets
+ if (tag == GridSimTags.EMPTY_PKT && np.getData() == null)
+ {
+ return;
+ }
+ else
+ {
+ // This is the last packet in the gridlet, so we have to check
+ // if the previous packets have arrived.
+ if (srcPktNum.getOk() == true)
+ {
+ // The gridlet has arrived perfect, with no packet lost
+
+ // convert the packets into IO_data
+ Object data = np.getData();
+
+
+ IO_data io = new IO_data(data, np.getSize(),
+ inPort_.get_dest());
+
+ // send the data into entity input port
+ super.sim_schedule(inPort_,
+ GridSimTags.SCHEDULE_NOW,
+ tag,
+ io.getData());
+
+ /*// REMOVE!!!
+ System.out.println("\n*********" + super.get_name() +
+ ": Data (maybe a gridlet) arrived. Pkt num: " +
+ ((FnbNetPacket) np).getPacketNum() +
+ " from " + src_outputPort_str +
+ "\n");*/
+
+ name = super.get_name();
+ if (name.indexOf("Input_SIM_0_Res_5") != -1)
+ {
+ fw_write(
+ "Data (maybe a gridlet) arrived at the Resource\n",
+ super.get_name());
+
+ /*System.out.println("\n*********" +
+ super.get_name() +
+ ": Data (maybe a gridlet) arrived at the Resource. Pkt num: " +
+ ((FnbNetPacket) np).getPacketNum() +
+ " from " + src_outputPort_str +
+ "\n");*/
+ }
+
+ } // if (srcPktNum.getOk() == true)
+
+ } // else of the if (tag == GridSimTags.EMPTY_PKT && np.getData() == null)
+
+ }//if (srcPktNum != null)
+
+ }// if (pkt instanceof FnbNetPacket)
+
+ }// if (obj instanceof Packet)
+
+ }
+
+ /**
+ * Look for a especific source_pktNum object in the source_PktNum_array
+ * @param src the source of the packet
+ * @param pktID the unique id of a packet
+ * @param glID the id of the girdlet this packet belongs to.
+ * @return a source_pktNum object whose source is src, null otherwise
+ * */
+ public source_pktNum lookForSrcPktNum(int src, int glID)
+ {
+
+ source_pktNum srcPktNum;
+ for (int i = 0; i < source_PktNum_array.size(); i++)
+ {
+ srcPktNum = (source_pktNum) source_PktNum_array.get(i);
+
+ if ((srcPktNum.getSource() == src) && (srcPktNum.getGlID() == glID))
+ return srcPktNum;
+ }
+
+ return null;
+
+ }
+
+ /**
+ * Look for a especific source_pktNum object in the source_PktNum_array
+ * @param src the source of the packet
+ * @return a source_pktNum object whose source is src, null otherwise
+ * */
+ public void removeFromSrcPktNum(int src)
+ {
+
+ source_pktNum srcPktNum;
+ for (int i = 0; i < source_PktNum_array.size(); i++)
+ {
+ srcPktNum = (source_pktNum) source_PktNum_array.get(i);
+
+ if (srcPktNum.getSource() == src)
+ source_PktNum_array.remove(i);
+ }
+
+ }
+
+
+
+ /**
+ * Prints out the given message into stdout.
+ * In addition, writes it into a file.
+ * @param msg a message
+ * @param file file where we want to write
+ */
+ private static void fw_write(String msg, String file)
+ {
+ //System.out.print(msg);
+ FileWriter fwriter = null;
+
+ try
+ {
+ fwriter = new FileWriter(file, true);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while opening file " + file);
+ }
+
+ try
+ {
+ fwriter.write(msg);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while writing on file " + file);
+ }
+
+ try
+ {
+ fwriter.close();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Unwanted errors while closing file " + file);
+ }
+ }
+
+
+ /**
+ * Processes a ping request
+ * @param pkt a packet for pinging
+ * @pre pkt != null
+ * @post $none
+ */
+ private void processPingRequest(InfoPacket pkt)
+ {
+ // add more information to ping() packet
+ pkt.addHop( inPort_.get_dest() );
+ pkt.addEntryTime( GridSim.clock() );
+
+ IO_data io = new IO_data( pkt, pkt.getSize(), inPort_.get_dest() );
+
+ // send this ping() packet to the entity
+ super.sim_schedule(inPort_, GridSimTags.SCHEDULE_NOW,
+ pkt.getTag(), io.getData());
+ }
+
+} // end class
+
Added: trunk/source/gridsim/net/fnb/FnbMessage.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbMessage.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbMessage.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+public interface FnbMessage
+{
+ public void setEntityID(int i);
+
+ public int getEntityID();
+
+}
Added: trunk/source/gridsim/net/fnb/FnbMessageDropFile.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbMessageDropFile.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbMessageDropFile.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,50 @@
+/*
+ * 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.fnb.*;
+
+public class FnbMessageDropFile implements FnbMessage
+{
+ int fileID;
+ String filename;
+
+ public FnbMessageDropFile(int e, String f)
+ {
+ fileID = e;
+ filename = f;
+ }
+
+ public void setEntityID(int i)
+ {
+ fileID = i;
+ }
+
+
+ public int getEntityID()
+ {
+ return fileID;
+ }
+
+ public void setFilename(String f)
+ {
+ filename = f;
+ }
+
+ public String getFilename()
+ {
+ return filename;
+ }
+
+
+}
Added: trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,38 @@
+/*
+ * 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.fnb.*;
+
+public class FnbMessageDropGridlet implements FnbMessage
+{
+ int gridletID;
+
+ public FnbMessageDropGridlet (int e)
+ {
+ gridletID = e;
+ }
+
+ public void setEntityID(int i)
+ {
+ gridletID = i;
+ }
+
+
+ public int getEntityID()
+ {
+ return gridletID;
+ }
+
+
+}
Added: trunk/source/gridsim/net/fnb/FnbNetPacket.java
===================================================================
--- trunk/source/gridsim/net/fnb/FnbNetPacket.java (rev 0)
+++ trunk/source/gridsim/net/fnb/FnbNetPacket.java 2008-08-31 09:30:07 UTC (rev 239)
@@ -0,0 +1,340 @@
+/*
+ * 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.*;
+import gridsim.net.*;
+
+/**
+ * Structure of a packet used to encapsulate data passing through the network,
+ * for the finite network buffers.
+ *
+ * In order to reduce the memory consumption, I moved some stuff which is common to all the packets
+ * of a transmission to another class, called FnbEndToEndPath.
+ * The stuff I moved is destID, srcID, classtype and totalPkts.
+ * I also added a FnbEndToEndPath object, which is common for all the packets of a connection
+ * (of the same gridlet).
+ *
+ *
+ * @invariant $none
+ * @since GridSim Toolkit 4.2
+ * @author Agustin Caminero
+ */
+public class FnbNetPacket implements Packet
+{
+ private long size; // packet size (for calculating transmission time)
+ private Object obj; // the actual object, the type depends on context
+
+ // original tag with which the encapsulated object was submitted
+ private int tag;
+
+ // the last entity encountered by the object, used to determine direction
+ private int last;
+
+ private String desc_; // description of this packet
+ private int pktNum; // packet num in one group
+ private int pktID_; // a unique packet ID issued by an entity
+
+ private FnbEndToEndPath conn;
+
+ /**
+ * Constructs a network packet for data that fits into a single network
+ * packet.
+ *
+ * @param data The data to be encapsulated.
+ * @param pktID The ID of this packet
+ * @param size The size of the data (in bytes)
+ * @param tag The original tag which was used with the data, its
+ * reapplied when the data is extracted from the NetPacket.
+ * @param srcID The id of the entity where the packet was created.
+ * @param destID The destination to which the packet has to be sent.
+ * @pre $none
+ * @post $none
+ */
+ public FnbNetPacket(Object data, int pktID, long size, int tag, int srcID)
+ {
+ this.obj = data ;
+ this.size = size ;
+ this.tag = tag ;
+
+ this.last = srcID ;
+ this.pktID_ = pktID;
+
+ this.pktNum = 1;
+
+ this.desc_ = null;
+ }
+
+ /**
+ * This is used to construct a packet that is one in a series. This happens
+ * when a large piece of data is required to be brokwn down into smaller
+ * chunks so that they can traverse of links that only support a certain
+ * MTU. It also allows setting of a classtype so that network schedulers
+ * maybe provide differntial service to it.
+ *
+ * @param data The data to be encapsulated.
+ * @param pktID The ID of this packet
+ * @param size The size of the data (in bytes)
+ * @param tag The original tag which was used with the data, its
+ * reapplied when the data is extracted from the NetPacket.
+ * @param srcID The id of the entity where the packet was created.
+ * @param destID The destination to which the packet has to be sent.
+ * @param netServiceType the network class type of this packet
+ * @param pktNum The packet number of this packet in its series. If there
+ * are 10 packets, they should be numbered from 1 to 10.
+ * @param totalPkts The total number of packets that the original data was
+ * split into. This is used by the receiver to confirm that
+ * all packets have been received.
+ * @pre $none
+ * @post $none
+ */
+ public FnbNetPacket(Object data, int pktID, long size, int tag, int srcID, int pktNum)
+ {
+ this.obj = data;
+ this.size = size;
+ this.tag = tag;
+
+ this.last = srcID;
+
+ this.pktNum = pktNum;
+ this.pktID_ = pktID;
+
+ this.desc_ = null;
+ }
+
+ /**
+ * Returns a description of this packet
+ * @return a description of this...
[truncated message content] |