public static void test() throws Exception {

		// #########################################################################################
		System.out.println("Testing packet serialization:");
		/**
		 * Foreach packet class, create an instance, serialize it and
		 * unserialize it. Packet class and a random sequence number must be
		 * correct in addition to some specific data
		 */
		int i = 0;
		while (true) {
			// Packet send
			Packet packetSend = Packet.getPacketById((byte) i);

			if (packetSend == null) {
				break;
			}

			// Fill package
			packetSend.setSequenceNumber(13);
			packetSend.setSender((byte)127);
			packetSend.setAddress((byte)1);

			// Packet specific data
			if (packetSend instanceof KeepAlivePacket) {
				((KeepAlivePacket) packetSend).setData(KeepAlivePacket.PONG);
			} else if (packetSend instanceof DataPacket) {
				byte[] b = { 0, 1, 2, 3, 4, 5, 0, 42 };
				((DataPacket) packetSend).setData(b);
			}
			
			else if (packetSend instanceof UnicastDataPacket) {
				byte[] hops = {1,2,3,4};
				((UnicastDataPacket) packetSend).setRoute(new Route((byte)1, hops));
				byte[] b = { 0, 1, 2, 3, 4, 5, 0, 42 };
				((UnicastDataPacket) packetSend).setData(b);
			}
			else if (packetSend instanceof RouteContainerPacket) {
				byte[] hops = {1,2,3,4};
				((RouteContainerPacket) packetSend).setRoute(new Route((byte)1, hops));
			}
			
			if (packetSend instanceof RREPPacket) {
				byte[] hops = {1,2,3,4, 5, 6};
				((RREPPacket) packetSend).setRequestedRoute(new Route((byte)1, hops));
			}

			// serialization
			byte[] b = packetSend.serialize();

			// dump packet
			System.out.println("Packet " + packetSend.getClass() + ": " + bytesToHex(b));
			System.out.println("\t= "+ packetSend.toString());

			// Packet receive
			Packet packetReceive = Packet.getPacket(b);

			// Test if received packet equals send packet
			if (b.equals(packetReceive.serialize())) {
				throw new Exception("ERROR: Packet received: " + bytesToHex(packetReceive.serialize()));
			}
			i++;
		}

		// #########################################################################################

	}