GridSim v1

Document Sample
GridSim v1 Powered By Docstoc
					                                                       Table of Content
1. Coding Conventions ................................................................ 2
     definitions ....................................................................................................................................... 2
     examples ......................................................................................................................................... 2
2. Topology ................................................................................... 3
3. Data Structures ........................................................................ 4
     GridFile ........................................................................................................................................... 4
     GridPacket....................................................................................................................................... 4
     GridRecorder................................................................................................................................... 5
     GridRouter ...................................................................................................................................... 6
     GridGlobalInfo................................................................................................................................ 7
     GridAgent ....................................................................................................................................... 8
     GridAgentServer ............................................................................................................................. 9
     GridAgentCache.............................................................................................................................. 9
     GridAgentClient............................................................................................................................ 10
4. Protocols ..................................................................................11
     Read Protocol................................................................................................................................ 11
     Write Protocol ............................................................................................................................... 12
     Probe Protocol............................................................................................................................... 14
     RoutingRegular4Read Protocol .................................................................................................... 14
     RoutingOnChange4Read Protocol ................................................................................................ 15
     RoutingRegular4Write Protocol.................................................................................................... 15
5. Commands ............................................................................. 16
     Commands deleted in this version ................................................................................................ 16
     Commands changed in this version............................................................................................... 16
     Commands to setup the topology.................................................................................................. 17
     Commands to setup system parameters ........................................................................................ 17
     Commands to operate the simulator.............................................................................................. 18
6. How to Install......................................................................... 20
7. How to define a new protocol ............................................... 22
8. An example of the script file ................................................. 23




Page 1 of 24
1. Coding Conventions
definitions

     allCapitalizedWord ::= [A-Z]+
     firstCapitalizedWord ::= [A-Z] [a-z]*
     normalWord ::= [a-z]+
     acronymWord ::= {allCapitalizedWord}
     name ::= {normalWord} ({acronymWord} | {firstCapitalizedWord})*

     globalVariableName ::= "g_" {name}
     memberVariableName ::= "m_" {name}
     parameterVariableName ::= "pm_" {name}
     localVarialbeName ::= {name}
     constantName ::= {allCapitalizedWord} ("_" {allCapitalizedWord})*
     memberFunctionName ::= {name}
     className ::= {firstCapitalizedWord}+
     fileName ::= "Grid" {firstCapitalizedWord}+ (".h" | ".cpp")

NOTE: we use the same coding rule for localVariablename and memberFunctionName. However, it is
      easy to differentiate them because all calls to memberFunctions are followed by the ()
      operator.



examples

           global variable name
           extern double g_alphaRead;

           member variable name
           unsigned long m_fileSize;

           parameter variable name
           virtual int command(int pm_argc, const char*const* pm_argv);

           constant name
           #define GRID_PROTOCOL_READ         0

           member function name
           void setNodeNumber(unsigned long);

           class name
           class GridGlobalInfo {...};




Page 2 of 24
2. Topology
The definition of the GridNet topology is two steps. First we can say that the GridNet is a DAG
(Directed Acyclic Graph). Second, based on the DAG, we define the relationship "sibling". With the
concept of sibling, the GridNet topology will not be a DAG any more because the nodes in a sibling
relationship could form a circle. However, here sibling is a special kind of circle. We call it a "local
circle". Only closely coupled nodes can form a sibling circle. We treat a sibling as a fully connected
sub-graph. And we take care of it to avoid endless loop.

The nodes in the DAG are classified into 3 types: GridAgentServer, GridAgentCache and
GridAgentClient. This classification is based on the first step of the definition: the GridNet is a
DAG. In this view, GridAgentServers are those nodes that do not have incoming arcs but have
outgoing arcs. GridAgentClients are those nodes that do not have outgoing arcs but have
incoming arcs. All other nodes are GridAgentCaches. Furthermore, we don't allow a
GridAgentClient to directly connect with GridAgentServer. That is, between any pair of
GridAgentClient and GridAgentServer, there is at least one GridAgentCache node.

Based on the DAG, now we are going to define the sibling. A sibling is only composed of the same
type of nodes. And there is no sibling for GridAgentClient. So basically, we have two types of
siblings: sibling of GridAgentServer and sibling of GridAgentCache. All the
GridAgentServer nodes are in a sibling. Because we suppose the whole data set could distributed
on the GridAgentServers. And a GridAgentServer could hold only part of the whole data
set. When a request comes to a GridAgentServer and that file is not on it, this server could
forward the request to other servers. A sibling of GridAgentCaches is based on the fact that some
cache nodes are so closely coupled that they could be treat as ONE virtual node both from the view of
the up level nodes and the down level nodes.

GridAgentClient issues requests. GridAgentClient could have one or more parents. All
parents should be GridAgentCache. There is no child for GridAgentClient.

GridAgentCache could have one or more children and have one or more parents. A child could be
GridAgentCache or GridAgentClient. A parent could be GridAgentCache or
GridAgentServer.

GridAgentServer could have one or more children and have one or more siblings.
GridAgentServer has no parent. All siblings are GridAgentServers. All children are
GridAgentCache.

Each server could hold only a part of the whole set of files.

In the system, files could only be added or removed at the Servers.




Page 3 of 24
3. Data Structures
GridFile

class GridFile
{
   GridID            m_fileID;
   int               m_fileSize;
public:
   GridFile(GridID pm_fileID, int pm_fileSize);
   GridID getFileID();
   int getFileSize();
};

GridFile is a file descriptor. It has only two fields: ID and size. Both fields should be filled in the
constructor when an object is created. After the object is created, neither field could be changed. In
Read Protocol, at the Request stage, the field m_file of GridPacket is null. It is filled at the
server which contains this file at the Response stage.

GridPacket

class GridPacket : public AppData
{
   GridID            m_packetID;
   GridID            m_protocolID;
   GridID            m_taskID;
   GridID            m_fileID;
   GridFile*         m_file;
   GridTrace         m_trace;
   GridAgent*        m_agent; //current station

     union { //put the protocol data here
        GridPacketWrite*         u_writeData;
        GridPacketRead*          u_readData;
        GridPacketProbe*         u_probeData;
        GridPacketRegularRead*   u_regularReadData;
        GridPacketRegularWrite* u_regularWriteData;
        GridPacketOnChangeRead* u_onChangeReadData;
     } m_protocolData;

friend class GridRouterWrite;
friend class GridRouterRead;
friend class GridRouterProbe;

public:
   GridID getProtocolID();
   GridID getFileID();




Page 4 of 24
     GridFile* getFile();
     GridAgent* getAgent();
     void putFile(GridFile* pm_file);
     void putAgent(GridAgent* pm_agent);
     void putHop(GridHop pm_hop);
     void putProtocolData(GridProtocolData* pm_protocolData);
     GridProtocolData* getProtocolData();
     GridPacket(GridID pm_protocolID, GridID pm_fileID):
         AppData(GRID_SIM_PACKET);
     GridPacket(GridPacket& pm_packet):AppData(GRID_SIM_PACKET);
     virtual int size() const;
     virtual AppData* copy();
};

The GridPacket is used to carry data for any request/response of any protocol. Due to the fact that
different protocol could have different data, we use an unnamed union to contain the protocol data and
use the field m_protocolID as a selector for the unnamed union.

GridRecorder

In each GridAgent, we have a set of Recorders. Usually a recorder is mapped to a protocol. However,
a Recorder could be shared by several protocols if you want to join the records together and the
records have the same structure.

class GridRecorder
{
protected:
   GridAgent*      m_agent;
public:
   GridRecorder(GridAgent* pm_agent);
};

Because protocols could have different requirements about the information to record, we define a
Recorder class for each protocol. The only common part for the recorders is the field m_agent. This
field points to the GridAgent that contains the recorder. Here is an example of GridRecorderRead,
which is a recorder for the Read Protocol.

class GridRecorderRead : public GridRecorder
{
   //<GridID: fileID, GridCounterRead: readCounter>
   map<GridID, GridCounterRead> m_readCounters;

     //<GridID: fileID, double: responseTime>
     map<GridID, double>       m_readResponse;

     //<GridID: fileID, int: responseCounter>
     map<GridID, int>         m_readResponseCounter;

public:
   GridRecorderRead(GridAgent* pm_agent);
   void recordReadCount(GridID pm_fileID);
   double getReadRate(GridID pm_fileID);
   void recordReadResponse(GridID pm_fileID, double pm_responseTime);
   void report();


Page 5 of 24
};

In this Read recorder, we maintain three tables: how many read requests are received in the container
agent for each file, how many read responses are received and what is the average response time for
each file.

A Recorder is usually called by its corresponding Router. Of course, it also could be called somewhere
else, whenever you want to record something for the current protocol.

GridRouter

In each GridAgent, we have a set of Routers. Usually a Router is mapped to a protocol. However, a
Recorder could be shared by several protocols if these protocols have the same routing definition.

class GridRouter
{
public:
   virtual void process_packet(GridPacket* pm_packet,
              GridAgent* pm_agent) = 0;
};

The only common part of the routers is the method process_packet, which is a pure virtual
function. Any Routers directly derived from GridRouter should explicitly define it or keep it as a pure
virtual function. This method works as a GridPacket dispatcher. When a GridAgent receives a
GridPacket, it first inspects the protocol used in the packet, then the GridPacket will be forwarded to
the Router for this protocol.

When a Router receives a GridPacket, it is always sent to the method process_packet. Here
process_packet is another GridPacket dispatcher. process_packet will check the AgentType
of the host Agent. Then based on the information in the packet, the corresponding even handler will be
called.

In each Router, a set of event handlers should be defined. Here is an example:

class GridRouterRead : public GridRouter
{
public:
   virtual void process_packet(GridPacket* pm_packet,
                     GridAgent* pm_agent);

     void onReceiveAckAtClient(GridPacket* pm_packet,
                       GridAgent* pm_agent);
     void onSendRequestAtClient(GridPacket* pm_packet,
                       GridAgent* pm_agent);

     void onReceiveAckAtCache(GridPacket* pm_packet,
                       GridAgent* pm_agent);
     void onSendAckAtCache(GridPacket* pm_packet,
                       GridAgent* pm_agent);
     void onReceiveRequestAtCache(GridPacket* pm_packet,
                       GridAgent* pm_agent);
     void onSendRequestAtCache(GridPacket* pm_packet,
                       GridAgent* pm_agent);


Page 6 of 24
     void onReceiveRequestAtServer(GridPacket* pm_packet,
                       GridAgent* pm_agent);
     void onSendAckAtServer(GridPacket* pm_packet,
                       GridAgent* pm_agent);
};

As shown in the above code, a couple of event handlers are defined. At the Clients, we have at least
two events: sending the Read Request and receiving the Read Response. At the Caches, we have four
events: receiving Read Request, forwarding Read Request, receiving Read Response and
forwarding/sending Read Response. At the Servers, there are only two events defined: receiving Read
Request and sending Read Response. This is only a router for Read protocol. In the router for Write
protocol, we need more event handlers, because we also need to update other GridAgents that are
holding a replica of the file.

GridGlobalInfo

class GridGlobalInfo
{
   //{topology & bandwidth
   vector<vector<double> >                           m_currentBandwidth;
    // -1 for non-connected
   //}topology & bandwidth

     //{"Agent Collection"
     //<GridID:agentID, GridAgent:agentPointer>
     map<GridID, GridAgent*>            m_agents;
     //}"Agent Collection"

     //{"global file catalog"
     map<GridFile*, set<GridAgent*> >   m_fileCatalog; //"global catalog"
     map<GridID, GridFile*>             m_files;
     //"file collection" constant after initilized.
     //}"global file catalog"

public:
   GridGlobalInfo();

     void printBandwidth();

     void addFileToAgent(GridFile*, GridAgent*);
     void removeFileFromAgent(GridFile*, GridAgent*);

     //void setNodeNumber(int);
     void updateLinkBandwidth(GridID pm_fromAgentID,
                       GridID pm_toAgentID, double pm_bandwidth);
     double getLinkBandwidth(GridID pm_fromAgentID,
                       GridID pm_toAgentID);

     GridAgent* getAgent(GridID pm_agentID);
     void putAgent(GridAgent* pm_agent);

     void addChildrenForAgent(vector<GridID> pm_childrenID,
                       GridID pm_agentID);



Page 7 of 24
     void addSiblingsForAgent(vector<GridID> pm_siblingsID,
                       GridID pm_agentID);

     bool isChildOf(GridID pm_childID, GridID pm_parentID);
     bool isParentOf(GridID pm_parentID, GridID pm_childID);
     bool isSiblingOf(GridID pm_sibling1, GridID pm_sibling2);

     vector<GridID> getChildren(GridID pm_agentID);
     vector<GridID> getParents(GridID pm_agentID);
     vector<GridID> getSiblings(GridID pm_agentID);
     GridFile* getGridFile(GridID pm_fileID) ;
};

We defined some global tables to facilitate the simulation. Actually, the content in this class could be
embedded in GridAgent as static data members and static method members. We put them in a separate
class to make it clear to understand.

We maintain 4 global tables here.

    vector<vector<double> >                             m_currentBandwidth;
    // -1 for non-connected
The first is the Topology & Bandwidth table. From this table we can know if a pair of nodes is
connected. And if they are connected, what is the current available bandwidth for the GridNet.

     //<GridID:agentID, GridAgent:agentPointer>
     map<GridID, GridAgent*>                          m_agents;
The second table is Agent Collection. Given any Agent ID, we can get the GridAgent object.

      map<GridFile*, set<GridAgent*> > m_fileCatalog;
The third table is the Global File Catalog. Given any GridFile object, we can get all the GridAgents
that contain the GridFile.

     map<GridID, GridFile*>                              m_files;
The last one is used to fine the GridFile object from the file ID.

GridAgent

class GridAgent : public HttpApp
{
protected:
   static GridGlobalInfo*      m_globalInfo;
   static FILE*                m_log;        //log file

     //<GridID:protocolID, GridRecorder*:recorder>
     map<GridID, GridRecorder*> m_recorders;
     //each node has a set of recorders, one recorder per protocol

     //<GridID:protocolID, GridRouter*:router>
     map<GridID, GridRouter*>   m_routers;
     //each node has a set of routers, one router per protocol

     //<GridID:fileID, GridFile*:file>
     map<GridID, GridFile*>     m_files;                         //local catalog



Page 8 of 24
     int                m_totalDiskSpace;                   //disk space
     int                m_availableDiskSpace;               //available disk space

public:
   GridAgent(GridID pm_agentID, int pm_totalDiskSpace);
   virtual int command(int pm_argc, const char*const* pm_argv);
   static GridGlobalInfo* getGlobalInfo();
   static double getGridTime();
   virtual GridID getAgentType() = 0;
   void addFile(GridFile* pm_file);
   void removeFile(GridFile* pm_file);
   bool isHoldingFile(GridFile* pm_file);

     GridRecorder* getRecorder(GridID pm_protocolID);
     GridRouter* getRouter(GridID pm_protocolID);
     void sendPacket(GridID pm_fromAgentID,
                   GridID pm_toAgentID,
                   GridPacket* pm_packet);
};

GridAgent is the common parent of the three types of nodes. In this class, we define the static
members, which are the GridGlobalInfo and a log file handle.

Also, all common data members and method members are defined here: Recorders, Routers, local
catalog and information about the storage of the current GridAgent.

GridAgentServer

class GridAgentServer : public GridAgent
{
public:
   GridAgentServer(GridID pm_agentID, int pm_totalDiskSpace):
       GridAgent(pm_agentID, pm_totalDiskSpace){}
   virtual int command(int pm_argc, const char*const* pm_argv);
   virtual void process_data(int pm_packetSize, AppData* pm_Packet);
   virtual GridID getAgentType(){return GRID_AGENT_SERVER;}
};

Whenever a GridAgentServer receives a GridPacket, it uses the method process_data to dispatch
it to the corresponding router.

GridAgentCache


class GridAgentCache : public GridAgent
{
public:
   GridAgentCache(GridID pm_agentID, int pm_totalDiskSpace):
       GridAgent(pm_agentID, pm_totalDiskSpace){}
   virtual void process_data(int pm_packetSize, AppData* pm_Packet);
   inline virtual GridID getAgentType(){return GRID_AGENT_CACHE;}
};


Page 9 of 24
Whenever a GridAgentCache receives a GridPacket, it uses the method process_data to dispatch it
to the corresponding router.



GridAgentClient


class GridAgentClient : public GridAgent
{
public:
   GridAgentClient(GridID pm_agentID, int pm_totalDiskSpace):
       GridAgent(pm_agentID, pm_totalDiskSpace){}
   virtual int command(int pm_argc, const char*const* pm_argv);
   virtual void process_data(int pm_packetSize, AppData* pm_Packet);
   inline virtual GridID getAgentType(){return GRID_AGENT_CLIENT;}
};

Whenever a GridAgentClient receives a GridPacket, it uses the method process_data to dispatch it
to the corresponding router.




Page 10 of 24
4. Protocols
The following Protocols are defined in this version:
    1) Read Protocol
    2) Write Protocol
    3) Probe Protocol
    4) RoutingRegular Protocol
    5) RoutingOnChange Protocol



Read Protocol

NOTE: at the "response" stage, the packet will go the same path but in the other direction. Only when
      an Agent receives a read-response packet, the cost model will be consulted and the Agent
      determines whether to create a local copy.

     1) at GridAgentClient(read-request):
           create a packet
           record the event
           if (there is a local copy){
                 bounce back the request
                 record the event
           }
           else{
                 find a best route
                 send the packet to the next hop
           }

     2) at GridAgentCache(read-request):
           record the event
           if (there is a local copy){
                 send back the packet
                 record the event
           }
           else{
                 find a best route
                 send the packet to the next hop
           }

     3) at GridAgentServer(read-request read-response):
           record the event
           if(there is a local copy){
                 send back the packet
                 record the event
           }
           else{
                 find the best server that contains the requested file



Page 11 of 24
                forward the request to that server
          }
          NOTE: A read-request at most consults two servers, because a forwarded read-request from
a server will never miss. It will always forward the read-request to the server which is containing the
requested file.

     4) at GridAgentCache(read-response):
           record the event
           if (cost model says that a local copy is needed){
                 if (there is enough disk space){
                       make a local copy
                       update local catalog
                       update global catalog
                 }
                 else if (make enough room from inferior replicas){
                       delete one or more inferior replicas
                       make a local copy
                       update local catalog
                       update global catalog
                       for (all children agents){
                             create RoutingOnChange packet
                             send out the RoutingOnChange packet
                       }
                 }
           }
           forward the packet to next hop

     5) at GridAgentClient(read-response):
           record the event
           if (cost model says that a local copy is needed){
                 if (there is enough disk space){
                       make a local copy
                       update local catalog
                       update global catalog
                 }
                 else if (make enough room from inferior copies){
                       delete inferior copies
                       make a local copy
                       update local catalog
                       update global catalog
                 }
           }



Write Protocol

     **NOTE: a) When a file copy is invalidated, that copy will be deleted
                 from that Agent.
            b) The write router should find a fastest route to one of the
                 server.
            c) At the "request" stage, the packet will be sent to one of the



Page 12 of 24
                     server directly. Nothing is done during the trip from Client to
                     Server. (In the V1.0, we used a strict or not policy.)
                d) At the "response" stage, a "lazy" or not policy is employed. If
                     "lazy" policy is used, all the copies in GridAgentClient and
                     GridAgentCache will be invalidated (deleted). If "not lazy"
                     policy is used, all the copies in GridAgentClient and
                     GridAgentCache will be updated (touched). In both cases, all the
                     copies in GridAgentServer will be updated.
                e) We assume the all the write-request only make small changes
                     to the files and the file sizes are NOT changed.
                f) Since the frequency of write-requests is so low that we
                     ignore the cases that two or more write-requests conflict. In
                     that case, we would need more complicated protocol for the
                     write-requests (refer to the two phrases protocol talked in
                     Distributed Database System??).

     1) at GridAgentClient(write-request):
           create a packet
           record the event
           find a best route
           send the packet to the next hop;

     2) at GridAgentCache(write-request):
           record the event
           find a best route
           send the packet to the next hop

     3) at GridAgentServer(write-request -> write-response):
           record the event
           if (the write-request is from a GridAgentCache){
                 for (all sibling GridAgentServer){
                       forward the write-request to them
                 }
                 for (all children GridAgentCache){
                       if (lazy scheme is used){
                             create & send out write-invalid-response
                       }
                       else{
                             create & send out write-update-response
                       }
                 }
           }
           else{//the write-request is from a sibling GridAgentServer
                 if (there is local copy){
                       update the local copy (record touch time??)
                 }
                 for (all children GridAgentCache){
                       if (lazy scheme is used){
                             create & send out write-invalid-response
                       }
                       else{
                             create & send out write-update-response
                       }



Page 13 of 24
                }
          }

     4) at GridAgentCache(write-response):
           record the event
           if (there is local copy){
                 if (write-invalid-response){
                       delete the local copy
                       update the local catalog
                       update the global catalog
                 }
                 else if(write-update-response){
                       update the local copy
                 }
           }
           forward the packet to next hop

     5) at GridAgentClient(read-response):
           record the event
           if (there is local copy){
                 if (write-invalid-response){
                       delete the local copy
                       update the local catalog
                       update the global catalog
                 }
                 else if(write-update-response){
                       update the local copy
                 }
           }



Probe Protocol

     record the event
     update global info
     schedule the next probe to the peer agent



RoutingRegular4Read Protocol

     **NOTE: There are two stages for this protocol: "issue" and "receive".
     At GridAgentServer:
         On "issue":
             for (all children and siblings){
                   generate a random number
                   schedule a packet
             }
             schedule the next "issue"

          On "receive":


Page 14 of 24
                update the routing table for Read-Request

     At GridAgentCache:
         On "receive":
             update the routing table for Read-Request
             for (all children){
                   "issue" a packet
             }

     At GridAgentClient:
         On "receive":
             update the routing table for Read-Request



RoutingOnChange4Read Protocol

     On "receive":
         update the routing table for read
         for (all children){
               "issue" a packet
         }



RoutingRegular4Write Protocol

     **NOTE: There are two stages for this protocol: "issue" and "receive".
     At GridAgentServer:
         On "issue":
             for (all children){//NOTE: no sibling here
                   generate a random number
                   schedule a packet
             }
             schedule the next "issue"

     At GridAgentCache:
         On "receive":
             update the routing table for Write-Request
             for (all children){
                   "issue" a packet
             }

     At GridAgentClient:
         On "receive":
             update the routing table for Write-Request




Page 15 of 24
5. Commands
Commands deleted in this version

$gridagent set-write-strict-on
    If strict policy is used, the replicas will be invalidated on the path of sending the write-request
from client to server. Use this command to switch on the strict policy.

$gridagent set-write-strict-off
   Switch off the strict policy.

$gridagent set-storage <long capacity>
   Set the storage capacity of this node.

$gridagent add-parent           <gridagent>
   Add a parent gridagent. Then the current node will be child gridagent of the parent automatically.

$gridagent set-default-parent <gridagent>
   set a default parent.

$gridagent set-energy             <int energy_capacity>
   See the energy model.

$gridagent report
   Print out report.



Commands changed in this version

OLD: $server set-interval-update-routes <float interval>
   set the period value of updating routes.
NEW: $GridServer set-interval-regular-read <float interval>
  set the period value of updating routes.

OLD: $gridagent start-probe
      start the bandwidth-probing program. The interval between two probes is defined by
"set-interval-bandwidth".
NEW: $gridagent start
      start probing
      start regular for read
      start regular for write

OLD: $server update-routes
   start to update routes regularly.
NEW: $gridagent start



Page 16 of 24
     start probing
     start regular for read
     start regular for write



Commands to setup the topology

$gridagent add-child <int children[]>
     Add child gridagents.
     Pre-Condition: all the agents in the parameter should not be connected with the current agent,
neither siblings nor parents.
     Post-Condition: all the agents in the parameter will be child agents of the current agent.

$gridagent add-sibling <int children[]>
     Add siblings gridagents.
     Pre-Condition: no agent in the parameter is connected with the current agent and any two agents
in the parameter is not connected.
     Post-Condition: any two agents from (agents in parameter + the current agent) are connected,
bidirectionally.



Commands to setup system parameters

$gridagent set-cost-model <int model_number>
    suppose we have several cost models to use, select particular cost model by using this command.
Note, only one cost model can be active.

$gridagent set-write-lazy-on
     If lazy policy is used, servers will not update replicas initiatively. Replicas will be updated by
issuing read-request. Use this command to switch on the lazy policy.

$gridagent set-write-lazy-off
   Switch off the lazy policy.

$gridagent set-probe-size <long file_size>
   Set the file size used to probe the bandwidth of grid links.

$gridagent set-alpha-read <float history_coefficient>
     The read-rate value is computed and updated periodically. This value determines how much of
the previous read-rate will affect the next read-rate. The formula is:

     read_rate(n+1) = alpha_read * read_rate(n) + (1 - alpha_read) * (read_count(n+1) /
interval_read);

     read_rate(n) is the read_rate until the nth period. read_count(n) is the read_count during the nth
period.

     Use this command to set the alpha_read value.

$gridagent set-alpha-write <float history_coefficient>


Page 17 of 24
     Use this command to set the alpha_write value.

$gridagent set-alpha-bandwidth <float history_coefficient>
   Use this command to set the alpha_bandwidth value.

$gridagent set-interval-read <float interval>
   Set the period value to compute the read_rate.

$gridagent set-interval-write <float interval>
   Set the period value to compute the write_rate.

$gridagent set-interval-bandwidth <float interval>
   Set the period value to probe the bandwidth of each grid links.

$gridagent set-interval-regular-read <float interval>
   set the period value of updating routes.

$gridagent set-interval-regular-write <float interval>
   set the period value of updating routes.



Commands to operate the simulator

$gridagent start
   start probing
   start regular for read
   start regular for write

$gridagent turn-monitor-on
   Turn the cost model on.

$gridagent turn-monitor-off
   Turn the cost model off.

$gridagent set-monitor-start-time <float start_time>
   Set the start time of cost model.

$gridagent open-log <filename>
   Open a disk file to log some statistics.

$gridagent cost-log
   Close the log file.

$server add-file <int fid>               <int fsize>
   add a file to this server;

$server remove-file <int fid>
   remove a file from this server;

$client read-request <int fid>
   send read-request.



Page 18 of 24
$client write-request <int fid>
   send write-request.




Page 19 of 24
6. How to Install
I tested the GridSim under the latest version of NS2, which is 2.26. I think it should work under other
versions, such as 2.1b9.

Before you install the GridSim, please install ns2-2.26 by following the installation instructions. I
recommend the "all-in-one" package, which can be downloaded from this URL:

http://www.isi.edu/nsnam/dist/ns-allinone-2.26.tar.gz

To install the GridSim, we need to modify 4 files which come with ns2. Please find these updated files
under the folder "patches" in this package.

1) ns-default.tcl
    Please use this file to override the file
~ns-allinone-2.26/ns-2.26/tcl/lib/ns-default.tcl

2) ns_tcl.cc
    Please use this file to override the file ~ns-allinone-2.26/ns-2.26/gen/ns_tcl.cc

3) Makefile
    Please use this file to override the file ~ns-allinone-2.26/ns-2.26/Makefile

4) ns-process.h
    Please use this file to override the file
~ns-allinone-2.26/ns-2.26/common/ns-process.h

Or you can update the files by yourself. Here are the changes you need to make:

1) ns-default.tcl
    Please add the following lines to
~ns-allinone-2.26/ns-2.26/tcl/lib/ns-default.tcl
     Application/GridAgentServer set id_ 0
     Application/GridAgentCache set id_ 0
     Application/GridAgentClient set id_ 0

2) ns_tcl.cc
   Please add the following lines to ~ns-allinone-2.26/ns-2.26/gen/ns_tcl.cc
    Application/GridAgentServer set id_ 0
    Application/GridAgentCache set id_ 0
    Application/GridAgentClient set id_ 0

3) Makefile
    Please add the following lines to ~ns-allinone-2.26/ns-2.26/Makefile
     webcache/grid.o \
     webcache/grid_funcs.o \
     webcache/grid_cost_model.o \




Page 20 of 24
4) ns-process.h
    Please add GRID_PACKET to AppDataType in
~ns-allinone-2.26/ns-2.26/common/ns-process.h
     enum AppDataType {... GRID_PACKET, ADU_LAST}

Then copy all the files in folder "src" to ~ns-allinone-2.26/ns-2.26/webcache/. Then go
to the folder ~ns-allinone-2.26/ns-2.26/, run "make".

Congratulations! Please run the following command under folder "examples":

ns 3nodes.tcl

Then you will get beautiful feedback from ns2. Enjoy it!




Page 21 of 24
7. How to define a new protocol
Before you define a new protocol, please study the behavior of the new protocol and keep in your
mind the answers to the following questions:
         What’s the protocol data? (which will be carried by GridPacket)
         Is there anything new to record or just reuse the existing recorders?
         What’s the routing algorithm will be used? How many events and their handlers should be
         defined?

Here is an example of defining a simple Read protocol. The simple Read Protocol has nothing to
record. And the routing algorithm is very easy: The request is initialized from a command from a
Client node: read-request. At the Request stage, the packet is always forwarded to the first parent,
until it gets to the Server node. The Server will always send back a Response packet. Then the packet
will go back along the path that it is sent to the server. Whenever the Request/Response gets to a node,
it will print out a message about this event.

Here are the steps to define the simple Read Protocol (search “SRP_STEP” in the source code to see
the details):
1. (“SRP_STEP 1” in GridShare.h) to define the protocol ID and the stages of the protocol.
2. (“SRP_STEP 2” in GridRouter.h and implemented in GridRouter.cc) to define the Router.
3. (“SRP_STEP 3” in GridAgentClient.cc) to define the command “read-request”.
4. (“SRP_STEP 4” in GridAgentClient.cc, GridAgentCache.cc and GridAgentServer.cc) to catch
     the packet and forward it to the router.
5. Refer to the example “3nodes.tcl” to launch the protocol.




Page 22 of 24
8. An example of the script file
Here is a commented example showing to how to use the extended commands. In this example, we
have only 3 nodes: Client, Cache and Server.

# 3nodes.tcl
#
# n1(server) --> n2(cache) --> n3(client)
#


set ns [new Simulator]

#1) define all the ns-2 nodes;
for {set q 1} {$q < 4} {incr q}              {
   set n$q [$ns node]
}

#2) link all the ns-2 nodes;
$ns duplex-link $n1 $n2 100Mb 5ms DropTail
$ns duplex-link $n2 $n3 100Mb 5ms DropTail

#3)   define TCP agents;
set   tcp_1_2 [new Agent/TCP/FullTcp]
set   tcp_2_1 [new Agent/TCP/FullTcp]
set   tcp_2_3 [new Agent/TCP/FullTcp]
set   tcp_3_2 [new Agent/TCP/FullTcp]

#4)   attach the TCP agents to ns-2 nodes;
$ns   attach-agent $n1 $tcp_1_2
$ns   attach-agent $n2 $tcp_2_1
$ns   attach-agent $n2 $tcp_2_3
$ns   attach-agent $n3 $tcp_3_2

#5) connect the TCP agents
$ns connect $tcp_1_2 $tcp_2_1
$ns connect $tcp_2_3 $tcp_3_2

#6) all the TCP agents are listening
$tcp_1_2 listen
$tcp_2_1 listen
$tcp_2_3 listen
$tcp_3_2 listen

#7)   define all the TCPAPP objects;
set   tcpapp_1_2 [new Application/TcpApp             $tcp_1_2    ]
set   tcpapp_2_1 [new Application/TcpApp             $tcp_2_1    ]
set   tcpapp_2_3 [new Application/TcpApp             $tcp_2_3    ]
set   tcpapp_3_2 [new Application/TcpApp             $tcp_3_2    ]




Page 23 of 24
#8) connect the TCPAPP objects;
$tcpapp_1_2 connect $tcpapp_2_1
$tcpapp_2_3 connect $tcpapp_3_2

#9)   define grid nodes
set   server1 [new Application/GridAgentServer 0 1024000]
set   cache2 [new Application/GridAgentCache 1 102400 ]
set   client3 [new Application/GridAgentClient 2 10240 ]

#10) settings of gridnet
$server1 open-log 3nodes.out
$server1 set-write-lazy-on
$server1 turn-monitor-off

$ns at 1 "$client3 read-request 1"

set   startTime 0.1    ;# simulation start time
set   finishTime 10   ;# simulation end time
$ns   at $startTime "start-connection"
$ns   at $finishTime "finish"

proc start-connection {} {
   global ns server1 cache2 client3
   global tcpapp_1_2 tcpapp_2_1 tcpapp_2_3 tcpapp_3_2

      $server1 connect $cache2    $tcpapp_1_2
      $cache2  connect $server1   $tcpapp_2_1
      $cache2  connect $client3    $tcpapp_2_3
      $client3  connect $cache2    $tcpapp_3_2

      $server1 add-child 1
      $cache2 add-child 2

      $server1 add-file 1 1024
}

proc finish {} {
       exit 0
}

$ns run




Page 24 of 24

				
DOCUMENT INFO
Shared By:
Stats:
views:154
posted:4/24/2012
language:English
pages:24
Description: Grid Computing simulator(GridSim) v1 manual