From: <sul...@us...> - 2008-08-04 02:15:25
|
Revision: 197 http://gridsim.svn.sourceforge.net/gridsim/?rev=197&view=rev Author: sulistio Date: 2008-08-04 02:15:29 +0000 (Mon, 04 Aug 2008) Log Message: ----------- comment debugging statements Modified Paths: -------------- trunk/source/gridsim/net/flow/FilterFlow.java trunk/source/gridsim/net/flow/Flow.java trunk/source/gridsim/net/flow/FlowInput.java trunk/source/gridsim/net/flow/FlowLink.java trunk/source/gridsim/net/flow/FlowOutput.java trunk/source/gridsim/net/flow/FlowPacket.java trunk/source/gridsim/net/flow/FlowRouter.java Modified: trunk/source/gridsim/net/flow/FilterFlow.java =================================================================== --- trunk/source/gridsim/net/flow/FilterFlow.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/FilterFlow.java 2008-08-04 02:15:29 UTC (rev 197) @@ -4,8 +4,8 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * + * Copyright (c) 2008, The University of Melbourne, Australia * Author: James Broberg - * */ package gridsim.net.flow; @@ -26,16 +26,14 @@ * (incoming buffer), or used to selectively wait for a future event. * <br> <br> * - * - * * @author James Broberg - * @since GridSim Toolkit 5.0 + * @since GridSim Toolkit 4.2 * @invariant $none */ public class FilterFlow extends Sim_predicate { private int tag_; // event tag to be matched - private int flowID_; // event or flow ID + private int flowID_; // event or flow ID /** Modified: trunk/source/gridsim/net/flow/Flow.java =================================================================== --- trunk/source/gridsim/net/flow/Flow.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/Flow.java 2008-08-04 02:15:29 UTC (rev 197) @@ -1,14 +1,11 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 4.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 * - * James Broberg - * - * August 2007 - * - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * Flow.java - Interface of a Network Flow. - * + * Copyright (c) 2008, The University of Melbourne, Australia + * Author: James Broberg */ package gridsim.net.flow; @@ -17,7 +14,7 @@ /** * This the structure for network flows. * - * @since GridSim Toolkit 4.0 + * @since GridSim Toolkit 4.2 * @author James Broberg, The University of Melbourne */ public interface Flow Modified: trunk/source/gridsim/net/flow/FlowInput.java =================================================================== --- trunk/source/gridsim/net/flow/FlowInput.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/FlowInput.java 2008-08-04 02:15:29 UTC (rev 197) @@ -1,14 +1,11 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 4.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 * + * Copyright (c) 2008, The University of Melbourne, Australia * Author: James Broberg (based on Input.java) - * - * March 2007 - * - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * FlowInput.java - Simulates a network input port - * */ package gridsim.net.flow; @@ -28,14 +25,14 @@ * <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 'FlowOutput' entity - * and passes the same to the GridSim entity. + * It accepts event messages that comes from the 'FlowOutput' entity + * and passes the event data to the GridSim entity. * It simulates Network communication delay depending on current bottleneck Baud rate * and data length. Simultaneous inputs can be modeled using multiple * instances of this class. * * @author James Broberg - * @since GridSim Toolkit 5.0 + * @since GridSim Toolkit 4.2 * @invariant $none */ public class FlowInput extends Sim_entity implements NetIO @@ -43,10 +40,6 @@ private Sim_port inPort_; private Link link_; private double baudRate_; - private static final int BITS = 8; // 1 byte = 8 bits - private final int SIZE = 8; // 1 byte in bits - - private HashMap<Integer, Packet> activeFlows_; // stores a list of active Flows @@ -180,39 +173,42 @@ super.sim_get_next(ev); // get the next event in the queue obj = ev.get_data(); // get the incoming data + /**** NOTE: debugging System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); System.out.println(super.get_name() + ".body(): ev.get_src() is " + ev.get_src()); - + *****/ + // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { break; // Check forecast of active flow and pass it onto Entity if still active } else if(ev.get_tag() == GridSimTags.FLOW_HOLD) { - System.out.println(super.get_name() + ".body(): checkForecast() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".body(): checkForecast() + at time = " + GridSim.clock()); checkForecast(ev); // Update flow duration forecast as a flow's bottleneck bandwidth has changed } else if (ev.get_tag() == GridSimTags.FLOW_UPDATE) { - System.out.println(super.get_name() + ".body(): updateForecast() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".body(): updateForecast() + at time = " + GridSim.clock()); updateForecast(ev); // if this entity is not connected in a network topology } else if (obj != null && obj instanceof IO_data) { - System.out.println(super.get_name() + ".body(): getDataFromEvent() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".body(): getDataFromEvent() + at time = " + GridSim.clock()); getDataFromEvent(ev); // if this entity belongs to a network topology } else if (obj != null && link_ != null) { - System.out.println(super.get_name() + ".body(): getDataFromLink() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".body(): getDataFromLink() + at time = " + GridSim.clock()); getDataFromLink(ev); } ev = null; // reset to null for gc to collect } - System.out.println(super.get_name() + ":%%%% Exiting body() at time " + - GridSim.clock() ); + //System.out.println(super.get_name() + ":%%%% Exiting body() at time " + + // GridSim.clock() ); } /** - * Check the forecast of a flow, and send data to output port if flow still exists + * Check the forecast of a flow, and send data to output port if flow + * still exists * * @param ev the flow hold notification event * @pre ev != null @@ -222,7 +218,7 @@ int pktID = (Integer) ev.get_data(); // ID of flow to be checked FlowPacket fp = null; // Reference to flow packet that needs forecast update - System.out.println(super.get_name() + ".checkForecast(): checking pkt id # " + pktID); + //System.out.println(super.get_name() + ".checkForecast(): checking pkt id # " + pktID); // If flow hasn't already finished, send it to inPort if ((fp = (FlowPacket) activeFlows_.get(pktID)) != null) { @@ -232,8 +228,8 @@ super.sim_schedule(inPort_, GridSimTags.SCHEDULE_NOW, fp.getTag() , io.getData()); activeFlows_.remove(pktID); - System.out.println(super.get_name() + ".checkForecast(): flow came from " + GridSim.getEntityName(fp.getSrcID()) - + " heading to " + GridSim.getEntityName(fp.getDestID())); + //System.out.println(super.get_name() + ".checkForecast(): flow came from " + GridSim.getEntityName(fp.getSrcID()) + // + " heading to " + GridSim.getEntityName(fp.getDestID())); // Deregister flow on all active links Iterator it = (fp.getLinks_()).iterator(); @@ -243,7 +239,7 @@ } } else { - System.out.println(super.get_name() + ".checkForecast(): pkt id # " + pktID + " already removed"); + //System.out.println(super.get_name() + ".checkForecast(): pkt id # " + pktID + " already removed"); } @@ -267,14 +263,14 @@ int sourceID = ev.get_src(); // ID of source of notification (FlowLink) int cancelledFlow = 0; // Count of canceled future events that match old forecast - System.out.println(super.get_name() + ".updateForecast(): updating pkt id # " + pktID); + //System.out.println(super.get_name() + ".updateForecast(): updating pkt id # " + pktID); // If flow hasn't already finished and been cleared... if ((fp = (FlowPacket) activeFlows_.get(pktID)) != null) { remSizeOld = fp.getRemSize(); bandwidthOld = fp.getBandwidth_(); - System.out.println(super.get_name() + "updateForecast(): rem size is " + remSizeOld + - "BW old is " + bandwidthOld + " last update " + fp.getUpdateTime()); + //System.out.println(super.get_name() + "updateForecast(): rem size is " + remSizeOld + + // "BW old is " + bandwidthOld + " last update " + fp.getUpdateTime()); Iterator it = (fp.getLinks_()).iterator(); // Find the source link of this notification and the associated bottleneck bandwidth @@ -286,20 +282,22 @@ } } - fp.setRemSize((long)((remSizeOld) - ((GridSim.clock()-fp.getUpdateTime())*(bandwidthOld/BITS)))); - duration = (fp.getRemSize()*BITS)/fp.getBandwidth_(); - System.out.println(super.get_name() + " new forecast end time is " + (GridSim.clock() + duration)); + fp.setRemSize((long)((remSizeOld) - ((GridSim.clock()-fp.getUpdateTime())*(bandwidthOld/NetIO.BITS)))); + duration = (fp.getRemSize()*NetIO.BITS)/fp.getBandwidth_(); + //System.out.println(super.get_name() + " new forecast end time is " + (GridSim.clock() + duration)); // Find old forecast and delete it! FilterFlow filter = new FilterFlow(fp.getID(), GridSimTags.FLOW_HOLD); cancelledFlow = this.sim_cancel(filter, null); + /**** // debugging if (cancelledFlow != 0) { System.out.println(super.get_name() + ".updateForecast(): old forecast cancelled #matches " + cancelledFlow); } + ******/ - System.out.println(super.get_name() + " setting updated forecast for packet #" + fp.getID()); + //System.out.println(super.get_name() + " setting updated forecast for packet #" + fp.getID()); // Make a note of the time when this forecast update was performed fp.setUpdateTime(GridSim.clock()); // Set new future event with the correct finish time @@ -368,7 +366,7 @@ // So, convert io into bits double minBaudRate = Math.min(baudRate_, senderBaudRate); double communicationDelay = GridSimRandom.realIO( - (io.getByteSize() * BITS) / minBaudRate); + (io.getByteSize() * NetIO.BITS) / minBaudRate); // NOTE: Below is a deprecated method for SimJava 2 //super.sim_hold(communicationDelay); @@ -411,7 +409,7 @@ { FlowPacket np = (FlowPacket) pkt; int tag = np.getTag(); - System.out.println("Packet id is " + np.getID()); + //System.out.println("Packet id is " + np.getID()); // ignore incoming junk packets if (tag == GridSimTags.JUNK_PKT) { @@ -423,8 +421,8 @@ return; } - System.out.println(super.get_name() + ".getDataFromLink() Time now " + GridSim.clock() - + " bottleneck is " + np.getBandwidth_() + " sum lat is " + np.getLatency() ); + //System.out.println(super.get_name() + ".getDataFromLink() Time now " + GridSim.clock() + // + " bottleneck is " + np.getBandwidth_() + " sum lat is " + np.getLatency() ); // if flow terminates at next entity, add to active flows // & hold for appropriate duration @@ -433,11 +431,11 @@ || pkt.getTag() == GridSimTags.JUNK_PKT) { np.setStartTime(GridSim.clock()); np.setUpdateTime(GridSim.clock()); - duration = np.getSize()*SIZE / np.getBandwidth_(); + duration = np.getSize()*NetIO.BITS / np.getBandwidth_(); activeFlows_.put(pkt.getID(), pkt); super.sim_schedule(super.get_id(), duration, GridSimTags.FLOW_HOLD, new Integer(pkt.getID())); - System.out.println(super.get_name() + ".getDataFromLink() initial forecast flow end at " + (GridSim.clock() - + duration)); + //System.out.println(super.get_name() + ".getDataFromLink() initial forecast flow end at " + (GridSim.clock() + // + duration)); return; } Modified: trunk/source/gridsim/net/flow/FlowLink.java =================================================================== --- trunk/source/gridsim/net/flow/FlowLink.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/FlowLink.java 2008-08-04 02:15:29 UTC (rev 197) @@ -1,14 +1,11 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 4.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 * + * Copyright (c) 2008, The University of Melbourne, Australia * Author: James Broberg - * - * March 2007 - * - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * FlowLink.java - Simulates a network link with active flows (based on SimpleLink.java) - * */ package gridsim.net.flow; @@ -27,7 +24,7 @@ * on SimpleLink.java by Gokul Poduval & Chen-Khong Tham * * @invariant $none - * @since GridSim Toolkit 5.0 + * @since GridSim Toolkit 4.2 * @author James Broberg, The University of Melbourne */ @@ -77,28 +74,6 @@ } /** - * Constructs a link with some default parameters. It simulates a link with - * a default value of baud rate, propagation delay and MTU. - * - * @param name Name of this Link - * @throws NullPointerException This happens when name is empty or null - * @throws ParameterException This happens when the given name is empty - * @see gridsim.net.Link#DEFAULT_BAUD_RATE - * @see gridsim.net.Link#DEFAULT_PROP_DELAY - * @see gridsim.net.Link#DEFAULT_MTU - * @pre name != null - * @post $none - */ -/* public FlowLink(String name) throws ParameterException, - NullPointerException - { - super(name, Link.DEFAULT_BAUD_RATE, Link.DEFAULT_PROP_DELAY, - Link.DEFAULT_MTU); - - init(); - }*/ - - /** * Initialises all attributes * @pre $none * @post $none @@ -214,8 +189,8 @@ { super.sim_get_next(ev); - System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); - System.out.println(super.get_name() + ".body(): ev.get_src() is " + ev.get_src()); + //System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); + //System.out.println(super.get_name() + ".body(): ev.get_src() is " + ev.get_src()); // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { @@ -223,7 +198,7 @@ } // process the received event - System.out.println(super.get_name() + ".body(): processEvent() at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".body(): processEvent() at time = " + GridSim.clock()); processEvent(ev); sim_completed(ev); } @@ -231,12 +206,12 @@ while(sim_waiting() > 0) { // wait for event and ignore - System.out.println(super.get_name() + ".body(): Ignore !!"); + //System.out.println(super.get_name() + ".body(): Ignore !!"); sim_get_next(ev); } - System.out.println(super.get_name() + ":%%%% Exiting body() at time " + - GridSim.clock() ); + //System.out.println(super.get_name() + ":%%%% Exiting body() at time " + + // GridSim.clock() ); } /** @@ -251,12 +226,12 @@ { case GridSimTags.PKT_FORWARD: // for normal packets case GridSimTags.JUNK_PKT: // for background traffic - System.out.println(super.get_name() + ".processEvent(): enque() at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".processEvent(): enque() at time = " + GridSim.clock()); enque(ev); break; case GridSimTags.INSIGNIFICANT: - System.out.println(super.get_name() + ".processEvent(): processInternalEvent() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".processEvent(): processInternalEvent() + at time = " + GridSim.clock()); processInternalEvent(); break; @@ -276,14 +251,14 @@ */ private synchronized boolean sendInternalEvent(double time) { - System.out.println(super.get_name() + " sendInternalEvent(): called at time = " + GridSim.clock()); + //System.out.println(super.get_name() + " sendInternalEvent(): called at time = " + GridSim.clock()); if (time < 0.0) { - System.out.println(super.get_name() + " sendInternalEvent(): false at time = " + GridSim.clock()); + //System.out.println(super.get_name() + " sendInternalEvent(): false at time = " + GridSim.clock()); return false; } - System.out.println(super.get_name() + " sendInternalEvent(): scheduled for = " + time + " from now"); + //System.out.println(super.get_name() + " sendInternalEvent(): scheduled for = " + time + " from now"); super.sim_schedule(super.get_id(), time, GridSimTags.INSIGNIFICANT); return true; } @@ -296,7 +271,7 @@ private synchronized void processInternalEvent() { - System.out.println(super.get_name() + "processInternalEvent(): " + GridSim.clock()); + //System.out.println(super.get_name() + "processInternalEvent(): " + GridSim.clock()); // this is a constraint that prevents an infinite loop // Compare between 2 floating point numbers. This might be incorrect @@ -320,8 +295,8 @@ } - System.out.println("Super.delay_ is " + super.delay_); - System.out.println(super.get_name() + " processInternalEvent(): done at time = " + GridSim.clock()); + //System.out.println("Super.delay_ is " + super.delay_); + //System.out.println(super.get_name() + " processInternalEvent(): done at time = " + GridSim.clock()); } /** @@ -332,7 +307,7 @@ */ private synchronized void enque(Sim_event ev) { - System.out.println(super.get_name() + " enque() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + " enque() + at time = " + GridSim.clock()); int tag = ((Packet)ev.get_data()).getTag(); // Register passing flow, gridlet or junk as active on this link if (tag == GridSimTags.FLOW_SUBMIT || tag == GridSimTags.GRIDLET_SUBMIT || @@ -358,13 +333,13 @@ private synchronized void deque(Packet np) { - System.out.println(super.get_name() + ".deque() for packet " + np.getID() +" here"); - System.out.println(super.get_name() + ".deque() packet " + np.toString()); + //System.out.println(super.get_name() + ".deque() for packet " + np.getID() +" here"); + //System.out.println(super.get_name() + ".deque() packet " + np.toString()); int dest = getNextHop(np); if (dest == -1) { - System.out.println(super.get_name() + ".deque() here3"); + //System.out.println(super.get_name() + ".deque() here3"); return; } @@ -372,7 +347,7 @@ int tag = 0; if (dest == outEnd2_ || dest == outEnd1_) { - System.out.println(super.get_name() + ".deque() here1"); + //System.out.println(super.get_name() + ".deque() here1"); // for junk packets only if (np.getTag() == GridSimTags.JUNK_PKT) { @@ -385,14 +360,14 @@ } // other side is a GridSim entity else { - System.out.println(super.get_name() + ".deque() here2"); + //System.out.println(super.get_name() + ".deque() here2"); tag = np.getTag(); } // sends the packet super.sim_schedule(dest, GridSimTags.SCHEDULE_NOW, tag, np); - System.out.println(super.get_name() + ".deque() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".deque() + at time = " + GridSim.clock()); } @@ -437,8 +412,8 @@ // Add flow to link activeFlows_.put(np.getID(), np ); - System.out.println(super.get_name() + ".registerFlow(): registering flow #" + np.getID() - + " total of " + activeFlows_.size() + " flows"); + //System.out.println(super.get_name() + ".registerFlow(): registering flow #" + np.getID() + // + " total of " + activeFlows_.size() + " flows"); // Register link to flow ((FlowPacket)np).addLink(this); @@ -450,11 +425,11 @@ // If change in bandwidth affects an existing flow i.e. is < current bottleneck if (this.getBaudRate() < tempFlow.getBandwidth_() && tempFlow.getID() != np.getID()) { // Need to notify flow - System.out.println(super.get_name() + ".registerFlow(): flow #" + np.getID() - + " bottleneck now " + this.getBaudRate() + " at time " + GridSim.clock()); + //System.out.println(super.get_name() + ".registerFlow(): flow #" + np.getID() + // + " bottleneck now " + this.getBaudRate() + " at time " + GridSim.clock()); // I can notify directly as I know the destId's!!!! - System.out.println(super.get_name() + ".registerFlow(): updating flow #" + tempFlow.getID() - + " destination " + tempFlow.getDestID()); + //System.out.println(super.get_name() + ".registerFlow(): updating flow #" + tempFlow.getID() + // + " destination " + tempFlow.getDestID()); super.sim_schedule(GridSim.getEntityId("Input_" + GridSim.getEntityName(tempFlow.getDestID())), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID())); @@ -476,8 +451,8 @@ // If the flow hasn't been removed already, remove from active flow list if ((fp = (FlowPacket) activeFlows_.remove(np.getID())) != null) { - System.out.println(super.get_name() + ".deregisterFlow() success flow # " + np.getID() - + " " + fp.getBandwidth_()); + //System.out.println(super.get_name() + ".deregisterFlow() success flow # " + np.getID() + // + " " + fp.getBandwidth_()); // Check if this affects any existing flows Iterator<Integer> flowsIter = activeFlows_.keySet().iterator(); @@ -488,11 +463,11 @@ if (this.getBaudRate() > tempFlow.getBandwidth_() && tempFlow.getID() != np.getID() && tempFlow.getBottleneckID() == this.get_id()) { // Need to notify flow - System.out.println(super.get_name() + ".deregisterFlow(): flow #" + np.getID() - + " bottleneck now " + this.getBaudRate() + " at time " + GridSim.clock()); + //System.out.println(super.get_name() + ".deregisterFlow(): flow #" + np.getID() + // + " bottleneck now " + this.getBaudRate() + " at time " + GridSim.clock()); // I can notify directly as I know the destId's!!!! - System.out.println(super.get_name() + ".deregisterFlow(): updating flow #" + tempFlow.getID() - + " destination " + tempFlow.getDestID()); + //System.out.println(super.get_name() + ".deregisterFlow(): updating flow #" + tempFlow.getID() + // + " destination " + tempFlow.getDestID()); super.sim_schedule(GridSim.getEntityId("Input_" + GridSim.getEntityName(tempFlow.getDestID())), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID())); @@ -510,10 +485,10 @@ */ public synchronized double getBaudRate() { if (activeFlows_.size() != 0) { - System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)/(activeFlows_.size())); + //System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)/(activeFlows_.size())); return (super.baudRate_)/(activeFlows_.size()); } else { - System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)); + //System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)); return super.baudRate_; } Modified: trunk/source/gridsim/net/flow/FlowOutput.java =================================================================== --- trunk/source/gridsim/net/flow/FlowOutput.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/FlowOutput.java 2008-08-04 02:15:29 UTC (rev 197) @@ -1,14 +1,11 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 4.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: James Broberg - * - * March 2007 - * - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * FlowOutput.java - Simulates a network output port - * + * Copyright (c) 2008, The University of Melbourne, Australia + * Author: James Broberg (based on Output.java) */ package gridsim.net.flow; @@ -34,7 +31,7 @@ * instances of this class * * @author James Broberg - * @since GridSim Toolkit 5.0 + * @since GridSim Toolkit 4.2 * @invariant $none */ public class FlowOutput extends Sim_entity implements NetIO @@ -49,7 +46,6 @@ private TrafficGenerator gen_; // background traffic generator private ArrayList list_; // list of resources + user entities private boolean hasStarted_; // a flag for background traffic has started - private static final int BITS = 8; // 1 byte = 8 bits private Random rnd; // Random number generator to generate unique // flow ID's @@ -267,8 +263,8 @@ break; } - System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); - System.out.println(super.get_name() + ".body(): ev.get_src() is " + ev.get_src()); + //System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); + //System.out.println(super.get_name() + ".body(): ev.get_src() is " + ev.get_src()); // handle different types of incoming events switch ( ev.get_tag() ) @@ -441,7 +437,7 @@ if (link_ != null && destId != gisID && destId != statID && destId != shutdownID) { - System.out.println(super.get_name() + ".defaultSend(): submitToLink() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + ".defaultSend(): submitToLink() + at time = " + GridSim.clock()); submitToLink(ev); return; } @@ -461,7 +457,7 @@ // So, convert io into bits double minBaudRate = Math.min(baudRate_, receiverBaudRate); double communicationDelay = GridSimRandom.realIO( - (io.getByteSize() * BITS) / minBaudRate); + (io.getByteSize() * NetIO.BITS) / minBaudRate); // NOTE: Below is a deprecated method for SimJava 2 //super.sim_hold(communicationDelay); @@ -493,7 +489,7 @@ destId, netServiceType, 1, 1); - System.out.println("Sending flow packet to link at time = " + GridSim.clock() + " id is " + np.getID()); + //System.out.println("Sending flow packet to link at time = " + GridSim.clock() + " id is " + np.getID()); enque(np, GridSimTags.SCHEDULE_NOW); } @@ -620,15 +616,13 @@ */ private synchronized void enque(Packet pkt, double delay) { - - flowList_.add(pkt); if (flowList_.size() == 1) { - System.out.println(super.get_name() + ".enque() Size is " + pkt.getSize() + " baud " + link_.getBaudRate()); + //System.out.println(super.get_name() + ".enque() Size is " + pkt.getSize() + " baud " + link_.getBaudRate()); double total = 0.0; - System.out.println(super.get_name() + ".enque() Time now " + GridSim.clock() + " delay is " + total); + //System.out.println(super.get_name() + ".enque() Time now " + GridSim.clock() + " delay is " + total); super.sim_schedule(super.get_id(), total, GridSimTags.SEND_PACKET); } @@ -664,7 +658,7 @@ // if an entity tries to send a packet to itself if ( np.getDestID() == outPort_.get_dest() ) { - System.out.println("Sending packet to self!"); + //System.out.println("Sending packet to self!"); // then change the destination name and id String destName = super.get_name(); destName = destName.replaceFirst("Output", "Input"); Modified: trunk/source/gridsim/net/flow/FlowPacket.java =================================================================== --- trunk/source/gridsim/net/flow/FlowPacket.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/FlowPacket.java 2008-08-04 02:15:29 UTC (rev 197) @@ -1,12 +1,11 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 3.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 * + * Copyright (c) 2008, The University of Melbourne, Australia * Author: James Broberg - * - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * FlowPacket.java - Implementation of a Flow Packet. - * */ package gridsim.net.flow; @@ -22,7 +21,7 @@ * Structure of a packet used to encapsulate flow passing through the network. * * @invariant $none - * @since GridSim Toolkit 5.0 + * @since GridSim Toolkit 4.2 * @author James Broberg */ public class FlowPacket implements Packet @@ -570,6 +569,12 @@ this.srcID = srcID; } + /** + * Sets the tag of this packet + * @param tag the packet's tag + * @pre $none + * @post $none + */ public void setTag(int tag) { this.tag = tag; } Modified: trunk/source/gridsim/net/flow/FlowRouter.java =================================================================== --- trunk/source/gridsim/net/flow/FlowRouter.java 2008-08-03 07:00:02 UTC (rev 196) +++ trunk/source/gridsim/net/flow/FlowRouter.java 2008-08-04 02:15:29 UTC (rev 197) @@ -1,20 +1,14 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 5.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: James Broberg - * + * Copyright (c) 2008, The University of Melbourne, Australia + * Author: James Broberg * Author: Gokul Poduval & Chen-Khong Tham - * Computer Communication Networks (CCN) Lab - * Dept of Electrical & Computer Engineering - * National University of Singapore - * August 2004 - * - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * FlowRouter.java - Simulates a flow network router with RIP as the advertising - * protocol (adapted from RIPRouter.java) - * */ + package gridsim.net.flow; import eduni.simjava.*; @@ -25,8 +19,8 @@ /** - * This class implements a FlowRouter using a form of RIP for routing. The routing - * protocol used here is similar to <a + * This class implements a FlowRouter using a form of RIP for routing. + * The routing 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. @@ -37,7 +31,7 @@ * reliable protocol to use. * * @invariant $none - * @since GridSim Toolkit 5.0 + * @since GridSim Toolkit 4.2 * @author James Broberg, The University of Melbourne * @author Gokul Poduval & Chen-Khong Tham, National University of Singapore */ @@ -49,11 +43,10 @@ private Hashtable routerTable; private Hashtable forwardTable; private int id; - private static final int BITS = 8; // 1 byte in bits /** - * Creates a new FlowRouter object. + * Creates a new FlowRouter object. * By default, <b>no recording or logging</b> * is done for packets' activities. If you want to log operations of this * entity, please use {@link #FlowRouter(String, boolean)}. @@ -278,17 +271,22 @@ */ protected synchronized void processEvent(Sim_event ev) { - - System.out.println(super.get_name() + ".processEvent(): Event was scheduled for " + ev.event_time()); - System.out.println(super.get_name() + ".processEvent(): ev.get_tag() is " + ev.get_tag()); - System.out.println(super.get_name() + ".processEvent(): ev.get_src() is " + ev.get_src()); + /***** NOTE: debugging information + System.out.println(super.get_name() + + ".processEvent(): Event was scheduled for " + ev.event_time()); + System.out.println(super.get_name() + + ".processEvent(): ev.get_tag() is " + ev.get_tag()); + System.out.println(super.get_name() + + ".processEvent(): ev.get_src() is " + ev.get_src()); + *************/ switch ( ev.get_tag() ) { - + case GridSimTags.PKT_FORWARD: case GridSimTags.JUNK_PKT: - System.out.println(super.get_name() + ".processEvent(): processNetPacket() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + + // ".processEvent(): processNetPacket() + at time = " + GridSim.clock()); processFlowPacket(ev, ev.get_tag()); break; @@ -297,7 +295,8 @@ break; case GridSimTags.INSIGNIFICANT: - System.out.println(super.get_name() + ".processEvent(): processInternalEvent() + at time = " + GridSim.clock()); + //System.out.println(super.get_name() + + // ".processEvent(): processInternalEvent() + at time = " + GridSim.clock()); processInternalEvent(ev); break; @@ -318,10 +317,9 @@ */ private synchronized void processFlowPacket(Sim_event ev, int tag) { - //double nextTime = 0; Packet pkt = (Packet) ev.get_data(); PacketScheduler sched = getScheduler(pkt); - System.out.println("Packet id is " + pkt.getID()); + //System.out.println("Packet id is " + pkt.getID()); // if a packet scheduler is not found, then try reschedule this packet // in the future @@ -342,42 +340,50 @@ ((InfoPacket) pkt).addEntryTime( GridSim.clock() ); ((InfoPacket) pkt).addBaudRate(sched.getBaudRate()); } - - System.out.println(super.get_name() + ".processNetPacket() check sched Time now " + GridSim.clock()); + + //System.out.println(super.get_name() + + // ".processNetPacket() check sched Time now " + GridSim.clock()); + // if no packets at the moment if (sched.size() == 0) { - System.out.println(super.get_name() + ".processNetPacket() #packets " + - " size " + pkt.getSize()*BITS + " baud sched " + sched.getBaudRate() + - " largest double " + Double.MAX_VALUE); + /****** // NOTE: debugging information + System.out.println(super.get_name() + ".processNetPacket() #packets " + + " size " + pkt.getSize()*NetIO.BITS + " baud sched " + + sched.getBaudRate() + " largest double " + Double.MAX_VALUE); - - System.out.println(super.get_name() + ".processNetPacket() set internal event to " + - "fire"); - // Fire internal event without delay (delay is incurred entirely at source - // of Flow + System.out.println(super.get_name() + + ".processNetPacket() set internal event to fire"); + ******/ + + // Fire internal event without delay (delay is incurred entirely at + // source of Flow sendInternalEvent(GridSimTags.SCHEDULE_NOW, sched); } - System.out.println(super.get_name() + ".processNetPacket() done sched Time now " + - GridSim.clock()); + //System.out.println(super.get_name() + + // ".processNetPacket() done sched Time now " + GridSim.clock()); + // log / record .... if (super.reportWriter_ != null) { super.write(""); super.write("receive incoming, " + pkt + ", delay, " + 0.0); - //super.write("break this packet into, " + numPackets); } // put the actual packet into the last one and resize it accordingly pkt.setLast(id); pkt.setSize(pkt.getSize()); - super.write("enqueing, " + pkt); + + if (super.reportWriter_ != null) { + super.write("enqueing, " + pkt); + } + sched.enque(pkt); // put the packet into the scheduler } - + /** * Gets the link's name for a given id * @param destID a destination id @@ -518,7 +524,9 @@ ((InfoPacket) np).addExitTime( GridSim.clock() ); } - super.write("dequeuing, " + np); + if (super.reportWriter_ != null) { + super.write("dequeuing, " + np); + } // must distinguish between normal and junk packet int tag = GridSimTags.PKT_FORWARD; @@ -531,12 +539,12 @@ super.sim_schedule(GridSim.getEntityId(linkName), GridSimTags.SCHEDULE_NOW, tag, np); - System.out.println(super.get_name() + ".deque() time now " + GridSim.clock()); + //System.out.println(super.get_name() + ".deque() time now " + GridSim.clock()); // process the next packet in the scheduler if ( !sched.isEmpty() ) { - double nextTime = (np.getSize() * BITS) / sched.getBaudRate(); + double nextTime = (np.getSize() * NetIO.BITS) / sched.getBaudRate(); sendInternalEvent(nextTime, sched); } } @@ -608,7 +616,11 @@ { RIPAdPack ad = new RIPAdPack(super.get_name(), hosts); String router = (String) routers.nextElement(); - super.write("advertise to router, " + router); + + if (super.reportWriter_ != null) { + super.write("advertise to router, " + router); + } + sim_schedule(Sim_system.get_entity_id(router), GridSimTags.SCHEDULE_NOW, GridSimTags.ROUTER_AD, ad); } @@ -626,7 +638,10 @@ */ private synchronized void receiveAd(Sim_event ev) { - super.write("receive router ad from, "+GridSim.getEntityName(ev.get_src())); + if (super.reportWriter_ != null) { + super.write("receive router ad from, " + + GridSim.getEntityName(ev.get_src())); + } // what to do when an ad is received RIPAdPack ad = (RIPAdPack)ev.get_data(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |