public void update(Packet p)
    { 
      //first, we define a boolean to mark whether any minDistance has changed. If none have changed,
      //we won't send out a packet.  It's initialized to false, because nothing has changed yet.
      boolean send = false;
      //Again, an array to hold and eventually send minimum distance values
      int[] minDistance = new int[4];
      //This for loop recalculates the min costs to each node and again store them in minDistance.
      for(int h = 0; h < 4; h++){
        //int a = Math.min(distanceTable[h][0], distanceTable[h][1]);
        int b = Math.min(distanceTable[h][2], distanceTable[h][3]);
        minDistance[h] = Math.min(distanceTable[h][1], b);
      }
      //This for loop checks to see if the cost in the distance table of getting to each node via p's source,
      // is less than the cost found by calculating the Mincost given by p plus the cost in the distance table 
      //of getting to each node. 
      for(int k = 0; k<4; k++){
        if(p.getMincost(k)+minDistance[p.getSource()] < distanceTable[k][p.getSource()]){
          //if so, it changes the value in the distance table to reflect the lesser value
          distanceTable[k][p.getSource()] = p.getMincost(k)+minDistance[p.getSource()];
          //it also checks to see if this is the new minimum distance for reaching this node.  If this
          //minimum value has changed, it changes send to true.
          if(distanceTable[k][p.getSource()]<minDistance[k]){
            minDistance[k] = distanceTable[k][p.getSource()];
            send = true;
          }
        }
      }
      //if the minimum value has changed, it sends update packets to each other node.
      if(send){
        for(int i = 1; i < 4; i++){
          Packet dtPacket = new Packet(0, i, minDistance);
          NetworkSimulator.toLayer2(dtPacket);
        }
      }
      //Prints the time, the fac that the update method just completed, and the current Distance Table.
      System.out.println("Entity0 Update Complete. Distance Table is:");
      System.out.println("Time now is " + NetworkSimulator.time + ".");
      printDT();
    }