private void handlePacket() throws IOException {
		DatagramPacket recvPacket = receivePacket();
		byte[] data = recvPacket.getData();
				
		String src = translateIP(data, 12);
		
		System.out.println("\nReceived packet from " + src);
		
		int data_length = (int) (((data[2] << 8) | (data[3] & 0xFF)) & 0xFFFF);

		// Validates the checksums
		validateChecksumIP(data, 0, 20);
		
		int protocol = (int) (data[9] & 0xFF);
		final int UDP = 17;
		final int ICMP = 1;
		
		if (protocol == UDP) {
			System.out.println("IPv4 Protocol 17: UDP");
			validateChecksumUDP(data, 20, data_length);
		} else if (protocol == ICMP) {
			System.out.println("IPv4 Protocol 1: ICMP");
			validateChecksumICMP(data, 20, 56);
		}
		
		String dest = translateIP(data, 16);
		
		/* Checks if the destination is this router */
		for (InetAddress addr : routerAddresses) {

			if (addr.getHostAddress().equals(dest)) {
				printMessage(data, data_length, src);
				return;
			}
		}
		
		InetAddress realDstIP = findMatch(dest);
		
		/* If no prefix match was found, the sender must be notified. */
		if (realDstIP == null) {
			System.out.println("No prefix match for: " + dest);
			sendICMP(ICMP_Header.UNREACHABLE, data, src);
			return;
		}
		
		System.out.println("Found prexif for " + dest + " -> " + 
				realDstIP.getHostAddress());
		
		int TTL = (int) (data[8] & 0xFF);
		
		/* Check if the TTL has expired*/
		if (TTL <= 0) { 
			System.out.println("TTL Expired");
			sendICMP(ICMP_Header.TIME_EXCEEDED, data, src);
			return;
		}
		
		// Decrements the TTL
		TTL--;
		data[8] = (byte) TTL;		
		
		// Updates the checksum
		int newChecksum = IP_Header.calculateChecksum(data, 0, 20);
		data[10] = (byte) (newChecksum >>> 8);
		data[11] = (byte) (newChecksum);
		
		DatagramPacket sendPkt = new DatagramPacket(data, data_length, 
				realDstIP, PORT);
		
		/* Forwards the packet */
		routerSocket.send(sendPkt);
		
		System.out.println("Sent message to " + realDstIP.getHostAddress());
	}