public static void main(String[] args){

		int numberOfRounds = 5000;
		int messagesPerRound = 5;
		int port = 0;
		String filename = "";

		if (args.length == 2) {
			port = Integer.parseInt(args[0]);
			filename = args[1];
		}

		else if (args.length == 4){
			port = Integer.parseInt(args[0]);
			filename = args[1];
			numberOfRounds = Integer.parseInt(args[2]);
			messagesPerRound = Integer.parseInt(args[3]);
		}

		else {
			System.out.println("Usage: java node PORT CONFIG-FILE <ROUNDS> <MESSAGES-PER-ROUND>");
			System.exit(1);
		}

		// Create peer list
		PeerList peerList = new PeerList(filename, port);

		// Create node
		Node node = new  Node(peerList, port, messagesPerRound);
		node.initServer();

		System.out.println("Waiting for other nodes to join the system...");

		// Sleep to give time for others to join
		Tools.sleep(20);

		System.out.println("Beginning " + numberOfRounds + " rounds...");

		// For each round begin round
		for (int i=0; i<numberOfRounds; i++){
			node.beginRound();
			 
			// Print progress report for user
			if (i % 1000 == 0){
				System.out.println("Completed: " + i + "/" + numberOfRounds);
			}
		}

		node.thisNodeFinished = true;
		node.broadcastComplete();

		// Wait for stragglers
		while (true){
			synchronized (node.finishedLock) {
				if (node.thisNodeFinished && node.allNodesFinished){
					break;
				}
			}
		}

		// Print output
		node.printOutput();

		// Send results to all nodes
		node.broadcastResults();

	}