From: <sul...@us...> - 2008-09-09 08:13:57
|
Revision: 242 http://gridsim.svn.sourceforge.net/gridsim/?rev=242&view=rev Author: sulistio Date: 2008-09-09 08:14:06 +0000 (Tue, 09 Sep 2008) Log Message: ----------- add javadoc comments (was done by Agustin) 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/FnbInput.java trunk/source/gridsim/net/fnb/FnbNetPacket.java trunk/source/gridsim/net/fnb/FnbNetworkReader.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/RED.java trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java Modified: trunk/source/gridsim/net/fnb/ARED.java =================================================================== --- trunk/source/gridsim/net/fnb/ARED.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/ARED.java 2008-09-09 08:14:06 UTC (rev 242) @@ -59,8 +59,12 @@ * @param name Name of this scheduler * @param baudRate baud rate in bits/s of the port that is using * this scheduler. + * @param max_p the maximum dropping probability for an incoming packet * @param max_buf_size maximum buffer size for routers - * @throws ParameterException This happens when the baud rate <= 0 + * @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 + * @throws Exception This happens when the baud rate <= 0 * @pre baudRate > 0 * @post $none */ @@ -74,7 +78,7 @@ /** * 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. + * It also updates ALPHA, as it depends on max_p. */ public void updateAREDParameters() { @@ -162,6 +166,7 @@ /** * Sets the baud rate that this scheduler will be sending packets at. * @param rate the baud rate of this scheduler (in bits/s) + * @return true if the baud rate has been set properly * @pre rate > 0 * @post $none */ Modified: trunk/source/gridsim/net/fnb/FIFO.java =================================================================== --- trunk/source/gridsim/net/fnb/FIFO.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FIFO.java 2008-09-09 08:14:06 UTC (rev 242) @@ -64,7 +64,9 @@ * @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 + * @param queue_weight this parameter reflects how important is the last + * @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 @@ -112,7 +114,7 @@ checkAndInsertPacketIntoQueue(pnp); /// insert the pkt into the queue //double avgQueueSize = avgQueueSize(); return true; - } + } /** @@ -145,7 +147,7 @@ * We are using the FIFO algorithm. * @param pnp the new incoming packet * */ - public synchronized boolean dropPacketFIFO(Packet pnp) + public 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. @@ -196,7 +198,7 @@ // super.shutdownUserEntity(); // super.terminateIOEntities(); - return false; + } } @@ -248,13 +250,12 @@ pnp = null; // remove the packet. - return true; - } /** Calculate the avg queue size for the FIFO algorithm. - * */ + * + * @return the average queue size of this queue, which has been calculated in this function*/ public double avgQueueSize() { @@ -330,6 +331,7 @@ /** * Sets the baud rate that this scheduler will be sending packets at. * @param rate the baud rate of this scheduler (in bits/s) + * @return true if the baud rate has been set properly * @pre rate > 0 * @post $none */ @@ -345,7 +347,8 @@ return true; } - /** Returns the avg buffer size*/ + /** Returns the avg buffer size + * @return the average queue size, which was already calculated*/ public double getAvg() { return AVG; Modified: trunk/source/gridsim/net/fnb/FnbEndToEndPath.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbEndToEndPath.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbEndToEndPath.java 2008-09-09 08:14:06 UTC (rev 242) @@ -43,8 +43,8 @@ /**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 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 * */ @@ -63,10 +63,9 @@ /**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 srcID 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) { Modified: trunk/source/gridsim/net/fnb/FnbInput.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbInput.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbInput.java 2008-09-09 08:14:06 UTC (rev 242) @@ -442,7 +442,6 @@ /** * 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 * */ @@ -465,7 +464,6 @@ /** * 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) { Modified: trunk/source/gridsim/net/fnb/FnbNetPacket.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbNetPacket.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbNetPacket.java 2008-09-09 08:14:06 UTC (rev 242) @@ -57,7 +57,6 @@ * @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 */ @@ -88,13 +87,8 @@ * @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 */ @@ -323,13 +317,15 @@ return conn.getTotalPkts(); } - /** Establishes the end to end path to another entity */ + /** Establishes the end to end path to another entity + * @param c new FnbEndToEndPath */ public void setPath(FnbEndToEndPath c) { conn = c; } - /**Returns the gridlet/file to which this packet belongs*/ + /**Returns the gridlet/file to which this packet belongs + * @return the gridlet/file to which this packet belongs*/ public int getObjectID() { return conn.getObjectID(); Modified: trunk/source/gridsim/net/fnb/FnbNetworkReader.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbNetworkReader.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbNetworkReader.java 2008-09-09 08:14:06 UTC (rev 242) @@ -64,6 +64,7 @@ * @param max_th maximum threshold for RED * @param max_p maximum drop probability for RED * @param queue_weight queue weight for RED + * @param stats whether we want to store stats or not * @return the list of finiteBufferRouters of the network or <tt>null</tt> if an error * occurs * @see gridsim.net.finiteBufferSCFQScheduler Modified: trunk/source/gridsim/net/fnb/FnbOutput.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbOutput.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbOutput.java 2008-09-09 08:14:06 UTC (rev 242) @@ -701,7 +701,9 @@ pktID_++; // increments packet ID } - /**Returns the my_id of the file. */ + /**Returns the my_id of the file. + * @param fname the name of the file + * @return the my_id of the file*/ int checkFilename(String fname) { Fnb_FileName_FileMyID fname_fid; @@ -726,7 +728,9 @@ return last_fileID + 1; } - /**Returns the file name of the file with the given my_id*/ + /**Returns the file name of the file with the given my_id + * @param fileID the id of the file + * @return the name of the file*/ String getFilename(int fileID) { Fnb_FileName_FileMyID fname_fid; @@ -759,8 +763,7 @@ * @param size packet size (in bytes) * @param numPackets total number of packets to be created * @param tag packet tag - * @param destId destination ID for sending the packet - * @param netServiceType level type of service for the packet + * @param conn a FnbEndToEndPath defining the end points of the transmission * @pre $none * @post $none */ @@ -1013,7 +1016,7 @@ } /**This function returns the entity (gridlet/file) to which a packet belongs - * @param pkt the ID of the packet of interest + * @param pktID the ID of the packet of interest * @return a FnbMessage object * */ FnbMessage lookForEntity(int pktID) Modified: trunk/source/gridsim/net/fnb/FnbRIPRouter.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbRIPRouter.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbRIPRouter.java 2008-09-09 08:14:06 UTC (rev 242) @@ -34,7 +34,7 @@ * * @invariant $none * @author Agustin Caminero, University of Castilla La Mancha, Spain. - * Based on class RIPRouter, by Gokul Poduval & Chen-Khong Tham, + * Based on class RIPRouter, by Gokul Poduval & Chen-Khong Tham, * National University of Singapore. * Things added or modified: * private int my_id_; @@ -60,11 +60,11 @@ private Hashtable routerTable; private Hashtable forwardTable; private int id; - private final int BITS = 8; // 1 byte in bits + private final int BITS = 8; // 1 byte in bits 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 int MIN = 60; // 1 minute in seconds private final double INTERVAL = 2 * MIN; // the interval to update (reset) the packet counters @@ -73,41 +73,44 @@ private boolean storeStats; /** - * Creates a new RIPRouter 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 #FnbRIPRouter(String, boolean)}. - * - * @param name Name of this router - * @throws NullPointerException This happens when name is empty or null - * @see #FnbRIPRouter(String, boolean) - * @pre name != null - * @post $none - */ - public FnbRIPRouter(String name, int my_id) throws NullPointerException - { - this(name, false, my_id); - storeStats = false; - } + * Creates a new RIPRouter 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 #FnbRIPRouter(String, boolean)}. + * + * @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 + * @throws NullPointerException This happens when name is empty or null + * @see #FnbRIPRouter(String, boolean) + * @pre name != null + * @post $none + */ + public FnbRIPRouter(String name, int my_id) throws NullPointerException + { + this(name, false, my_id); + storeStats = false; + } - /** - * Creates a new FnbRIPRouter object with logging facility if it is turned on. - * <br> - * NOTE: If logging facility is turned on, there are some overheads - * in terms of performance and memory consumption. - * - * @param name Name of this router - * @param trace <tt>true</tt> if you want to record this router's - * activity, <tt>false</tt> otherwise - * @throws NullPointerException This happens when name is empty or null - * @pre name != null - * @post $none - */ - public FnbRIPRouter(String name, boolean trace, int my_id) throws NullPointerException - { - super(name, trace); - my_id_ = my_id; - storeStats = false; - init(); + /** + * Creates a new FnbRIPRouter object with logging facility if it is turned on. + * <br> + * NOTE: If logging facility is turned on, there are some overheads + * in terms of performance and memory consumption. + * + * @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 + * @throws NullPointerException This happens when name is empty or null + * @pre name != null + * @post $none + */ + public FnbRIPRouter(String name, boolean trace, int my_id) throws + NullPointerException + { + super(name, trace); + my_id_ = my_id; + storeStats = false; + init(); } /** @@ -123,7 +126,8 @@ * @pre name != null * @post $none */ - public FnbRIPRouter(String name, int my_id, boolean stats) throws NullPointerException + public FnbRIPRouter(String name, int my_id, boolean stats) throws + NullPointerException { this(name, false, my_id); storeStats = stats; @@ -144,7 +148,8 @@ * @pre name != null * @post $none */ - public FnbRIPRouter(String name, boolean trace, int my_id, boolean stats) throws NullPointerException + public FnbRIPRouter(String name, boolean trace, int my_id, boolean stats) throws + NullPointerException { super(name, trace); my_id_ = my_id; @@ -190,7 +195,8 @@ * @post $none */ public void attachRouter(FnbRouter router, Link link, - PacketScheduler thisSched, PacketScheduler otherSched) + PacketScheduler thisSched, + PacketScheduler otherSched) { String msg = super.get_name() + ".attachRouter(): Error - "; if (router == null) @@ -208,12 +214,12 @@ if (thisSched == null || otherSched == null) { System.out.println(msg + - "the one or more packet schedulers are null."); + "the one or more packet schedulers are null."); return; } - thisSched.setBaudRate( link.getBaudRate() ); - otherSched.setBaudRate( link.getBaudRate() ); + thisSched.setBaudRate(link.getBaudRate()); + otherSched.setBaudRate(link.getBaudRate()); link.attach(this, router); this.attachRouter(router, link, thisSched); @@ -233,7 +239,8 @@ * @pre sched != null * @post $none */ - protected void attachRouter(FnbRouter router, Link link, PacketScheduler sched) + protected void attachRouter(FnbRouter router, Link link, + PacketScheduler sched) { String msg = super.get_name() + ".attachRouter(): Error - "; if (router == null) @@ -256,25 +263,26 @@ linkTable.put(router.get_name(), link.get_name()); - if (!schedTable.containsKey( link.get_name()) ) { + if (!schedTable.containsKey(link.get_name())) + { schedTable.put(link.get_name(), sched); } - routerTable.put( link.get_name(), router.get_name() ); - hostTable.put( link.get_name(), router.get_name() ); + routerTable.put(link.get_name(), router.get_name()); + hostTable.put(link.get_name(), router.get_name()); // logging or recording ... if (reportWriter_ != null) { StringBuffer sb = null; sb = new StringBuffer("attach this ROUTER, with router, "); - sb.append( router.get_name() ); + sb.append(router.get_name()); sb.append(", with link, "); - sb.append( link.get_name() ); + sb.append(link.get_name()); sb.append(", with packet scheduler, "); - sb.append( sched.getSchedName() ); + sb.append(sched.getSchedName()); - super.write( sb.toString() ); + super.write(sb.toString()); } } @@ -308,26 +316,27 @@ } Link link = entity.getLink(); - sched.setBaudRate( link.getBaudRate() ); + sched.setBaudRate(link.getBaudRate()); link.attach(this, entity); - linkTable.put( entity.get_name(), link.get_name() ); + linkTable.put(entity.get_name(), link.get_name()); - if (!schedTable.containsKey( link.get_name() )) { + if (!schedTable.containsKey(link.get_name())) + { schedTable.put(link.get_name(), sched); } - hostTable.put( link.get_name(), entity.get_name() ); + hostTable.put(link.get_name(), entity.get_name()); // recording ... if (reportWriter_ != null) { StringBuffer sb = null; sb = new StringBuffer("attach this ROUTER, to entity, "); - sb.append( entity.get_name() ); + sb.append(entity.get_name()); sb.append(", with packet scheduler, "); - sb.append( sched.getSchedName() ); + sb.append(sched.getSchedName()); - super.write( sb.toString() ); + super.write(sb.toString()); } } @@ -339,7 +348,7 @@ */ protected synchronized void processEvent(Sim_event ev) { - switch ( ev.get_tag() ) + switch (ev.get_tag()) { case GridSimTags.PKT_FORWARD: case GridSimTags.JUNK_PKT: @@ -358,14 +367,14 @@ processEndOfSimulation(ev); break; - case GridSimTags.FNB_UPDATE_ARED_PARAMETERS: - updateAREDParameters(); - break; + case GridSimTags.FNB_UPDATE_ARED_PARAMETERS: + updateAREDParameters(); + break; default: System.out.println(super.get_name() + ".body(): Unable to " + - "handle request from GridSimTags " + - "with constant number " + ev.get_tag() ); + "handle request from GridSimTags " + + "with constant number " + ev.get_tag()); break; } } @@ -399,7 +408,8 @@ { ((RED) sched).updateStats(); } - }else + } + else { if (storeStats) { @@ -410,7 +420,6 @@ } //for (Enumeration e = schedTable.keys(); e.hasMoreElements(); ) - super.sim_schedule(super.get_id(), GridSimTags.SCHEDULE_NOW + GridSimTags.FNB_UPDATE_ARED_PARAMETERS_PERIOD, @@ -418,23 +427,24 @@ } - /**At the end of simulations, write the counters into files.*/ + /**At the end of simulations, write the counters into files. + * @param ev an event*/ private void processEndOfSimulation(Sim_event ev) { - processCountDroppedPkts(ev); + processCountDroppedPkts(ev); - } /** * This event is used to write in a file the current number of packets - * dropped at the schedulers of this router*/ + * dropped at the schedulers of this router + * @param ev an event*/ private void processCountDroppedPkts(Sim_event ev) { /*System.out.println(super.get_name() + - ": COUNT_DROPPED_PKTS event arrived. Clock: " + - GridSim.clock() + "Next event will be in (delay) " + + ": COUNT_DROPPED_PKTS event arrived. Clock: " + + GridSim.clock() + "Next event will be in (delay) " + (GridSimTags.SCHEDULE_NOW + 3600));*/ double clock = GridSim.clock(); @@ -444,7 +454,7 @@ if (clock > nextInterval_dropped) { FnbSCFQScheduler sched = null; - double droppedPktsCounter; + double droppedPktsCounter; for (Enumeration e = schedTable.keys(); e.hasMoreElements(); ) { link = (String) e.nextElement(); @@ -474,15 +484,17 @@ nextInterval_dropped = GridSim.clock() + INTERVAL; - }// if (clock > nextInterval_dropped) + } // if (clock > nextInterval_dropped) } + /** * Processes incoming network packets, one at a time. * The incoming packet will be split up into smaller pieces if * the packet size > MTU of the other end. * * @param ev a Sim_event object + * @param tag tag of the event * @pre ev != null * @post $none */ @@ -499,12 +511,12 @@ if (pkt instanceof InfoPacket) { ((InfoPacket) pkt).addHop(id); - ((InfoPacket) pkt).addEntryTime( GridSim.clock() ); + ((InfoPacket) pkt).addEntryTime(GridSim.clock()); ((InfoPacket) pkt).addBaudRate(sched.getBaudRate()); } // check downlink MTU, and split accordingly - String linkName = getLinkName( pkt.getDestID() ); + String linkName = getLinkName(pkt.getDestID()); Link downLink = (Link) Sim_system.get_entity(linkName); int MTU = downLink.getMTU(); int numPackets = (int) Math.ceil(pkt.getSize() / (MTU * 1.0)); @@ -512,10 +524,12 @@ // if no packets at the moment if (sched.size() == 0) { - if (numPackets == 1) { + if (numPackets == 1) + { nextTime = (pkt.getSize() * BITS) / sched.getBaudRate(); } - else { + else + { nextTime = (MTU * BITS * 1.0) / sched.getBaudRate(); } @@ -539,14 +553,15 @@ if (pkt instanceof FnbNetPacket) { conn = new FnbEndToEndPath(pkt.getDestID(), pkt.getSrcID(), - pkt.getNetServiceType(), - numPackets, ((FnbNetPacket) pkt).getObjectID()); + pkt.getNetServiceType(), + numPackets, + ((FnbNetPacket) pkt).getObjectID()); } else { conn = new FnbEndToEndPath(pkt.getDestID(), pkt.getSrcID(), - pkt.getNetServiceType(), - numPackets); + pkt.getNetServiceType(), + numPackets); } np = new FnbNetPacket(null, pkt.getID(), MTU, tag, @@ -556,14 +571,14 @@ np.setLast(id); super.write("enqueing, " + np); - sched.enque(np); // put the packet into the scheduler + sched.enque(np); // put the packet into the scheduler } // put the actual packet into the last one and resize it accordingly pkt.setLast(id); pkt.setSize(pkt.getSize() - MTU * (numPackets - 1)); super.write("enqueing, " + pkt); - sched.enque(pkt); // put the packet into the scheduler + sched.enque(pkt); // put the packet into the scheduler } /** @@ -579,8 +594,9 @@ String linkName = null; //directly connected - if (hostTable.containsValue(destName)) { - linkName = (String)linkTable.get(destName); + if (hostTable.containsValue(destName)) + { + linkName = (String) linkTable.get(destName); } else { @@ -603,11 +619,12 @@ */ public PacketScheduler getScheduler(Packet np) { - if (np == null) { + if (np == null) + { return null; } - String destName = GridSim.getEntityName( np.getDestID() ); + String destName = GridSim.getEntityName(np.getDestID()); return getScheduler(destName); } @@ -623,7 +640,8 @@ */ public PacketScheduler getScheduler(int dest) { - if (dest < 0) { + if (dest < 0) + { return null; } @@ -644,12 +662,13 @@ */ public PacketScheduler getScheduler(String dest) { - if (dest == null || dest.length() == 0) { + if (dest == null || dest.length() == 0) + { return null; } PacketScheduler sched = null; - if ( hostTable.containsValue(dest) ) + if (hostTable.containsValue(dest)) { String linkName = (String) linkTable.get(dest); sched = (PacketScheduler) schedTable.get(linkName); @@ -730,7 +749,8 @@ */ private synchronized boolean sendInternalEvent(double time, Object data) { - if (time < 0.0) { + if (time < 0.0) + { return false; } @@ -759,9 +779,9 @@ for (Enumeration e = forwardTable.keys(); e.hasMoreElements(); ) { - String host = (String)e.nextElement(); - Object[] data = (Object[])forwardTable.get(host); - String nextHop = (String)data[0]; + String host = (String) e.nextElement(); + Object[] data = (Object[]) forwardTable.get(host); + String nextHop = (String) data[0]; System.out.println(host + "\t\t" + nextHop); } @@ -771,10 +791,11 @@ } /** - * Returns the my_id_ of this router - * @pre $none - * @post $none - */ + * Returns the my_id_ of this router + * @pre $none + * @post $none + * @return the my_id_ of he entity + */ public int get_my_id() { @@ -793,7 +814,7 @@ Collection hosts = hostTable.values(); // who to advertise Enumeration routers = routerTable.elements(); - while ( routers.hasMoreElements() ) + while (routers.hasMoreElements()) { RIPAdPack ad = new RIPAdPack(super.get_name(), hosts); String router = (String) routers.nextElement(); @@ -802,7 +823,7 @@ GridSimTags.SCHEDULE_NOW, GridSimTags.ROUTER_AD, ad); } - super.sim_pause(5); // wait for 5 secs to gather the results + super.sim_pause(5); // wait for 5 secs to gather the results } /** @@ -815,46 +836,51 @@ */ private synchronized void receiveAd(Sim_event ev) { - super.write("receive router ad from, "+GridSim.getEntityName(ev.get_src())); + 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(); + RIPAdPack ad = (RIPAdPack) ev.get_data(); // prevent count-to-infinity if (ad.getHopCount() > 15) { - return ; + return; } String sender = ad.getSender(); Iterator it = ad.getHosts().iterator(); - while ( it.hasNext() ) + while (it.hasNext()) { String host = (String) it.next(); - if ( host.equals(super.get_name()) ) { + if (host.equals(super.get_name())) + { continue; } - if (hostTable.containsValue(host)) { // direct connection + if (hostTable.containsValue(host)) + { // direct connection continue; } if (forwardTable.containsKey(host)) { - Object[] data = (Object[])forwardTable.get(host); - int hop = ((Integer)data[1]).intValue(); + Object[] data = (Object[]) forwardTable.get(host); + int hop = ((Integer) data[1]).intValue(); if ((hop) > ad.getHopCount()) { - Object[] toPut = { sender, new Integer(ad.getHopCount()) }; + Object[] toPut = + {sender, new Integer(ad.getHopCount())}; forwardTable.put(host, toPut); } } else { - Object[] toPut = { sender, new Integer(ad.getHopCount()) }; + Object[] toPut = + {sender, new Integer(ad.getHopCount())}; forwardTable.put(host, toPut); } } @@ -874,59 +900,60 @@ { String sender = ad.getSender(); ad.incrementHopCount(); - RIPAdPack newad = new RIPAdPack(super.get_name(),ad.getHosts()); + RIPAdPack newad = new RIPAdPack(super.get_name(), ad.getHosts()); newad.setHopCount(ad.getHopCount()); Enumeration routers = routerTable.elements(); - while ( routers.hasMoreElements() ) + while (routers.hasMoreElements()) { - String router = (String)routers.nextElement(); + String router = (String) routers.nextElement(); if (!router.equals(sender)) { sim_schedule(Sim_system.get_entity_id(router), - GridSimTags.SCHEDULE_NOW, GridSimTags.ROUTER_AD, newad); + GridSimTags.SCHEDULE_NOW, GridSimTags.ROUTER_AD, + newad); } } } /** - * 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; + * 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 = 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.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); - } - } + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while closing file " + file); + } + } } // end class Modified: trunk/source/gridsim/net/fnb/FnbRouter.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbRouter.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbRouter.java 2008-09-09 08:14:06 UTC (rev 242) @@ -52,7 +52,7 @@ * * @invariant $none * @author Agustin Caminero, University of Castilla La Mancha, Spain. - * Based on class Router, by Gokul Poduval & Chen-Khong Tham, + * Based on class Router, by Gokul Poduval & Chen-Khong Tham, * National University of Singapore. * Functions added or modified: * - get_my_id() @@ -233,6 +233,7 @@ * Returns the my_id_ of this router * @pre $none * @post $none + * @return the my_id_ of he entity */ public abstract int get_my_id(); Modified: trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbSCFQScheduler.java 2008-09-09 08:14:06 UTC (rev 242) @@ -103,7 +103,8 @@ * @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 + * @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 @@ -142,7 +143,8 @@ * @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 + * @param stats whether we want to store stats or not + * @throws Exception This happens when the baud rate <= 0 * @pre baudRate > 0 * @post $none */ @@ -172,7 +174,8 @@ * * @param name Name of this scheduler * @param max_buf_size maximum buffer size for routers - * @throws ParameterException This happens when the name is null + * @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 @@ -202,7 +205,8 @@ * The baud rate is left at 0, and should be set with * {@link gridsim.net.PacketScheduler#setBaudRate(double)} * before the simulation starts. - * @throws ParameterException This happens when the name is null + * @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 @@ -230,7 +234,7 @@ * @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 + * @throws Exception This happens when the baud rate <= 0 * @pre baudRate > 0 * @post $none */ @@ -260,7 +264,7 @@ * * @param name Name of this scheduler * @param max_buf_size maximum buffer size for routers - * @throws ParameterException This happens when the name is null + * @throws Exception This happens when the name is null * @see gridsim.net.PacketScheduler#setBaudRate(double) * @pre name != null * @post $none @@ -370,6 +374,7 @@ * @pre np != null * @pre nextTime >= 0 * @post $none + * @return finish time for the network paket */ private double calculateFinishTime(Packet np, double nextTime) { @@ -513,7 +518,8 @@ return p; } - /**Returns the size of the pkt list.*/ + /**Returns the size of the pkt list. + * @return size of the list of packets*/ public double pktListSize() { return pktList.size(); @@ -576,6 +582,7 @@ * @param rate the baud rate of this scheduler (in bits/s) * @pre rate > 0 * @post $none + * @return true if the baud rate has been set properly, false otherwise */ public boolean setBaudRateSCFQ(double rate) { @@ -789,7 +796,8 @@ } /** - * Returns the DROPPED_PKTS_COUNTER */ + * Returns the DROPPED_PKTS_COUNTER + * @return the counter of dropped packets*/ public double getCounterDroppedPkts() { return DROPPED_PKTS_COUNTER; @@ -805,6 +813,7 @@ /**This function returns maximum buffer size, up to this moment along the experiment. * This is not the max allowed buffer size in pkts. + * @return the maximum buffer size, up this moment * */ double getMaxBufferSize() { @@ -812,7 +821,7 @@ } /**This function returns the max buffer size in pkts. - * */ + * @return the maximum number of packets that fit into this buffer*/ double getMaxBufferSizeInPkts() { return MAX_BUFF_SIZE_PK; @@ -822,7 +831,7 @@ /**This function sets the maximum buffer size - * */ + * @param maxSize the new maximum buffer size */ void setMaxBufferSize(int maxSize) { maxBufferSize = maxSize; @@ -884,7 +893,8 @@ } } - /** Returns the avg buffer size*/ + /** Returns the avg buffer size + * @return the avg buffer size */ public abstract double getAvg(); @@ -900,6 +910,8 @@ /**Checks if there is an existing gridletID_userID in the droppedGl_user array. * We consider gridlets, datagridlets and files + * @param gl the gridlet + * @param user user to which the gridlet belongs * @return true, if there is a gridletID_userID object, false otherwise */ public boolean checkDroppedGlList(int gl, int user) { Modified: trunk/source/gridsim/net/fnb/FnbWhiteList.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbWhiteList.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/FnbWhiteList.java 2008-09-09 08:14:06 UTC (rev 242) @@ -26,7 +26,10 @@ } - /**Returns true if the given id is in the list.*/ + /**Returns true if the given id is in the list. + * @param id the id of an entity + * @return true if the given id is in the list. + * */ public boolean checkList(int id) { @@ -81,7 +84,9 @@ return addEntityID(new Integer (id)); } - /**Removes the given id of the list.*/ + /**Removes the given id of the list. + * @param id the id of an entity, to be removed from the list + * @return true if the entity is removed properly, false otherwise*/ public boolean removeID(int id) { int id_tmp; Modified: trunk/source/gridsim/net/fnb/RED.java =================================================================== --- trunk/source/gridsim/net/fnb/RED.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/RED.java 2008-09-09 08:14:06 UTC (rev 242) @@ -68,13 +68,12 @@ * @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 drop_alg the algorithm used to drop packets at routers * @param min_th minimum threshold for RED * @param max_th maximum threshold for RED * @param max_p maximum drop probability for RED - * @param queue_weight queue weight for RED + * @param queue_weigth queue weight for RED * @param storeStats whether we want to store stats or not - * @throws ParameterException This happens when the name is null or + * @throws Exception This happens when the name is null or * the baud rate <= 0 * @pre name != null * @pre baudRate > 0 @@ -202,7 +201,7 @@ * We are using the RED algorithm. * @param pnp the new incoming packet * */ - public synchronized boolean dropPacket(Packet pnp) + public synchronized void dropPacket(Packet pnp) { increaseDroppedPktCounter(); // increase the counter of dropped packets @@ -263,7 +262,7 @@ // If we have been able of dropping a data packet, then we have room for this control packet insertPacketIntoQueue(pnp); - return true; + //return true; } else { @@ -282,7 +281,7 @@ // super.shutdownUserEntity(); // super.terminateIOEntities(); - return false; + //return false; } } @@ -422,12 +421,12 @@ } - return true; + //return true; } /** Calculate the avg queue size for the RED algorithm. - * */ + * @return the avg queue size, which is calculated in this method */ public double avgQueueSize() { @@ -540,6 +539,7 @@ * @param rate the baud rate of this scheduler (in bits/s) * @pre rate > 0 * @post $none + * @return true if the baud rate has been set properly, false otherwise */ public boolean setBaudRate(double rate) { @@ -564,53 +564,62 @@ this.getSchedName() + "_Buffers"); } - /** Returns the avg buffer size*/ + /** Returns the avg buffer size + * @return the avg buffer size */ public double getAvg() { return AVG; } - /** Returns the max_p */ + /** Returns the max_p + * @return the maximum dropping probability */ public double getMaxP() { return MAX_P; } - /** Updates the vaule of MAX_P*/ + /** Updates the vaule of MAX_P + * @param m new value for the maximum dropping probability */ public void setMaxP(double m) { MAX_P = m; } - /** Returns the min_threshold*/ + /** Returns the min_threshold + * @return the minimum threshold*/ public double getMinTh() { return MIN_TH; } - /** Returns the max_threshold*/ + /** Returns the max_threshold + * @return the maximum threshold*/ public double getMaxTh() { return MAX_TH; } + /**Updates the value QUEUE_WEIGHT + * @param q new queue weight */ public void setQueueWeight(double q) { QUEUE_WEIGHT = q; } - /** Updates the vaule of MIN_TH*/ + /** Updates the value of MIN_TH + * @param m new minimum threshold*/ public void setMinTh(double m) { MIN_TH = m; } - /** Updates the vaule of MAX_TH*/ + /** Updates the value of MAX_TH + * @param m new maximum threshold*/ public void setMaxTh(double m) { MAX_TH = m; Modified: trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java =================================================================== --- trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java 2008-09-01 10:04:22 UTC (rev 241) +++ trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java 2008-09-09 08:14:06 UTC (rev 242) @@ -50,6 +50,7 @@ /** Sets the isFile. + * @param f if this is a file or not * */ public void setIsFile(boolean f) { @@ -98,7 +99,7 @@ } /** Sets the id of the first packet. - * @param last the id of the first packet. + * @param first the id of the first packet. * */ public void setFirst(int first) { @@ -106,7 +107,7 @@ } /** Sets the id of gridlet. - * @param last the id of gridlet. + * @param gl the id of the gridlet * */ public void setGridletID(int gl) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |