public static void main(String[] args) {
		try{
	    	Calendar calendar = Calendar.getInstance();
	    	boolean trace_flag = true;  // mean trace GridSim events
	    	int num_user = 3;
	    	int num_resource = 2;
	    	int num_gridlet = 3;

	        // First step: Initialize the GridSim package. It should be called
	        // before creating any entities. We can't run GridResource
	        // entity without initializing GridSim first. We will get run-time
	        // exception error.

	        // Initialize the GridSim package
	        System.out.println("Initializing GridSim package");
	        GridSim.init(num_user, calendar, trace_flag);

            double baud_rate = 1000; // bits/sec
            double propDelay = 10;   // propagation delay in millisecond
            int mtu = 1500;          // max. transmission unit in byte

            long seed = 11L*13*17*19*23+1;

            Sim_uniform_obj genCost = new Sim_uniform_obj("cost",1,2, seed);
            Sim_uniform_obj genMIPS = new Sim_uniform_obj("mips",300,400, seed);


        	Broker broker = new Broker("Broker", baud_rate, propDelay, mtu, num_user);
        	
            // more resources can be created by
            // setting num_resource to an appropriate value
            ArrayList resList = new ArrayList(num_resource);
            for (int i = 0; i < num_resource; i++) {
                GridResource res = createGridResource("Resource_"+i, baud_rate,
                                                      propDelay, mtu, genCost.sample(),
                                                      ((int)genMIPS.sample()), broker.get_id());
                // add a resource into a list
                resList.add(res);
            }
            
            // create users
            ArrayList userList = new ArrayList(num_user);
            for (int i = 0; i < num_user; i++)
            {
                NetUser user = new NetUser("User_" + i, num_gridlet,
                		baud_rate, propDelay, mtu, broker);

                // add a user into a list
                userList.add(user);
            }
            
            //////////////////////////////////////////
            // Fourth step: Builds the network topology among entities.

            // In this example, the topology is:
            // user(s) --1Mb/s-- r1 --10Mb/s-- r2 --1Mb/s-- GridResource(s)

            // create the routers.
            // If trace_flag is set to "true", then this experiment will create
            // the following files (apart from sim_trace and sim_report):
            // - router1_report.csv
            // - router2_report.csv
            Router r1 = new RIPRouter("router1", trace_flag);   // router 1
            Router r2 = new RIPRouter("router2", trace_flag);   // router 2

            FIFOScheduler brokerSched = new FIFOScheduler("NetBrokerSched");
            r1.attachHost(broker, brokerSched);
            
            // connect all user entities with r1 with 1Mb/s connection
            // For each host, specify which PacketScheduler entity to use.
            NetUser user = null;
            for (int i = 0; i < userList.size(); i++)
            {
                // A First In First Out Scheduler is being used here.
                // SCFQScheduler can be used for more fairness
                FIFOScheduler userSched = new FIFOScheduler("NetUserSched_"+i);
                user = (NetUser) userList.get(i);
                r1.attachHost(user, userSched);
            }

            // connect all resource entities with r2 with 1Mb/s connection

            // For each host, specify which PacketScheduler entity to use.
            GridResource resObj = null;
            for (int i = 0; i < resList.size(); i++)
            {
                FIFOScheduler resSched = new FIFOScheduler("GridResSched_"+i);
                resObj = (GridResource) resList.get(i);
                r2.attachHost(resObj, resSched);
            }

            // then connect r1 to r2 with 10Mb/s connection
            // For each host, specify which PacketScheduler entity to use.
            baud_rate = 10000;
            Link link = new SimpleLink("r1_r2_link", baud_rate, propDelay, mtu);
            FIFOScheduler r1Sched = new FIFOScheduler("r1_Sched");
            FIFOScheduler r2Sched = new FIFOScheduler("r2_Sched");

            // attach r2 to r1
            r1.attachRouter(r2, link, r1Sched, r2Sched);

            //////////////////////////////////////////
            // Starts the simulation
            GridSim.startGridSimulation();

            //////////////////////////////////////////
            // Final step: Prints the Gridlets when simulation is over

//            // also prints the routing table
//            r1.printRoutingTable();
//            r2.printRoutingTable();
		}
		catch(Exception ex){
			System.out.println(" Error executing simulation. Message: " + ex.getMessage());
			ex.printStackTrace();
		}
	}