public boolean replicateFile(File master, int resID)
    {
        // check for errors first
        if (master == null || resID == -1) {
            return false;
        }

        File file = master.makeReplica();   // makes a replica of this file
        int fileSize = file.getSizeInByte();    // size of the replica file
        Object[] packet = new Object[2];
        packet[0] = file;
        packet[1] = myID_;

        int tag = DataGridTags.FILE_ADD_REPLICA;
        super.send(super.output, 0, tag, new IO_data(packet, fileSize, resID));

        // wait for ACK
        tag = DataGridTags.FILE_ADD_REPLICA_RESULT;
        FilterDataResult type = new FilterDataResult(file.getName(), tag);
        Sim_event ev = new Sim_event();
        super.sim_get_next(type, ev);

        boolean result = false;
        try
        {
            packet = (Object[]) ev.get_data();
            String resName = GridSim.getEntityName(resID);
            String filename = file.getName();

            int msg = ((Integer) packet[1]).intValue();
            if (msg == DataGridTags.FILE_ADD_SUCCESSFUL)
            {
                result = true;
                System.out.println(super.get_name() + ".replicateFile(): " +
                        filename + " has been replicated to " + resName);
            }
            else {
                System.out.println(super.get_name() + ".replicateFile(): " +
                        "There was an error in replicating " + filename +
                        " to " + resName);
            }
        }
        catch (Exception e) {
            System.out.println(super.get_name()+".replicateFile(): Exception");
            result = false;
        }

        return result;
    }