import java.net.DatagramSocket;
import java.time.Instant;
import java.util.Random;

/**
 * This is the main class of the server. It represents the sink in the ad-hoc gradient routing network.
 * Created by nicolas on 11/04/17.
 */
public class Main {

    private static int deviceId;

    private static int gradient = 0;    // the server is always the sink in the network

    public static void main(String[] args) {
        System.out.println("Hello server");
        deviceId = Integer.parseInt(args[0]);
        initialization();
    }

    /**
     * This function initializes the gradient network
     */
    private static void initialization() {
        Random rand = new Random();
        try {
            String random = Instant.now().toString() + rand.nextInt(1000000000);
            DatagramSocket socket = new DatagramSocket(Constants.portNumber);
            Utils.broadcast(
                    Utils.createNetworkPacket(
                            true, gradient, deviceId,
                            Instant.now().toString(), random),
                    socket);
        } catch(Exception E) {
            System.out.println("Socket exception error: " + E);
        }
    }
}

@@ -68,22 +68,20 @@
 va.util.
-Random
+UUID
 ;%0A%0A/**%0A 
@@ -659,130 +659,13 @@
     
-Random rand = new Random();%0A        try %7B%0A            String random = Instant.now().toString() + rand.nextInt(1000000000);
+try %7B
 %0A   
@@ -872,36 +872,8 @@
 eId,
-%0A                           
  Ins
@@ -899,14 +899,36 @@
 (), 
+UUID.
 random
+UUID().toString()
 ),%0A 

Update uniqueId of messageUid