From: <bro...@us...> - 2008-02-19 02:37:00
|
Revision: 110 http://gridsim.svn.sourceforge.net/gridsim/?rev=110&view=rev Author: brobergj Date: 2008-02-18 18:37:05 -0800 (Mon, 18 Feb 2008) Log Message: ----------- *FlowPacket encapsulates a network Flow, and collects information as it passes from source to destination Added Paths: ----------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java Added: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-19 02:37:05 UTC (rev 110) @@ -0,0 +1,398 @@ +/* + * ** Network and Service Differentiation Extensions to GridSim 3.0 ** + * + * Author: James Broberg + * + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * FlowPacket.java - Implementation of a Flow Packet. + * + */ + +package gridsim.net.flow; + +import java.util.Vector; + +import gridsim.*; +import gridsim.net.Link; +import gridsim.net.Packet; +import eduni.simjava.*; + + +/** + * Structure of a packet used to encapsulate flow passing through the network. + * + * @invariant $none + * @since GridSim Toolkit 4.0 + * @author James Broberg + */ +public class FlowPacket implements Packet +{ + private int destID; // where the packet wants to go + private int srcID; // sender ID + private long size; // packet size (for calculating transmission time) + private long origSize; // original packet size + private Object obj; // the actual object, the type depends on context + + private double bandwidth_; // Bottleneck baud rate + + private Vector baudRates_; // list of entity's baud rate + + private Vector links_; + + // Sum of latency (delay) on path + private double latency; + + // 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 classType; // level of service for this packet + private int pktNum; // packet num in one group + private int totalPkts; // total num of packet that belongs to a group + private int pktID_; // a unique packet ID issued by an entity + + /** + * 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 FlowPacket(Object data, int pktID, long size, int tag, int srcID, + int destID) + { + this.obj = data ; + this.size = size ; + this.origSize = size ; + this.tag = tag ; + this.destID = destID; + this.srcID = srcID ; + this.last = srcID ; + this.pktID_ = pktID; + this.classType = 0 ; + this.pktNum = 1; + this.totalPkts = 1; + this.desc_ = null; + this.latency = 0.0; + this.bandwidth_ = Double.MAX_VALUE; + this.baudRates_ = new Vector(); + + } + + /** + * 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 FlowPacket(Object data, int pktID, long size, int tag, int srcID, + int destID, int netServiceType, int pktNum, int totalPkts) + { + this.obj = data; + this.size = size; + this.tag = tag; + this.destID = destID; + this.srcID = srcID; + this.last = srcID; + this.classType = netServiceType; + this.pktNum = pktNum; + this.pktID_ = pktID; + this.totalPkts = totalPkts; + this.desc_ = null; + this.latency = 0.0; + this.bandwidth_ = -1; + this.baudRates_ = new Vector(); + + } + + /** + * Returns a description of this packet + * @return a description of this packet + * @pre $none + * @post $none + */ + public String toString() + { + if (desc_ == null) + { + StringBuffer sb = new StringBuffer("Packet #"); + sb.append(pktNum); + sb.append(", out of, "); + sb.append(totalPkts); + sb.append(", with id, "); + sb.append(pktID_); + sb.append(", from, "); + sb.append( GridSim.getEntityName(srcID) ); + sb.append(", to, "); + sb.append( GridSim.getEntityName(destID) ); + sb.append(", tag, "); + + if (tag == GridSimTags.PKT_FORWARD) { + sb.append("GridSimTags.PKT_FORWARD"); + } + else if (tag == GridSimTags.JUNK_PKT) { + sb.append("GridSimTags.JUNK_PKT"); + } else if (tag == GridSimTags.FLOW_SUBMIT) { + sb.append("GridSimTags.FLOW_SUBMIT"); + } else if (tag == GridSimTags.FLOW_RETURN) { + sb.append("GridSimTags.FLOW_RETURN"); + } else { + sb.append(tag); + } + + desc_ = sb.toString(); + } + + return desc_; + } + + /** + * Returns the data encapsulated in this NetPacket + * @return data encapsulated in this packet + * @pre $none + * @post $none + */ + public Object getData() { + return obj; + } + + /** + * Returns the source ID of this packet. The source ID is where the + * NetPacket was originally created. + * + * @return the source id. + * @pre $none + * @post $none + */ + public int getSrcID() { + return srcID; + } + + /** + * Returns the ID of this packet + * @return packet ID + * @pre $none + * @post $none + */ + public int getID() { + return pktID_; + } + + /** + * Modifies the data encapsulated in this NetPacket. + * @param data the packet's data + * @pre $none + * @post $none + */ + public void setData(Object data) { + this.obj = data; + } + + /** + * Gets the size of this packet + * @return the packet size + * @pre $none + * @post $none + */ + public long getSize() { + return size; + } + + /** + * Gets the original size of this packet + * @return the packet size + * @pre $none + * @post $none + */ + public long getOrigSize() { + return origSize; + } + + /** + * Sets the packet size + * @param size the packet size + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre size >= 0 + * @post $none + */ + public boolean setSize(long size) + { + if (size < 0) { + return false; + } + + this.size = size; + return true; + } + + /** + * Returns the tag associated originally with data that was encapsulated in + * this packet. + * + * @return the tag of the data contained. + * @pre $none + * @post $none + */ + public int getTag() { + return tag; + } + + /** + * Returns the destination ID of this packet + * + * @return destination ID + * @pre $none + * @post $none + */ + public int getDestID() { + return destID; + } + + /** + * Sets the destination id of this packet + * @param id the destination id + * @pre id >= 0 + * @post $none + */ + public void setDestID(int id) { + this.destID = id; + } + + /** + * Sets the last hop that this NetPacket traversed. This is used to + * determine the next hop at routers. Only routers and hosts/GridResources + * set this, links do not modify it. + * @param last the entity ID from the last hop + * @pre last >= 0 + * @post $none + */ + public void setLast(int last) { + this.last = last; + } + + /** + * Returns the ID of the last hop that this packet traversed. This could be + * the ID of a router, host or GridResource. + * + * @return ID of the last hop + * @pre $none + * @post $none + */ + public int getLast() { + return last; + } + + /** + * Sets the network class type of this packet, so that it can receive + * differentiated services. + * @param netServiceType a network service type + * @pre netServiceType >= 0 + * @post $none + */ + public void setNetServiceType(int netServiceType) { + this.classType = netServiceType; + } + + /** + * Returns the class type of this packet. Used by routers etc. to determine + * the level of service that this packet should obtain. + * + * @return the class of this packet + * @pre $none + * @post $none + */ + public int getNetServiceType() { + return classType; + } + + /** + * Returns the serial number of this packet. + * + * @return packet number + * @pre $none + * @post $none + */ + public int getPacketNum() { + return pktNum; + } + + /** + * Returns the total number of packets in this stream. A stream of + * packets is sent whenever the data is too big to be sent as one + * packet. + * + * @return total number of packets in this stream. + * @pre $none + * @post $none + */ + public int getTotalPackets() { + return totalPkts; + } + + public double getLatency() { + return latency; + } + + public void addLatency(double latency) { + this.latency += latency; + } + + public void addBaudRate(double baudRate) + { + if (baudRates_ == null) { + return; + } + + baudRates_.add( new Double(baudRate) ); + if (bandwidth_ < 0 || baudRate < this.bandwidth_) { + this.bandwidth_ = baudRate; + } + } + + public double getBandwidth_() { + return bandwidth_; + } + + public void setBandwidth_(double bandwidth_) { + this.bandwidth_ = bandwidth_; + } + + public void addLink(Link link) + { + if (links_ == null) { + return; + } + + links_.add( link ); + } + +} // end class + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-02-21 06:06:30
|
Revision: 119 http://gridsim.svn.sourceforge.net/gridsim/?rev=119&view=rev Author: brobergj Date: 2008-02-20 22:06:35 -0800 (Wed, 20 Feb 2008) Log Message: ----------- *Made tracking of bottleneck easier via addLink() *Track bottleneck Link ID at all times *Track remaining flow size Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-21 05:35:52 UTC (rev 118) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-21 06:06:35 UTC (rev 119) @@ -31,10 +31,11 @@ private int destID; // where the packet wants to go private int srcID; // sender ID private long size; // packet size (for calculating transmission time) - private long origSize; // original packet size + private long remSize; // remaining packet size private Object obj; // the actual object, the type depends on context private double bandwidth_; // Bottleneck baud rate + private int bottleneckID; // Bottleneck link ID private Vector baudRates_; // list of entity's baud rate @@ -43,6 +44,12 @@ // Sum of latency (delay) on path private double latency; + // Packet start time + private double startTime; + + // Packet last size update time + private double updateTime; + // original tag with which the encapsulated object was submitted private int tag; @@ -74,7 +81,9 @@ { this.obj = data ; this.size = size ; - this.origSize = size ; + this.remSize = size ; + this.startTime = -1.0; + this.updateTime = -1.0; this.tag = tag ; this.destID = destID; this.srcID = srcID ; @@ -87,6 +96,7 @@ this.latency = 0.0; this.bandwidth_ = Double.MAX_VALUE; this.baudRates_ = new Vector(); + this.bottleneckID = -1; } @@ -118,6 +128,9 @@ { this.obj = data; this.size = size; + this.remSize = size ; + this.startTime = -1.0; + this.updateTime = -1.0; this.tag = tag; this.destID = destID; this.srcID = srcID; @@ -130,6 +143,8 @@ this.latency = 0.0; this.bandwidth_ = -1; this.baudRates_ = new Vector(); + this.links_ = new Vector(); + this.bottleneckID = -1; } @@ -227,16 +242,6 @@ } /** - * Gets the original size of this packet - * @return the packet size - * @pre $none - * @post $none - */ - public long getOrigSize() { - return origSize; - } - - /** * Sets the packet size * @param size the packet size * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise @@ -365,15 +370,18 @@ this.latency += latency; } - public void addBaudRate(double baudRate) + public synchronized void addBaudRate(Link link) { + double baudRate = link.getBaudRate(); + if (baudRates_ == null) { return; } baudRates_.add( new Double(baudRate) ); if (bandwidth_ < 0 || baudRate < this.bandwidth_) { - this.bandwidth_ = baudRate; + this.setBandwidth_(baudRate); + this.setBottleneckID(link.get_id()); } } @@ -381,18 +389,56 @@ return bandwidth_; } - public void setBandwidth_(double bandwidth_) { + public synchronized void setBandwidth_(double bandwidth_) { this.bandwidth_ = bandwidth_; } - public void addLink(Link link) + public synchronized void addLink(Link link) { if (links_ == null) { return; } links_.add( link ); + this.addBaudRate(link); + this.addLatency(link.getDelay()); } + public double getStartTime() { + return startTime; + } + + public void setStartTime(double startTime) { + this.startTime = startTime; + } + + public double getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(double updateTime) { + this.updateTime = updateTime; + } + + public long getRemSize() { + return remSize; + } + + public void setRemSize(long remSize) { + this.remSize = remSize; + } + + public Vector getLinks_() { + return links_; + } + + public int getBottleneckID() { + return bottleneckID; + } + + public void setBottleneckID(int bottleneckID) { + this.bottleneckID = bottleneckID; + } + } // end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-02-22 02:10:58
|
Revision: 124 http://gridsim.svn.sourceforge.net/gridsim/?rev=124&view=rev Author: brobergj Date: 2008-02-21 18:11:02 -0800 (Thu, 21 Feb 2008) Log Message: ----------- *Added comments and javadoc Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-22 02:10:46 UTC (rev 123) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-22 02:11:02 UTC (rev 124) @@ -16,7 +16,6 @@ import gridsim.*; import gridsim.net.Link; import gridsim.net.Packet; -import eduni.simjava.*; /** @@ -28,18 +27,18 @@ */ public class FlowPacket implements Packet { - private int destID; // where the packet wants to go + private int destID; // where the flow wants to go private int srcID; // sender ID - private long size; // packet size (for calculating transmission time) - private long remSize; // remaining packet size + private long size; // flow size (for calculating transmission time) + private long remSize; // remaining flow size private Object obj; // the actual object, the type depends on context private double bandwidth_; // Bottleneck baud rate private int bottleneckID; // Bottleneck link ID - private Vector baudRates_; // list of entity's baud rate + private Vector baudRates_; // list of entity's baud rate on path from source to dest - private Vector links_; + private Vector links_; // list of entity's links on path from source to dest // Sum of latency (delay) on path private double latency; @@ -63,7 +62,7 @@ private int pktID_; // a unique packet ID issued by an entity /** - * Constructs a network packet for data that fits into a single network + * Constructs a network flow for data that fits into a single network * packet. * * @param data The data to be encapsulated. @@ -96,6 +95,7 @@ this.latency = 0.0; this.bandwidth_ = Double.MAX_VALUE; this.baudRates_ = new Vector(); + this.links_ = new Vector(); this.bottleneckID = -1; } @@ -362,14 +362,36 @@ return totalPkts; } + /** + * Returns the current sum of latency over the path from source to dest. + * + * @return latency + * @pre $none + * @post $none + */ public double getLatency() { return latency; } + /** + * Adds to the current sum of latency over the path from source to dest. + * + * @param latency the latency of a given link + * @pre $none + * @post $none + */ public void addLatency(double latency) { this.latency += latency; } + /** + * Adds baud rate of current link, and sets bottleneck + * bandwidth and ID if the link is this flow's bottleneck + * + * @param link a given link + * @pre $none + * @post $none + */ public synchronized void addBaudRate(Link link) { double baudRate = link.getBaudRate(); @@ -385,14 +407,35 @@ } } + /** + * Returns the current bottleneck bandwidth of this flow. + * + * @return bandwidth_ + * @pre $none + * @post $none + */ public double getBandwidth_() { return bandwidth_; } + /** + * Sets the current bottleneck bandwidth of this flow. + * + * param bandwidth_ the current bottleneck bandwidth + * @pre $none + * @post $none + */ public synchronized void setBandwidth_(double bandwidth_) { this.bandwidth_ = bandwidth_; } + /** + * Adds current link, and calls addBaudRate() and addLatency() + * + * @param link a given link + * @pre $none + * @post $none + */ public synchronized void addLink(Link link) { if (links_ == null) { @@ -404,38 +447,103 @@ this.addLatency(link.getDelay()); } + /** + * Returns the current start time of this flow. + * + * @return startTime + * @pre $none + * @post $none + */ public double getStartTime() { return startTime; } + /** + * Sets the current start time of this flow. + * + * @param startTime the time a flow begins holding at the destination + * @pre $none + * @post $none + */ public void setStartTime(double startTime) { this.startTime = startTime; } + /** + * Returns the last time a flow was updated (i.e. bottleneck + * bandwidth changed and forecast was recomputed) + * + * @return updateTime + * @pre $none + * @post $none + */ public double getUpdateTime() { return updateTime; } + /** + * Sets the last time a flow was updated (i.e. bottleneck + * bandwidth changed and forecast was recomputed) + * + * @param updateTime the time a flow's forecast was last updated + * @pre $none + * @post $none + */ public void setUpdateTime(double updateTime) { this.updateTime = updateTime; } + /** + * Returns the remaining size of a flow + * + * @return remSize + * @pre $none + * @post $none + */ public long getRemSize() { return remSize; } + /** + * Sets the remaining size of a flow + * + * param remSize the remaining size of a flow + * @pre $none + * @post $none + */ public void setRemSize(long remSize) { this.remSize = remSize; } + /** + * Returns a vector of links that make up this flow's path + * + * @return links_ + * @pre $none + * @post $none + */ public Vector getLinks_() { return links_; } + /** + * Returns the FlowLink ID of the bottleneck of this flow + * + * @return bottleneckID + * @pre $none + * @post $none + */ public int getBottleneckID() { return bottleneckID; } + /** + * ets the FlowLink ID of the bottleneck of this flow + * + * param bottleneckID the ID of the bottleneck FlowLink + * @pre $none + * @post $none + */ public void setBottleneckID(int bottleneckID) { this.bottleneckID = bottleneckID; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-02-26 04:44:00
|
Revision: 130 http://gridsim.svn.sourceforge.net/gridsim/?rev=130&view=rev Author: brobergj Date: 2008-02-25 20:44:05 -0800 (Mon, 25 Feb 2008) Log Message: ----------- *Minor changes Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-26 04:40:33 UTC (rev 129) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-02-26 04:44:05 UTC (rev 130) @@ -35,7 +35,7 @@ private double bandwidth_; // Bottleneck baud rate private int bottleneckID; // Bottleneck link ID - + private Vector baudRates_; // list of entity's baud rate on path from source to dest private Vector links_; // list of entity's links on path from source to dest @@ -372,6 +372,17 @@ public double getLatency() { return latency; } + + /** + * Sets the current latency over the path from source to dest. + * + * param latency + * @pre $none + * @post $none + */ + public void setLatency(double latency) { + this.latency = latency; + } /** * Adds to the current sum of latency over the path from source to dest. @@ -538,7 +549,7 @@ } /** - * ets the FlowLink ID of the bottleneck of this flow + * Sets the FlowLink ID of the bottleneck of this flow * * param bottleneckID the ID of the bottleneck FlowLink * @pre $none @@ -548,5 +559,20 @@ this.bottleneckID = bottleneckID; } + /** + * Sets the source ID for a FlowPacket + * + * param srcID the id of the source of this flow + * @pre $none + * @post $none + */ + public void setSrcID(int srcID) { + this.srcID = srcID; + } + + public void setTag(int tag) { + this.tag = tag; + } + } // end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |