Index: src/peer/Peer.java
===================================================================
--- src/peer/Peer.java	(nonexistent)
+++ src/peer/Peer.java	(revision 1)
@@ -0,0 +1,198 @@
+package peer;
+
+import channels.McChannel;
+import channels.MdbChannel;
+import protocols.BackupProtocol;
+import protocols.RestoreProtocol;
+import utils.Utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.*;
+import java.security.NoSuchAlgorithmException;
+
+import utils.*;
+
+public class Peer {
+
+    private static int senderId; //id of the server that has sent the message
+
+    private static InetAddress mcChannel;
+    private static InetAddress mdbChannel;
+    private static InetAddress mdrChannel;
+
+    private static int mcPort;
+    private static int mdbPort;
+    private static int mdrPort;
+
+
+
+    //BACKUP, DELETE, RECLAIM, RESTORE;
+
+
+    public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InterruptedException {
+        if(!parseArgs(args)) return;
+
+        joinMulticastGroup();
+        startThreads();
+        getRequests();
+
+    }
+
+    private static void getRequests() throws IOException, NoSuchAlgorithmException, InterruptedException {
+        DatagramSocket request = new DatagramSocket();
+        int portNumber = request.getLocalPort();
+        System.out.println("Socket Peer opened in port number: " + portNumber);
+
+        while(true){
+            byte[] buffer = new byte[Utils.BUFFER_SIZE];
+            DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
+
+            request.receive(packet);
+
+            InetAddress clientAddress = packet.getAddress();
+            String requestString = new String(packet.getData(), 0, packet.getLength());
+
+            System.out.println();
+            System.out.println("---------------------------------------------------------------------------");
+            System.out.println("Request from TestApp: " + requestString);
+            System.out.println();
+
+            String[] requestArgs = requestString.split("\\s+");
+
+            switch(requestArgs[0]){
+                    case "BACKUP":
+                        new BackupProtocol(requestArgs);
+                        break;
+                    case "RESTORE":
+                        new RestoreProtocol(requestArgs);
+                        break;
+                    default:
+                        break;
+            }
+
+            int port = packet.getPort();
+            String answer = "Got your request";
+            buffer = answer.getBytes();
+            packet = new DatagramPacket(buffer, 0, buffer.length, clientAddress, port);
+
+            request.send(packet);
+        }
+    }
+
+    public static void startThreads(){ //only subscribed mc channel
+        Utils.mcChannel = new McChannel();
+        new Thread(Utils.mcChannel).start();
+
+        Utils.mdbChannel = new MdbChannel();
+        new Thread(Utils.mdbChannel).start();
+
+        Utils.mdrChannel = new channels.MdrChannel();
+        new Thread(Utils.mdrChannel).start();
+    }
+
+    public static void joinMulticastGroup() throws IOException{
+        //mc channel
+        Utils.mcSocket = new MulticastSocket(getMcPort());
+        Utils.mcSocket.joinGroup(getMcAddress());
+        //mdb channel
+        Utils.mdbSocket = new MulticastSocket(getMdbPort());
+        Utils.mdbSocket.joinGroup(getMdbAddress());
+        //mdr channel
+        Utils.mdrSocket = new MulticastSocket(getMdrPort());
+        Utils.mdrSocket.joinGroup(getMdrAddress());
+    }
+
+    public static boolean parseArgs(String[] args) throws UnknownHostException{
+        if(args == null || args.length != 4){
+            System.out.println("Usage: java peer.peer <SenderId> <McAddress>:<McPortNumber> <MdbAddress>:<MdbPortNumber> <MdrAddress>:<MdrPortNumber>");
+            return false;
+        }
+
+        //sets sender id
+        setSenderId(Integer.parseInt(args[0]));
+
+        //sets address and port for channel MC
+        String[] mcPart = args[1].split(":");
+        setMcAddress(InetAddress.getByName(mcPart[0]));
+        setMcPort(Integer.parseInt(mcPart[1]));
+
+        //sets address and port for channel MDB
+        String[] mdbPart = args[2].split(":");
+        setMdbAddress(InetAddress.getByName(mdbPart[0]));
+        setMdbPort(Integer.parseInt(mdbPart[1]));
+
+        //sets address and port for channel MDR
+        String[] mdrPart = args[3].split(":");
+        setMdrAddress(InetAddress.getByName(mdrPart[0]));
+        setMdrPort(Integer.parseInt(mdrPart[1]));
+
+        return true;
+    }
+
+    //getters and setters
+
+    public static InetAddress getMcAddress(){
+        return mcChannel;
+    }
+
+    public static InetAddress getMdbAddress(){
+        return mdbChannel;
+    }
+
+    public static InetAddress getMdrAddress(){
+        return mdrChannel;
+    }
+
+    public static int getMcPort(){
+        return mcPort;
+    }
+
+    public static int getMdbPort(){
+        return mdbPort;
+    }
+
+    public static int getMdrPort(){
+        return mdrPort;
+    }
+
+    public static void setMcAddress(InetAddress mcAddress){
+        mcChannel = mcAddress;
+    }
+
+    public static void setMdbAddress(InetAddress mdbAddress){
+        mdbChannel = mdbAddress;
+    }
+
+    public static void setMdrAddress(InetAddress mdrAddress){
+        mdrChannel = mdrAddress;
+    }
+
+    public static void setMcPort(int port){
+        mcPort = port;
+    }
+
+    public static void setMdbPort(int port){
+        mdbPort = port;
+    }
+
+    public static void setMdrPort(int port){
+        mdrPort = port;
+    }
+
+    public static void setSenderId(int id){
+        senderId = id;
+    }
+
+    public static int getSenderId(){
+        return senderId;
+    }
+
+
+
+
+
+
+
+}
+
Index: src/.idea/encodings.xml
===================================================================
--- src/.idea/encodings.xml	(nonexistent)
+++ src/.idea/encodings.xml	(revision 1)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>
\ No newline at end of file
Index: src/out/production/SIDS/storage/Restored/Peer1/htp.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Restored/Peer1/htp.jpg
===================================================================
--- src/out/production/SIDS/storage/Restored/Peer1/htp.jpg	(nonexistent)
+++ src/out/production/SIDS/storage/Restored/Peer1/htp.jpg	(revision 1)

Property changes on: src/out/production/SIDS/storage/Restored/Peer1/htp.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/TestApp.java
===================================================================
--- src/TestApp.java	(nonexistent)
+++ src/TestApp.java	(revision 1)
@@ -0,0 +1,193 @@
+import java.io.IOException;
+import java.net.*;
+import java.util.Scanner;
+
+import static utils.Utils.BUFFER_SIZE;
+
+//TODO: parse args for reclaim and delete not fully functional
+//grupo 11
+
+public class TestApp {
+
+    private static String hostname = "localhost";
+    private static int portNumber;
+    private static String protocolRequest;
+    private static String filePath;
+    private static int replicationDegree;
+
+
+    public static void main(String[] args) throws SocketException, UnknownHostException {
+        mainMenu();
+        }
+
+    private static void mainMenu() throws SocketException, UnknownHostException {
+
+        System.out.println("1- Backup a file");
+        System.out.println("2- Restore a file");
+        System.out.println("0- Exit");
+
+
+        Scanner in = new Scanner(System.in);
+        int option = in.nextInt();
+
+        switch(option){
+            case 0:
+                System.out.println("exiting application...");
+                break;
+            case 1:
+                backupMenu();
+                break;
+            case 2:
+                restoreMenu();
+                break;
+
+        }
+    }
+
+    private static void restoreMenu() throws SocketException, UnknownHostException {
+        String[] args = new String[4];
+
+        System.out.println("Please insert the peer port number which you want to send the request");
+
+        Scanner in = new Scanner(System.in);
+        String portnumber = in.nextLine();
+
+        args[0] = portnumber;
+
+        args[1] = "RESTORE";
+
+        System.out.println("Specify the file name you want to restore ");
+
+        String filename = in.nextLine();
+
+        args[2] = filename;
+
+        if(!parseArgs(args)) return;
+
+        sendRequest(args);
+
+
+    }
+
+    private static void backupMenu() throws SocketException, UnknownHostException {
+        String[] args = new String[4];
+
+        System.out.println("Please insert the peer port number which you want to send the request");
+
+        Scanner in = new Scanner(System.in);
+        String portnumber = in.nextLine();
+
+        args[0] = portnumber;
+
+        args[1] = "BACKUP";
+
+        System.out.println("Specify the file name you want to backup (must be inside test folder) ");
+
+        String filename = in.nextLine();
+
+        args[2] = filename;
+
+        System.out.println("Now enter the replication degree");
+        String replicD = in.nextLine();
+
+        args[3] = replicD;
+
+        if(!parseArgs(args)) return;
+
+        sendRequest(args);
+        
+    }
+
+    private static void sendRequest(String[] args) throws SocketException, UnknownHostException {
+        DatagramSocket socket = new DatagramSocket();
+        byte[] buffer;
+        String message = "";
+
+        for(int i = 1; i < args.length; i++){
+            if(i == args.length -1){
+                message += args[i];
+                break;
+            }
+            message += args[i] + " ";
+        }
+
+        buffer = message.getBytes();
+
+        InetAddress address = InetAddress.getByName(hostname);
+        DatagramPacket packet = new DatagramPacket(buffer, buffer.length, address, portNumber);
+
+        try {
+            socket.send(packet);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        buffer = new byte[BUFFER_SIZE];
+        packet = new DatagramPacket(buffer, buffer.length);
+
+        //
+        try {
+            socket.receive(packet);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        String answer = new String(packet.getData(), 0, packet.getLength());
+        System.out.println("Peer said: " + answer);
+        socket.close();
+
+        //after request sent and done, come back to main menu
+        mainMenu();
+    }
+
+    private static boolean parseArgs(String[] args) {
+        if(args == null || args.length < 3) {
+            System.out.println("Usage: java TestApp <peer_ap> <sub_protocol> <opnd_1> <opnd_2>");
+            return false;
+        }
+        String[] peer_ap = args[0].split(":");
+
+        if(peer_ap.length == 1) { //user just gave the port number
+            portNumber = Integer.parseInt(peer_ap[0]);
+        }
+        else if(peer_ap.length == 2) {
+            hostname = peer_ap[0];
+            portNumber = Integer.parseInt(peer_ap[1]);
+        }
+        else {
+            System.out.println("Usage: java TestApp <peer_ap> <sub_protocol> <opnd_1> <opnd_2>");
+            return false;
+        }
+
+        switch(args[1]) {
+            case "BACKUP":
+                protocolRequest = "BACKUP";
+                filePath = args[2];
+                if(args[3] == null){
+                    System.out.println("In backup protocol, you have to specify also the replication degree");
+                    return false;
+                }
+                replicationDegree = Integer.parseInt(args[3]);
+                break;
+            case "RESTORE":
+                protocolRequest = "RESTORE";
+                filePath = args[2];
+                break;
+            case "DELETE":
+                protocolRequest = "DELETE";
+                filePath = args[2];
+                break;
+            case "RECLAIM":
+                protocolRequest = "RECLAIM";
+                break;
+                default: return false;
+        }
+
+
+
+
+        return true;
+    }
+
+}
+
Index: peer4.sh
===================================================================
--- peer4.sh	(nonexistent)
+++ peer4.sh	(revision 1)
@@ -0,0 +1,5 @@
+cd src
+javac *.java
+java peer.Peer 4 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002
+
+

Property changes on: peer4.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/out/production/SIDS/test/htp.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/test/htp.jpg
===================================================================
--- src/out/production/SIDS/test/htp.jpg	(nonexistent)
+++ src/out/production/SIDS/test/htp.jpg	(revision 1)

Property changes on: src/out/production/SIDS/test/htp.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/utils/Chunk.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/utils/Chunk.class
===================================================================
--- src/out/production/SIDS/utils/Chunk.class	(nonexistent)
+++ src/out/production/SIDS/utils/Chunk.class	(revision 1)

Property changes on: src/out/production/SIDS/utils/Chunk.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/.idea/misc.xml
===================================================================
--- src/.idea/misc.xml	(nonexistent)
+++ src/.idea/misc.xml	(revision 1)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_10" project-jdk-name="10" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>
\ No newline at end of file
Index: src/.idea/modules.xml
===================================================================
--- src/.idea/modules.xml	(nonexistent)
+++ src/.idea/modules.xml	(revision 1)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/SIDS.iml" filepath="$PROJECT_DIR$/SIDS.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
Index: src/out/production/SIDS/utils/Utils.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/utils/Utils.class
===================================================================
--- src/out/production/SIDS/utils/Utils.class	(nonexistent)
+++ src/out/production/SIDS/utils/Utils.class	(revision 1)

Property changes on: src/out/production/SIDS/utils/Utils.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/.idea/vcs.xml
===================================================================
--- src/.idea/vcs.xml	(nonexistent)
+++ src/.idea/vcs.xml	(revision 1)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
Index: src/out/production/SIDS/TestApp.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/TestApp.class
===================================================================
--- src/out/production/SIDS/TestApp.class	(nonexistent)
+++ src/out/production/SIDS/TestApp.class	(revision 1)

Property changes on: src/out/production/SIDS/TestApp.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/.idea/workspace.xml
===================================================================
--- src/.idea/workspace.xml	(nonexistent)
+++ src/.idea/workspace.xml	(revision 1)
@@ -0,0 +1,407 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ChangeListManager">
+    <list default="true" id="d51d95c7-4d11-4ecd-934b-ad1c8b084f2c" name="Default Changelist" comment="">
+      <change beforePath="$PROJECT_DIR$/peer/Peer.java" beforeDir="false" afterPath="$PROJECT_DIR$/peer/Peer.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/protocols/RestoreProtocol.java" beforeDir="false" afterPath="$PROJECT_DIR$/protocols/RestoreProtocol.java" afterDir="false" />
+    </list>
+    <ignored path="$PROJECT_DIR$/out/" />
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="FileEditorManager">
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
+      <file pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/protocols/RestoreProtocol.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="195">
+              <caret line="37" column="100" selection-start-line="37" selection-start-column="100" selection-end-line="37" selection-end-column="100" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/channels/McChannel.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="541">
+              <caret line="61" column="27" selection-start-line="61" selection-start-column="27" selection-end-line="61" selection-end-column="27" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/channels/MdrChannel.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="511">
+              <caret line="73" column="13" selection-start-line="73" selection-start-column="13" selection-end-line="73" selection-end-column="13" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/utils/Chunk.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="376">
+              <caret line="30" column="42" selection-start-line="30" selection-start-column="42" selection-end-line="30" selection-end-column="42" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/utils/FileController.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="-89">
+              <caret line="38" column="70" selection-start-line="38" selection-start-column="70" selection-end-line="38" selection-end-column="70" />
+              <folding>
+                <element signature="method#saveToDisk#0;class#FileController#0" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/peer/Peer.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="-645">
+              <caret line="37" column="12" selection-start-line="37" selection-start-column="12" selection-end-line="37" selection-end-column="12" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/utils/Utils.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="300">
+              <caret line="26" column="52" selection-start-line="26" selection-start-column="52" selection-end-line="26" selection-end-column="52" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/TestApp.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="90">
+              <caret line="10" selection-start-line="10" selection-end-line="10" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/protocols/BackupProtocol.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="180">
+              <caret line="12" column="13" selection-start-line="12" selection-start-column="13" selection-end-line="12" selection-end-column="13" />
+              <folding>
+                <element signature="imports" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/channels/MdbChannel.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="405">
+              <caret line="35" column="62" selection-start-line="35" selection-start-column="62" selection-end-line="35" selection-end-column="62" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+    </leaf>
+  </component>
+  <component name="FindInProjectRecents">
+    <findStrings>
+      <find>store</find>
+      <find>stored</find>
+      <find>hashData</find>
+      <find>Utils</find>
+    </findStrings>
+  </component>
+  <component name="Git.Settings">
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
+  </component>
+  <component name="IdeDocumentHistory">
+    <option name="CHANGED_PATHS">
+      <list>
+        <option value="$PROJECT_DIR$/protocols/BackupProtocol.java" />
+        <option value="$PROJECT_DIR$/utils/Chunk.java" />
+        <option value="$PROJECT_DIR$/utils/FileController.java" />
+        <option value="$PROJECT_DIR$/channels/MdbChannel.java" />
+        <option value="$PROJECT_DIR$/channels/MdrChannel.java" />
+        <option value="$PROJECT_DIR$/utils/Utils.java" />
+        <option value="$PROJECT_DIR$/channels/McChannel.java" />
+        <option value="$PROJECT_DIR$/peer/Peer.java" />
+        <option value="$PROJECT_DIR$/protocols/RestoreProtocol.java" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectFrameBounds" extendedState="6">
+    <option name="x" value="1849" />
+    <option name="width" value="1356" />
+    <option name="height" value="528" />
+  </component>
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+  <component name="ProjectView">
+    <navigator proportions="" version="1">
+      <foldersAlwaysOnTop value="true" />
+    </navigator>
+    <panes>
+      <pane id="Scope" />
+      <pane id="PackagesPane" />
+      <pane id="ProjectPane">
+        <subPane>
+          <expand>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="channels" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="peer" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="protocols" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="utils" type="462c0819:PsiDirectoryNode" />
+            </path>
+          </expand>
+          <select />
+        </subPane>
+      </pane>
+    </panes>
+  </component>
+  <component name="PropertiesComponent">
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1555276281623" />
+  </component>
+  <component name="RunDashboard">
+    <option name="ruleStates">
+      <list>
+        <RuleState>
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
+        </RuleState>
+        <RuleState>
+          <option name="name" value="StatusDashboardGroupingRule" />
+        </RuleState>
+      </list>
+    </option>
+  </component>
+  <component name="RunManager" selected="Application.TestApp">
+    <configuration name="Peer1" type="Application" factoryName="Application" temporary="true">
+      <option name="MAIN_CLASS_NAME" value="peer.Peer" />
+      <module name="SIDS" />
+      <option name="PROGRAM_PARAMETERS" value="1 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="peer.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="Peer2" type="Application" factoryName="Application">
+      <option name="MAIN_CLASS_NAME" value="peer.Peer" />
+      <module name="SIDS" />
+      <option name="PROGRAM_PARAMETERS" value="2 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="peer.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="Peer3" type="Application" factoryName="Application">
+      <option name="MAIN_CLASS_NAME" value="peer.Peer" />
+      <module name="SIDS" />
+      <option name="PROGRAM_PARAMETERS" value="3 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="peer.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="TestApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
+      <option name="MAIN_CLASS_NAME" value="TestApp" />
+      <module name="SIDS" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <list>
+      <item itemvalue="Application.Peer2" />
+      <item itemvalue="Application.Peer3" />
+      <item itemvalue="Application.Peer1" />
+      <item itemvalue="Application.TestApp" />
+    </list>
+    <recent_temporary>
+      <list>
+        <item itemvalue="Application.TestApp" />
+        <item itemvalue="Application.Peer1" />
+      </list>
+    </recent_temporary>
+  </component>
+  <component name="SvnConfiguration">
+    <configuration />
+  </component>
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <changelist id="d51d95c7-4d11-4ecd-934b-ad1c8b084f2c" name="Default Changelist" comment="" />
+      <created>1555096072834</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1555096072834</updated>
+    </task>
+    <servers />
+  </component>
+  <component name="ToolWindowManager">
+    <frame x="1366" y="-2" width="1920" height="1082" extended-state="6" />
+    <editor active="true" />
+    <layout>
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.1814301" />
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
+      <window_info id="Image Layers" order="2" />
+      <window_info id="Designer" order="3" />
+      <window_info id="UI Designer" order="4" />
+      <window_info id="Capture Tool" order="5" />
+      <window_info id="Favorites" order="6" side_tool="true" />
+      <window_info anchor="bottom" id="Message" order="0" />
+      <window_info anchor="bottom" id="Find" order="1" />
+      <window_info active="true" anchor="bottom" x="74" y="129" width="1204" height="551" id="Run" order="2" type="WINDOWED" visible="true" weight="0.45960125" />
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
+      <window_info anchor="bottom" id="TODO" order="6" />
+      <window_info anchor="bottom" id="Terminal" order="7" />
+      <window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
+      <window_info anchor="bottom" id="Version Control" order="9" />
+      <window_info anchor="bottom" id="Messages" order="10" weight="0.32948583" />
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
+      <window_info anchor="right" id="Palette" order="3" />
+      <window_info anchor="right" id="Maven" order="4" />
+      <window_info anchor="right" id="Theme Preview" order="5" />
+      <window_info anchor="right" id="Capture Analysis" order="6" />
+      <window_info anchor="right" id="Palette&#9;" order="7" />
+    </layout>
+  </component>
+  <component name="editorHistoryManager">
+    <entry file="file://$PROJECT_DIR$/TestApp.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="90">
+          <caret line="10" selection-start-line="10" selection-end-line="10" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/channels/MdbChannel.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="405">
+          <caret line="35" column="62" selection-start-line="35" selection-start-column="62" selection-end-line="35" selection-end-column="62" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/FileController.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-89">
+          <caret line="38" column="70" selection-start-line="38" selection-start-column="70" selection-end-line="38" selection-end-column="70" />
+          <folding>
+            <element signature="method#saveToDisk#0;class#FileController#0" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/Chunk.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="376">
+          <caret line="30" column="42" selection-start-line="30" selection-start-column="42" selection-end-line="30" selection-end-column="42" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/Utils.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="300">
+          <caret line="26" column="52" selection-start-line="26" selection-start-column="52" selection-end-line="26" selection-end-column="52" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="jrt:///usr/lib/jvm/java-1.11.0-openjdk-amd64!/java.base/java/io/File.class">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/protocols/BackupProtocol.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="180">
+          <caret line="12" column="13" selection-start-line="12" selection-start-column="13" selection-end-line="12" selection-end-column="13" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/peer/Peer.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-645">
+          <caret line="37" column="12" selection-start-line="37" selection-start-column="12" selection-end-line="37" selection-end-column="12" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/channels/MdrChannel.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="511">
+          <caret line="73" column="13" selection-start-line="73" selection-start-column="13" selection-end-line="73" selection-end-column="13" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/channels/McChannel.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="541">
+          <caret line="61" column="27" selection-start-line="61" selection-start-column="27" selection-end-line="61" selection-end-column="27" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/protocols/RestoreProtocol.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="195">
+          <caret line="37" column="100" selection-start-line="37" selection-start-column="100" selection-end-line="37" selection-end-column="100" />
+        </state>
+      </provider>
+    </entry>
+  </component>
+  <component name="masterDetails">
+    <states>
+      <state key="ProjectJDKs.UI">
+        <settings>
+          <last-edited>10</last-edited>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+    </states>
+  </component>
+</project>
\ No newline at end of file
Index: src/protocols/RestoreProtocol.java
===================================================================
--- src/protocols/RestoreProtocol.java	(nonexistent)
+++ src/protocols/RestoreProtocol.java	(revision 1)
@@ -0,0 +1,89 @@
+package protocols;
+
+
+import peer.Peer;
+import utils.FileController;
+import utils.Utils;
+
+import java.io.*;
+import java.net.DatagramPacket;
+import java.util.ArrayList;
+
+public class RestoreProtocol {
+    String hashId;
+    String name;
+    int numberOfChunks;
+
+    public RestoreProtocol(String[] args) throws IOException, InterruptedException {
+        this.name = args[1];
+        this.numberOfChunks = 0;
+
+        //check in hash database
+        this.hashId = Utils.hashDatabase.get(this.name);
+
+        if(this.hashId == null) {
+            System.out.println("no such file exists to restore, exiting ...");
+            return;
+        }
+
+        getNumberOfChunks();
+
+        System.out.println("RESTORE Protocol  ||  Restoring: " + this.name + "  ||  IdHashed: " + this.hashId);
+
+        Utils.restorePeer = Peer.getSenderId();
+
+        //send get chunck message to MC channel
+        sendGetChunk(0);
+
+        Thread.sleep(10000); //waits a bit for chunks to be stored in the folder before merging them
+        System.out.println("All chunks stored, merging into one single file");
+        mergeChunks();
+    }
+
+    private void getNumberOfChunks() {
+        for (String name: Utils.storedChunks.keySet()){
+            String [] key = name.split(":");
+            if(this.hashId.equals(key[0])) this.numberOfChunks++;
+        }
+    }
+
+    private void sendGetChunk(int chunkNo) throws IOException {
+
+        if(chunkNo > this.numberOfChunks -1) return;
+
+        System.out.println("Sending getchunk message to mc...");
+        String msg = "GETCHUNK" + " " + Utils.version + " " + Peer.getSenderId() + " " + this.hashId + " " + chunkNo + Utils.crlf;
+
+        DatagramPacket packet = new DatagramPacket(msg.getBytes(), msg.getBytes().length, Peer.getMcAddress(),Peer.getMcPort());
+
+        Utils.mcSocket.send(packet);
+        chunkNo += 1;
+        sendGetChunk(chunkNo);
+    }
+
+    private void mergeChunks() throws IOException {
+        File outputFile = new File("storage/Restored/Peer" + Peer.getSenderId() + "/" + this.name);
+        outputFile.getParentFile().mkdirs();
+        outputFile.createNewFile();
+
+        FileOutputStream outStream = new FileOutputStream(outputFile);
+
+        for(int i = 0; i < this.numberOfChunks; i++) {
+            File inputFile = new File("storage/Restored/Peer" + Peer.getSenderId() + "/" + i);
+                FileInputStream inStream = new FileInputStream(inputFile);
+                byte[] buf = new byte[64000];
+                int readBytes = inStream.read(buf);
+                outStream.write(buf, 0, readBytes);
+
+                inStream.close();
+
+        }
+
+        for(int i = 0; i < this.numberOfChunks; i++) { //delete chunks (we dont need them anymore)
+            File inputFile = new File("storage/Restored/Peer" + Peer.getSenderId() + "/" + i);
+            inputFile.delete();
+        }
+
+        outStream.close();
+    }
+}
Index: src/channels/McChannel.java
===================================================================
--- src/channels/McChannel.java	(nonexistent)
+++ src/channels/McChannel.java	(revision 1)
@@ -0,0 +1,80 @@
+package channels;
+
+
+import peer.Peer;
+import utils.Chunk;
+import utils.Utils;
+import static utils.Utils.BUFFER_SIZE;
+import static utils.Utils.chunkReceived;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.util.Arrays;
+import java.util.Random;
+
+public class McChannel implements Runnable{
+
+
+    public void run() {
+        while (true) {
+            byte[] buf = new byte[BUFFER_SIZE];
+
+            DatagramPacket receiveDatagram = new DatagramPacket(buf, buf.length);
+
+            try {
+                Utils.mcSocket.receive(receiveDatagram);
+                String receivedMessage = new String(buf, 0, buf.length).trim();
+                String[] receivedArgs = receivedMessage.split("\\s+");
+
+                switch (receivedArgs[0]) {
+                    case "GETCHUNK":
+                        if (!receivedArgs[2].equals((Integer.toString(Peer.getSenderId())))) { //if not init peer send chunk message to other peers
+                            Utils.chunkReceived = false;
+                            sendChunk(receivedArgs);
+                        }
+                        break;
+                    case "STORED":
+                        //System.out.println("STORED <Version> <SenderId> <FileId> <ChunkNo> <CRLF><CRLF>");
+                        break;
+                }
+
+            } catch (IOException e) {
+                System.out.println(e.getMessage());
+
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private void sendChunk(String[] receivedArgs) throws IOException, InterruptedException {
+        String chunkyNo = receivedArgs[4];
+        String cleanChunkNo = chunkyNo.substring(0, chunkyNo.length() - 4);
+
+        File toCheck = new File("storage/Backup/Peer" + Peer.getSenderId() + "/" + receivedArgs[3] + "/" + cleanChunkNo);
+        if(toCheck.exists() && !toCheck.isDirectory()){ //go get the chunk in memory
+            FileInputStream stream = new FileInputStream(toCheck);
+            byte[] buffer = new byte[64000];
+            int sizeRead = stream.read(buffer,0,64000);
+            stream.close();
+            byte[] realBuffer = Arrays.copyOf(buffer,sizeRead);
+
+            Chunk toSend = new Chunk(realBuffer,"CHUNK",receivedArgs[3], cleanChunkNo);
+            sendTheChunkMdr(toSend);
+        }
+    }
+    private void sendTheChunkMdr(Chunk toSend) throws InterruptedException, IOException {
+        int delay = new Random().nextInt(400); // waits before sending chunk message
+        Thread.sleep(delay);
+        if(!Utils.chunkReceived){
+            System.out.println("McChannel: " + toSend.getHeaderMsg());
+            MdrChannel.sendMessage(toSend.getBuffer());
+        }
+    }
+
+
+
+}
\ No newline at end of file
Index: src/channels/MdbChannel.java
===================================================================
--- src/channels/MdbChannel.java	(nonexistent)
+++ src/channels/MdbChannel.java	(revision 1)
@@ -0,0 +1,91 @@
+package channels;
+
+import peer.Peer;
+import utils.FileController;
+import utils.Utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.util.ArrayList;
+import java.util.Random;
+
+public class MdbChannel implements Runnable{
+    public void run() {
+        while(true){
+            byte[] buf = new byte[65000]; //header + body
+
+            DatagramPacket receivedPacket = new DatagramPacket(buf,buf.length);
+
+            try {
+                //received chunck
+                Utils.mdbSocket.receive(receivedPacket);
+                String received = new String(receivedPacket.getData(),0,receivedPacket.getLength());
+                String[] receivedArray = received.split("\\r\\n\\r\\n"); //separate header from body
+                int offsetOfBody = receivedArray[0].length() + 4;
+
+                String receivedChunkData = received.substring(offsetOfBody, received.length());
+
+                int size = received.length() - offsetOfBody;
+                byte[] toRet = new byte[size];
+
+                for(int i = offsetOfBody; i < received.length(); i++) {
+                    toRet[i - offsetOfBody] = receivedPacket.getData()[i];
+                }
+
+                FileController receivedFile = new FileController(receivedArray, toRet);
+
+
+                //addToChunkDatabase
+                if(!Utils.storedChunks.containsKey(receivedFile.getHashedFileId() + ":" + receivedFile.getChunkNo())){
+                    Utils.storedChunks.put(receivedFile.getHashedFileId() + ":" + receivedFile.getChunkNo(),new ArrayList<Integer>());
+                    Utils.storedChunks.get(receivedFile.getHashedFileId() + ":" +  receivedFile.getChunkNo()).add(Integer.parseInt(receivedFile.getReplicationDeg()));
+                }
+
+                //saveFileIfSentFromAnotherPeer
+                if(! (receivedFile.getSenderId() == Peer.getSenderId())) {
+
+                    //System.out.println("MDB: Received CMD - " + receivedFile.getStringInformation());
+                    if(!checkIfFileExists(receivedFile.getHashedFileId() + receivedFile.getChunkNo()))
+                        receivedFile.saveToDisk(Peer.getSenderId(),receivedFile.getChunkNo());
+                    try {
+                        Thread.sleep(new Random().nextInt(400));
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                    sendStoredMessage(receivedFile);
+                }
+            }
+            catch(IOException e){
+                e.getCause();
+            }
+
+
+        }
+
+
+    }
+
+    private void sendStoredMessage(FileController receivedFile) throws IOException {
+        String message = ("STORED " + receivedFile.getVersion() + " " +
+                Peer.getSenderId() + " " + receivedFile.getHashedFileId()
+                + " " + receivedFile.getChunkNo() + Utils.crlf);
+        byte[] buf = new byte[256];
+        buf = message.getBytes();
+
+        DatagramPacket packet = new DatagramPacket(buf,buf.length, Peer.getMcAddress(),Peer.getMcPort());
+        Utils.mcSocket.send(packet);
+    }
+
+    public static void sendMessage(byte[] buf) throws IOException{
+        DatagramPacket packet = new DatagramPacket(buf,buf.length, Peer.getMdbAddress(),Peer.getMdbPort());
+        Utils.mdbSocket.send(packet);
+    }
+
+    private boolean checkIfFileExists(String string) {
+        File f = new File("src/test/" + Peer.getSenderId() + "/" + string);
+        if(f.exists() && !f.isDirectory())
+            return true;
+        return false;
+    }
+}
\ No newline at end of file
Index: src/channels/MdrChannel.java
===================================================================
--- src/channels/MdrChannel.java	(nonexistent)
+++ src/channels/MdrChannel.java	(revision 1)
@@ -0,0 +1,94 @@
+package channels;
+
+import peer.Peer;
+import utils.FileController;
+import utils.Utils;
+
+import java.io.*;
+import java.net.DatagramPacket;
+
+public class MdrChannel implements Runnable{
+    public void run(){
+        while(true){
+            byte[] buf = new byte[64000 + 1000];
+            DatagramPacket receivePacket = new DatagramPacket(buf, buf.length);
+            try{
+                Utils.mdrSocket.receive(receivePacket);
+                String received = new String(receivePacket.getData(),0,receivePacket.getLength());
+
+                String[] receivedArray = received.split("\\r\\n\\r\\n");
+                int offsetOfBody = receivedArray[0].length() + 4;
+                byte[] bodyByteArray = getArrayFromOffset(receivePacket.getData(), offsetOfBody, receivePacket.getLength());
+
+                FileController receivedFile = new FileController(receivedArray, bodyByteArray);
+
+                if(Peer.getSenderId() == Utils.restorePeer){ //save to init peer
+                    saveFile(receivedFile);
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private byte[] getArrayFromOffset(byte[] data, int offsetOfBody, int length) {
+        int size = length - offsetOfBody;
+        byte[] toRet = new byte[size];
+
+        for(int i = offsetOfBody; i < length; i++) {
+            toRet[i - offsetOfBody] = data[i];
+        }
+
+        return toRet;
+    }
+
+    private void saveFile(FileController receivedFile) throws IOException {
+
+        File theDir = new File("storage/Restored");
+
+        // if the directory does not exist, create it
+        if (!theDir.exists()) {
+            boolean result = false;
+
+            try{
+                theDir.mkdir();
+                result = true;
+            }
+            catch(SecurityException se){
+            }
+            if(result) {
+            }
+        }
+
+        File dir = new File("storage/Restored/Peer" + Peer.getSenderId());
+
+        // if the directory does not exist, create it
+        if (!dir.exists()) {
+            boolean result = false;
+
+            try{
+                dir.mkdir();
+                result = true;
+            }
+            catch(SecurityException se){
+            }
+            if(result) {
+            }
+        }
+
+        File f = new File("storage/Restored/Peer" + Peer.getSenderId() + "/" + receivedFile.getChunkNo());
+
+        if(!f.exists()) { //if file is not saved yet by other peer...
+            f.createNewFile();
+        }
+        OutputStream out = new FileOutputStream(f);
+        out.write(receivedFile.getBody(), 0, receivedFile.getBody().length);
+        out.close();
+        Utils.chunkReceived = true;
+    }
+
+    public static void sendMessage(byte[] buf) throws IOException {
+        DatagramPacket packet = new DatagramPacket(buf, buf.length, Peer.getMdrAddress(), Peer.getMdrPort());
+        Utils.mdrSocket.send(packet);
+    }
+}
\ No newline at end of file
Index: src/test/teste.txt
===================================================================
--- src/test/teste.txt	(nonexistent)
+++ src/test/teste.txt	(revision 1)
@@ -0,0 +1,13 @@
+Este é um ficheiro de teste.
+DFDJFDSF
+DFSDFDSFDS
+DFDSFSFFD
+DFSDFSDFSDFDS
+DFSFSDFSFSDFSFDSF
+FDSFSDFDSFSDFDSFDSFSDF
+......
+--------
+´´´´´´´´´
+~~~~~~~~~~1323658769
+0xD 0xA 
+
Index: src/out/production/SIDS/.idea/encodings.xml
===================================================================
--- src/out/production/SIDS/.idea/encodings.xml	(nonexistent)
+++ src/out/production/SIDS/.idea/encodings.xml	(revision 1)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>
\ No newline at end of file
Index: src/utils/Utils.java
===================================================================
--- src/utils/Utils.java	(nonexistent)
+++ src/utils/Utils.java	(revision 1)
@@ -0,0 +1,47 @@
+package utils;
+
+import channels.McChannel;
+import channels.MdbChannel;
+import channels.MdrChannel;
+
+import java.net.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+
+public class Utils {
+    public static int BUFFER_SIZE = 256;
+    public static MulticastSocket mcSocket;
+    public static MulticastSocket mdbSocket;
+    public static MulticastSocket mdrSocket;
+
+    public static String version = "1.0";
+    public static String crlf = "\\r\\n";
+
+    public static McChannel mcChannel;
+    public static MdbChannel mdbChannel;
+    public static MdrChannel mdrChannel;
+
+    public static boolean chunkReceived = false;
+    public static int restorePeer = 0;
+    public static boolean receivedAllChunks = false;
+
+    public static HashMap<String,String> hashDatabase = new HashMap<String, String>();
+    public static HashMap<String, ArrayList<Integer>> storedChunks = new HashMap<>();
+
+
+    public static String encodeHexString(byte[] byteArray) { //https://www.baeldung.com/java-byte-arrays-hex-strings
+        StringBuffer hexStringBuffer = new StringBuffer();
+        for (int i = 0; i < byteArray.length; i++) {
+            hexStringBuffer.append(byteToHex(byteArray[i]));
+        }
+        return hexStringBuffer.toString();
+    }
+
+    public static String byteToHex(byte num) {
+        char[] hexDigits = new char[2];
+        hexDigits[0] = Character.forDigit((num >> 4) & 0xF, 16);
+        hexDigits[1] = Character.forDigit((num & 0xF), 16);
+        return new String(hexDigits);
+    }
+}
\ No newline at end of file
Index: src/out/production/SIDS/.idea/misc.xml
===================================================================
--- src/out/production/SIDS/.idea/misc.xml	(nonexistent)
+++ src/out/production/SIDS/.idea/misc.xml	(revision 1)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_10" project-jdk-name="10" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>
\ No newline at end of file
Index: src/out/production/SIDS/.idea/modules.xml
===================================================================
--- src/out/production/SIDS/.idea/modules.xml	(nonexistent)
+++ src/out/production/SIDS/.idea/modules.xml	(revision 1)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/SIDS.iml" filepath="$PROJECT_DIR$/SIDS.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
Index: src/out/production/SIDS/.idea/vcs.xml
===================================================================
--- src/out/production/SIDS/.idea/vcs.xml	(nonexistent)
+++ src/out/production/SIDS/.idea/vcs.xml	(revision 1)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
Index: peer2.sh
===================================================================
--- peer2.sh	(nonexistent)
+++ peer2.sh	(revision 1)
@@ -0,0 +1,4 @@
+cd src
+javac *.java
+java peer.Peer 2 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002
+

Property changes on: peer2.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: testApp.sh
===================================================================
--- testApp.sh	(nonexistent)
+++ testApp.sh	(revision 1)
@@ -0,0 +1,2 @@
+cd src
+java TestApp

Property changes on: testApp.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/out/production/SIDS/.idea/workspace.xml
===================================================================
--- src/out/production/SIDS/.idea/workspace.xml	(nonexistent)
+++ src/out/production/SIDS/.idea/workspace.xml	(revision 1)
@@ -0,0 +1,413 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ChangeListManager">
+    <list default="true" id="d51d95c7-4d11-4ecd-934b-ad1c8b084f2c" name="Default Changelist" comment="">
+      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/channels/McChannel.java" beforeDir="false" afterPath="$PROJECT_DIR$/channels/McChannel.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/channels/MdbChannel.java" beforeDir="false" afterPath="$PROJECT_DIR$/channels/MdbChannel.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/channels/MdrChannel.java" beforeDir="false" afterPath="$PROJECT_DIR$/channels/MdrChannel.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/.idea/misc.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/TestApp.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/TestApp.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/channels/McChannel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/channels/McChannel.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/channels/MdbChannel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/channels/MdbChannel.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/channels/MdrChannel.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/channels/MdrChannel.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/peer/Peer.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/peer/Peer.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/protocols/BackupProtocol.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/protocols/BackupProtocol.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/protocols/RestoreProtocol.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/protocols/RestoreProtocol.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/utils/Chunk.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/utils/Chunk.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/utils/FileController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/utils/FileController.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/out/production/SIDS/utils/Utils.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/SIDS/utils/Utils.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/protocols/BackupProtocol.java" beforeDir="false" afterPath="$PROJECT_DIR$/protocols/BackupProtocol.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/protocols/RestoreProtocol.java" beforeDir="false" afterPath="$PROJECT_DIR$/protocols/RestoreProtocol.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/storage/Backup/Peer11/35c42a2c5b603a69a045174897a3b25a54920b06b0f2ecf24610f4cc0379a5c4/0" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/storage/Backup/Peer11/35c42a2c5b603a69a045174897a3b25a54920b06b0f2ecf24610f4cc0379a5c4/1" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/utils/Chunk.java" beforeDir="false" afterPath="$PROJECT_DIR$/utils/Chunk.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utils/FileController.java" beforeDir="false" afterPath="$PROJECT_DIR$/utils/FileController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/utils/Utils.java" afterDir="false" />
+    </list>
+    <ignored path="$PROJECT_DIR$/out/" />
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="FileEditorManager">
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/protocols/RestoreProtocol.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="151">
+              <caret line="79" column="61" selection-start-line="79" selection-start-column="61" selection-end-line="79" selection-end-column="61" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/channels/McChannel.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="601">
+              <caret line="68" column="36" selection-start-line="68" selection-start-column="36" selection-end-line="68" selection-end-column="36" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/utils/Chunk.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="361">
+              <caret line="29" column="141" selection-start-line="29" selection-start-column="141" selection-end-line="29" selection-end-column="141" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/channels/MdrChannel.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="240">
+              <caret line="21" column="63" selection-start-line="21" selection-start-column="63" selection-end-line="21" selection-end-column="63" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/utils/Utils.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="330">
+              <caret line="28" column="85" selection-start-line="28" selection-start-column="85" selection-end-line="28" selection-end-column="85" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/peer/Peer.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="60">
+              <caret line="15" column="13" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/TestApp.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="90">
+              <caret line="10" selection-start-line="10" selection-end-line="10" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/utils/FileController.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="466">
+              <caret line="189" column="119" selection-start-line="189" selection-start-column="109" selection-end-line="189" selection-end-column="119" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/protocols/BackupProtocol.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="-149">
+              <caret line="4" column="12" selection-start-line="4" selection-start-column="7" selection-end-line="4" selection-end-column="12" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/channels/MdbChannel.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="510">
+              <caret line="42" column="17" selection-start-line="42" selection-start-column="17" selection-end-line="42" selection-end-column="17" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+    </leaf>
+  </component>
+  <component name="FindInProjectRecents">
+    <findStrings>
+      <find>store</find>
+      <find>stored</find>
+      <find>hashData</find>
+      <find>Utils</find>
+    </findStrings>
+  </component>
+  <component name="Git.Settings">
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
+  </component>
+  <component name="IdeDocumentHistory">
+    <option name="CHANGED_PATHS">
+      <list>
+        <option value="$PROJECT_DIR$/protocols/BackupProtocol.java" />
+        <option value="$PROJECT_DIR$/utils/Utils.java" />
+        <option value="$PROJECT_DIR$/channels/MdbChannel.java" />
+        <option value="$PROJECT_DIR$/protocols/RestoreProtocol.java" />
+        <option value="$PROJECT_DIR$/channels/MdrChannel.java" />
+        <option value="$PROJECT_DIR$/channels/McChannel.java" />
+        <option value="$PROJECT_DIR$/utils/FileController.java" />
+        <option value="$PROJECT_DIR$/utils/Chunk.java" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectFrameBounds" extendedState="6">
+    <option name="x" value="1849" />
+    <option name="width" value="1356" />
+    <option name="height" value="528" />
+  </component>
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+  <component name="ProjectView">
+    <navigator proportions="" version="1">
+      <foldersAlwaysOnTop value="true" />
+    </navigator>
+    <panes>
+      <pane id="Scope" />
+      <pane id="PackagesPane" />
+      <pane id="ProjectPane">
+        <subPane>
+          <expand>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="channels" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="peer" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="protocols" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="src" type="b2602c69:ProjectViewProjectNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="utils" type="462c0819:PsiDirectoryNode" />
+            </path>
+          </expand>
+          <select />
+        </subPane>
+      </pane>
+    </panes>
+  </component>
+  <component name="PropertiesComponent">
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1555187104674" />
+  </component>
+  <component name="RunDashboard">
+    <option name="ruleStates">
+      <list>
+        <RuleState>
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
+        </RuleState>
+        <RuleState>
+          <option name="name" value="StatusDashboardGroupingRule" />
+        </RuleState>
+      </list>
+    </option>
+  </component>
+  <component name="RunManager" selected="Application.TestApp">
+    <configuration name="Peer1" type="Application" factoryName="Application" temporary="true">
+      <option name="MAIN_CLASS_NAME" value="peer.Peer" />
+      <module name="SIDS" />
+      <option name="PROGRAM_PARAMETERS" value="1 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="peer.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="Peer2" type="Application" factoryName="Application">
+      <option name="MAIN_CLASS_NAME" value="peer.Peer" />
+      <module name="SIDS" />
+      <option name="PROGRAM_PARAMETERS" value="2 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="peer.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="Peer3" type="Application" factoryName="Application">
+      <option name="MAIN_CLASS_NAME" value="peer.Peer" />
+      <module name="SIDS" />
+      <option name="PROGRAM_PARAMETERS" value="3 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002" />
+      <extension name="coverage">
+        <pattern>
+          <option name="PATTERN" value="peer.*" />
+          <option name="ENABLED" value="true" />
+        </pattern>
+      </extension>
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="TestApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
+      <option name="MAIN_CLASS_NAME" value="TestApp" />
+      <module name="SIDS" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <list>
+      <item itemvalue="Application.Peer2" />
+      <item itemvalue="Application.Peer3" />
+      <item itemvalue="Application.Peer1" />
+      <item itemvalue="Application.TestApp" />
+    </list>
+    <recent_temporary>
+      <list>
+        <item itemvalue="Application.Peer1" />
+        <item itemvalue="Application.TestApp" />
+      </list>
+    </recent_temporary>
+  </component>
+  <component name="SvnConfiguration">
+    <configuration />
+  </component>
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <changelist id="d51d95c7-4d11-4ecd-934b-ad1c8b084f2c" name="Default Changelist" comment="" />
+      <created>1555096072834</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1555096072834</updated>
+    </task>
+    <servers />
+  </component>
+  <component name="ToolWindowManager">
+    <frame x="1366" y="-2" width="1920" height="1082" extended-state="6" />
+    <editor active="true" />
+    <layout>
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1814301" />
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
+      <window_info id="Image Layers" order="2" />
+      <window_info id="Designer" order="3" />
+      <window_info id="UI Designer" order="4" />
+      <window_info id="Capture Tool" order="5" />
+      <window_info id="Favorites" order="6" side_tool="true" />
+      <window_info anchor="bottom" id="Message" order="0" />
+      <window_info anchor="bottom" id="Find" order="1" />
+      <window_info anchor="bottom" x="50" y="57" width="1204" height="551" id="Run" order="2" type="WINDOWED" visible="true" weight="0.45960125" />
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
+      <window_info anchor="bottom" id="TODO" order="6" />
+      <window_info anchor="bottom" id="Terminal" order="7" />
+      <window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
+      <window_info anchor="bottom" id="Version Control" order="9" />
+      <window_info anchor="bottom" id="Messages" order="10" />
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
+      <window_info anchor="right" id="Palette" order="3" />
+      <window_info anchor="right" id="Maven" order="4" />
+      <window_info anchor="right" id="Theme Preview" order="5" />
+      <window_info anchor="right" id="Capture Analysis" order="6" />
+      <window_info anchor="right" id="Palette&#9;" order="7" />
+    </layout>
+  </component>
+  <component name="editorHistoryManager">
+    <entry file="file://$PROJECT_DIR$/peer/Peer.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="60">
+          <caret line="15" column="13" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/TestApp.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="90">
+          <caret line="10" selection-start-line="10" selection-end-line="10" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/channels/MdbChannel.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="510">
+          <caret line="42" column="17" selection-start-line="42" selection-start-column="17" selection-end-line="42" selection-end-column="17" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/protocols/BackupProtocol.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="-149">
+          <caret line="4" column="12" selection-start-line="4" selection-start-column="7" selection-end-line="4" selection-end-column="12" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/Utils.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="330">
+          <caret line="28" column="85" selection-start-line="28" selection-start-column="85" selection-end-line="28" selection-end-column="85" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/protocols/RestoreProtocol.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="151">
+          <caret line="79" column="61" selection-start-line="79" selection-start-column="61" selection-end-line="79" selection-end-column="61" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/channels/MdrChannel.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="240">
+          <caret line="21" column="63" selection-start-line="21" selection-start-column="63" selection-end-line="21" selection-end-column="63" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/FileController.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="466">
+          <caret line="189" column="119" selection-start-line="189" selection-start-column="109" selection-end-line="189" selection-end-column="119" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/channels/McChannel.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="601">
+          <caret line="68" column="36" selection-start-line="68" selection-start-column="36" selection-end-line="68" selection-end-column="36" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/utils/Chunk.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="361">
+          <caret line="29" column="141" selection-start-line="29" selection-start-column="141" selection-end-line="29" selection-end-column="141" />
+        </state>
+      </provider>
+    </entry>
+  </component>
+  <component name="masterDetails">
+    <states>
+      <state key="ProjectJDKs.UI">
+        <settings>
+          <last-edited>10</last-edited>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+    </states>
+  </component>
+</project>
\ No newline at end of file
Index: src/out/production/SIDS/channels/McChannel.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/channels/McChannel.class
===================================================================
--- src/out/production/SIDS/channels/McChannel.class	(nonexistent)
+++ src/out/production/SIDS/channels/McChannel.class	(revision 1)

Property changes on: src/out/production/SIDS/channels/McChannel.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/channels/MdbChannel.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/channels/MdbChannel.class
===================================================================
--- src/out/production/SIDS/channels/MdbChannel.class	(nonexistent)
+++ src/out/production/SIDS/channels/MdbChannel.class	(revision 1)

Property changes on: src/out/production/SIDS/channels/MdbChannel.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/channels/MdrChannel.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/channels/MdrChannel.class
===================================================================
--- src/out/production/SIDS/channels/MdrChannel.class	(nonexistent)
+++ src/out/production/SIDS/channels/MdrChannel.class	(revision 1)

Property changes on: src/out/production/SIDS/channels/MdrChannel.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/peer/Peer.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/peer/Peer.class
===================================================================
--- src/out/production/SIDS/peer/Peer.class	(nonexistent)
+++ src/out/production/SIDS/peer/Peer.class	(revision 1)

Property changes on: src/out/production/SIDS/peer/Peer.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/protocols/BackupProtocol.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/protocols/BackupProtocol.class
===================================================================
--- src/out/production/SIDS/protocols/BackupProtocol.class	(nonexistent)
+++ src/out/production/SIDS/protocols/BackupProtocol.class	(revision 1)

Property changes on: src/out/production/SIDS/protocols/BackupProtocol.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/protocols/RestoreProtocol.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/protocols/RestoreProtocol.class
===================================================================
--- src/out/production/SIDS/protocols/RestoreProtocol.class	(nonexistent)
+++ src/out/production/SIDS/protocols/RestoreProtocol.class	(revision 1)

Property changes on: src/out/production/SIDS/protocols/RestoreProtocol.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0
===================================================================
--- src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0	(nonexistent)
+++ src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0	(revision 1)

Property changes on: src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1
===================================================================
--- src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1	(nonexistent)
+++ src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1	(revision 1)

Property changes on: src/out/production/SIDS/storage/Backup/Peer2/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0
===================================================================
--- src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0	(nonexistent)
+++ src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0	(revision 1)

Property changes on: src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/0
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1
===================================================================
--- src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1	(nonexistent)
+++ src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1	(revision 1)

Property changes on: src/out/production/SIDS/storage/Backup/Peer3/7fa8ccea18b60ec345db886bca2c458bd79726a7f4f8141576e98ff09d2af7ca/1
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/storage/Restored/Peer1/0
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Restored/Peer1/0
===================================================================
--- src/out/production/SIDS/storage/Restored/Peer1/0	(nonexistent)
+++ src/out/production/SIDS/storage/Restored/Peer1/0	(revision 1)

Property changes on: src/out/production/SIDS/storage/Restored/Peer1/0
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/storage/Restored/Peer1/1
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/storage/Restored/Peer1/1
===================================================================
--- src/out/production/SIDS/storage/Restored/Peer1/1	(nonexistent)
+++ src/out/production/SIDS/storage/Restored/Peer1/1	(revision 1)

Property changes on: src/out/production/SIDS/storage/Restored/Peer1/1
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/test/804838.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/test/804838.jpg
===================================================================
--- src/test/804838.jpg	(nonexistent)
+++ src/test/804838.jpg	(revision 1)

Property changes on: src/test/804838.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/utils/Chunk.java
===================================================================
--- src/utils/Chunk.java	(nonexistent)
+++ src/utils/Chunk.java	(revision 1)
@@ -0,0 +1,61 @@
+package utils;
+
+import peer.Peer;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+public class Chunk {
+    private static int SIZE = 64000;
+
+    private byte[] header;
+    private byte[] data;
+    private byte[] buffer;
+
+    private int chunkDataLength;
+    private int chunkLength;
+
+    private String headerMsg;
+
+    public Chunk(byte[] h, FileController fileController) throws IOException{ //Chunk to backup
+        this.header = h;
+        this.data = getChunkData(fileController);
+        this.buffer = mergeByteArrays(this.header, this.data);
+		this.chunkLength = this.chunkDataLength + this.header.length;
+    }
+
+    public Chunk(byte[] dataBuffer, String messageType, String hashFileId, String chunkNo){ //Chunk to restore
+        this.data = dataBuffer;
+        this.chunkDataLength = this.data.length;
+        String headerMsg = messageType + " " + Utils.version + " " + Peer.getSenderId() + " " + hashFileId + " " + chunkNo + " " + "\r\n\r\n";
+        byte[] buf = headerMsg.getBytes();
+        this.headerMsg = headerMsg;
+        this.header = buf;
+        this.buffer = mergeByteArrays(this.header, this.data);
+        this.chunkLength = this.header.length + this.chunkDataLength;
+    }
+
+    public byte[] getChunkData(FileController fileController) throws IOException{
+        byte[] dataBuffer = new byte[SIZE];
+        this.chunkDataLength = fileController.getFileStream().read(dataBuffer,0,SIZE);
+        return dataBuffer;
+    }
+
+    public byte[] getBuffer(){
+        this.buffer  = Arrays.copyOf(this.buffer,this.chunkLength);
+        return buffer;
+    }
+
+    public byte[] mergeByteArrays(byte[] header, byte[] content){
+		
+		byte[] ret = new byte[header.length + content.length];
+		System.arraycopy(header, 0, ret, 0, header.length);
+		System.arraycopy(content, 0, ret, header.length, content.length);
+		
+		return ret;
+	}
+
+	public String getHeaderMsg(){
+        return headerMsg;
+    }
+}
Index: src/SIDS.iml
===================================================================
--- src/SIDS.iml	(nonexistent)
+++ src/SIDS.iml	(revision 1)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
\ No newline at end of file
Index: peer3.sh
===================================================================
--- peer3.sh	(nonexistent)
+++ peer3.sh	(revision 1)
@@ -0,0 +1,5 @@
+cd src
+javac *.java
+java peer.Peer 3 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002
+
+

Property changes on: peer3.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/out/production/SIDS/test/804838.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/test/804838.jpg
===================================================================
--- src/out/production/SIDS/test/804838.jpg	(nonexistent)
+++ src/out/production/SIDS/test/804838.jpg	(revision 1)

Property changes on: src/out/production/SIDS/test/804838.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/test/teste.txt
===================================================================
--- src/out/production/SIDS/test/teste.txt	(nonexistent)
+++ src/out/production/SIDS/test/teste.txt	(revision 1)
@@ -0,0 +1,13 @@
+Este é um ficheiro de teste.
+DFDJFDSF
+DFSDFDSFDS
+DFDSFSFFD
+DFSDFSDFSDFDS
+DFSFSDFSFSDFSFDSF
+FDSFSDFDSFSDFDSFDSFSDF
+......
+--------
+´´´´´´´´´
+~~~~~~~~~~1323658769
+0xD 0xA 
+
Index: src/out/production/SIDS/utils/FileController.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/out/production/SIDS/utils/FileController.class
===================================================================
--- src/out/production/SIDS/utils/FileController.class	(nonexistent)
+++ src/out/production/SIDS/utils/FileController.class	(revision 1)

Property changes on: src/out/production/SIDS/utils/FileController.class
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/out/production/SIDS/SIDS.iml
===================================================================
--- src/out/production/SIDS/SIDS.iml	(nonexistent)
+++ src/out/production/SIDS/SIDS.iml	(revision 1)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
\ No newline at end of file
Index: src/protocols/BackupProtocol.java
===================================================================
--- src/protocols/BackupProtocol.java	(nonexistent)
+++ src/protocols/BackupProtocol.java	(revision 1)
@@ -0,0 +1,68 @@
+package protocols;
+
+import channels.MdbChannel;
+import peer.Peer;
+import utils.Chunk;
+import utils.FileController;
+import utils.Utils;
+
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+
+public class BackupProtocol {
+
+    FileController file;
+
+    private int[] peers;
+    private String fileId;
+    private int chunkNo;
+
+    public BackupProtocol(String[] requestArgs) throws IOException, NoSuchAlgorithmException {
+        file = new FileController(requestArgs[0], Utils.version, Peer.getSenderId(),requestArgs[1],requestArgs[2]);
+        backUpFile();
+    }
+
+    private void backUpFile() throws IOException, NoSuchAlgorithmException {
+        file.openStream();
+        file.hashFileId();
+        int size = file.getSize();
+        this.fileId=file.getHashedFileId();
+        sendToPeers(size);
+    }
+
+    private void sendToPeers(int size) throws IOException, NoSuchAlgorithmException {
+        
+        for(int i=0; (i==0 || size > 0);i++){
+            this.peers = new int[0];
+            boolean done = false;
+            int attempts = 0;
+            int delay = 1000;
+
+            size -= 64000;
+            byte[] header = file.header(i);
+            Chunk chunk = new Chunk(header,file);
+
+            while(!done && attempts<5){
+                System.out.println("BACKUP: Sending chunk of: " + file.getFileName() + "  ||  Size Remaining:" + size + " ||  Header: " + new String(header,0,header.length));
+
+                this.chunkNo = i;
+                MdbChannel.sendMessage(chunk.getBuffer());
+                try{
+                    Thread.sleep(delay);
+                } catch(InterruptedException e){
+                    e.getCause();
+                }
+                if(Integer.parseInt(file.getReplicationDeg()) <= this.peers.length){
+                    done = true;
+                }
+                else{
+                    attempts++;
+                    delay=2*delay;
+                }
+
+            }
+        }
+        System.out.println(("DONE"));
+    }
+}
Index: src/test/htp.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/test/htp.jpg
===================================================================
--- src/test/htp.jpg	(nonexistent)
+++ src/test/htp.jpg	(revision 1)

Property changes on: src/test/htp.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/utils/FileController.java
===================================================================
--- src/utils/FileController.java	(nonexistent)
+++ src/utils/FileController.java	(revision 1)
@@ -0,0 +1,229 @@
+package utils;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public class FileController implements Serializable {
+    private String messageType;
+    private String version;
+    private int senderId; //id of the server that has sent the message
+    private String fileId; //metadata of file
+    private byte[] body;
+
+    private String hashedFileId; //hashed string with SHA256
+
+    private String chunkNo; //together with the FileId specifies a chunk in the file.
+    private String replicationDeg; //up to 9
+    private int fileSize;
+
+    private File file;
+    private FileInputStream fileStream;
+
+    public FileController(String m, String v, int s, String f, String r) throws IOException {
+        this.messageType = m;
+        this.version = v;
+        this.senderId = s;
+        this.fileId = f;
+        this.replicationDeg = r;
+    }
+
+    public FileController(String[] receivedArray, byte[] bodyByteArray){
+        String headerMsg = receivedArray[0];
+        String[] headerTokens = headerMsg.split("\\s+");
+
+        this.messageType = headerTokens[0];
+        this.version = headerTokens[1];
+        this.chunkNo = headerTokens[4];
+
+        this.hashedFileId = headerTokens[3];
+        if(headerTokens.length >= 6)
+            this.replicationDeg = headerTokens[5];
+        else
+            this.replicationDeg = "";
+        this.senderId = Integer.parseInt(headerTokens[2]);
+
+        this.body = bodyByteArray;
+        this.fileId = null;
+    }
+
+    public String getFileMetadata(String f) throws IOException {
+        Path file = FileSystems.getDefault().getPath("test", f);
+        BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
+
+        return f + "-" + attr.lastModifiedTime() + "-" + attr.creationTime();
+    }
+
+    public String getFileName(){
+        return this.fileId;
+    }
+
+    public void saveToDisk(int senderId, String chunckNo) throws IOException {
+        System.out.println("saving to disk...  ||  Sender ID: " + senderId + "  ||  ChunkNo: " + chunkNo);
+        File storage = new File("storage");
+
+        // if the directory does not exist, create it
+        if (!storage.exists()) {
+            System.out.println("creating directory to store chunks: " + storage.getName());
+            boolean result = false;
+
+            try{
+                storage.mkdir();
+                result = true;
+            }
+            catch(SecurityException se){
+                //handle it
+            }
+            if(result) {
+                System.out.println("Storage Directory created");
+            }
+        }
+
+        //directory for backup
+        File backup = new File ("storage/Backup");
+
+        // if the directory does not exist, create it
+        if (!backup.exists()) {
+            System.out.println("creating directory to store chunks: " + backup.getName());
+            boolean result = false;
+
+            try{
+                backup.mkdir();
+                result = true;
+            }
+            catch(SecurityException se){
+                //handle it
+            }
+            if(result) {
+                System.out.println("Backup Directory created");
+            }
+        }
+        //directory for peerid
+        File peerId = new File ("storage/Backup/Peer" + senderId);
+
+        // if the directory does not exist, create it
+        if (!peerId.exists()) {
+            System.out.println("creating directory to store chunks: " + peerId.getName());
+            boolean result = false;
+
+            try{
+                peerId.mkdir();
+                result = true;
+            }
+            catch(SecurityException se){
+                //handle it
+            }
+            if(result) {
+                System.out.println("PeerId Directory created");
+            }
+        }
+        //directory for hashed file id
+        //System.out.println(this.hashedFileId);
+        File hashedDir = new File("storage/Backup/Peer" + senderId + "/"+ this.hashedFileId);
+        // if the directory does not exist, create it
+        if (!hashedDir.exists()) {
+            System.out.println("creating directory to store chunks: " + hashedDir.getName());
+            boolean result = false;
+
+            try{
+                hashedDir.mkdir();
+                result = true;
+            }
+            catch(SecurityException se){
+                //handle it
+            }
+            if(result) {
+                System.out.println("file Directory created");
+            }
+        }
+
+        //now store the chunck
+        File chunk = new File("storage/Backup/Peer" + senderId + "/"+ this.hashedFileId + "/" + chunckNo);
+
+        FileOutputStream fos = new FileOutputStream(chunk);
+        fos.write(this.body);
+        fos.close();
+        
+
+
+
+    }
+
+    public void hashFileId() throws NoSuchAlgorithmException, IOException { //reference https://www.baeldung.com/sha-256-hashing-java
+        //add a little more info to hash this fileId;
+        String fileIdWithMetadata = getFileMetadata(this.fileId);
+
+
+        if(!Utils.hashDatabase.containsKey(this.fileId)){
+            MessageDigest digest = MessageDigest.getInstance("SHA-256");
+            byte[] encodedhash = digest.digest(
+                    fileIdWithMetadata.getBytes(StandardCharsets.UTF_8));
+            String hexHash = Utils.encodeHexString(encodedhash);
+            this.hashedFileId = hexHash;
+
+            Utils.hashDatabase.put(this.fileId,hexHash);
+        }
+        else this.hashedFileId = Utils.hashDatabase.get(this.fileId);
+    }
+
+    public void openStream() throws FileNotFoundException {
+        this.file = new File("test/" + getFileName());
+        this.fileStream = new FileInputStream(this.file);
+        this.fileSize = ((int) this.file.length());
+    }
+
+    public byte[] header(int chunkNo){
+        String header = "";
+        switch(messageType){
+            case "BACKUP":
+                header = messageType + " " + version + " " + senderId + " " + hashedFileId + " " + chunkNo + " " + replicationDeg + "\r\n\r\n";
+                break;
+            case "RESTORE":
+                header = messageType + " " + version + " " + senderId + " " + hashedFileId + " " + chunkNo + "\r\n\r\n";
+                break;
+
+        }
+        byte[] buffer = header.getBytes();
+        return buffer;
+    }
+
+    public int getSenderId() {
+        return senderId;
+    }
+
+    public String getHashedFileId() {
+        return hashedFileId;
+    }
+
+    public int getSize() {
+        return fileSize;
+    }
+
+    public FileInputStream getFileStream(){
+        return fileStream;
+    }
+
+    public String getReplicationDeg(){
+        return replicationDeg;
+    }
+
+    public String getChunkNo() {
+        return chunkNo;
+    }
+
+    public String getVersion() {
+        return this.version;
+    }
+
+    public byte[] getBody(){
+        return body;
+    }
+}
Index: peer1.sh
===================================================================
--- peer1.sh	(nonexistent)
+++ peer1.sh	(revision 1)
@@ -0,0 +1,4 @@
+cd src
+javac *.java
+java peer.Peer 1 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002
+

Property changes on: peer1.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: peer_args.txt
===================================================================
--- peer_args.txt	(nonexistent)
+++ peer_args.txt	(revision 1)
@@ -0,0 +1 @@
+1 224.0.0.0:8000 224.0.0.0:8001 224.0.0.0:8002
\ No newline at end of file
