public void run() {
    	
        while (true) {
            try {
                sleep(100);
            } catch (InterruptedException except) { }
            
            for (SwitchPort port: this.ports) {
            	//Check incoming packets only on connected ports
            	if (port.getIPAddress() == null) continue;

	            //Get incoming bytes
		    	byte[] packet = port.getIncomingPacket();

		    	//If no packet received, ignore this loop
		    	if (packet == null) continue;
		
				try {
					//Extract the destination ip address of the packet
			    	byte[] dst_address = extractData(packet, 4, 4);
					InetAddress ipAddress = InetAddress.getByAddress(dst_address);
					
					//Get port number associated with the ip address
					Integer port_no = table.get(ipAddress);

					//Port number not found in table, try find port
					if (port_no == null) {
						manualScan(packet, ipAddress);
						return;
					}
					
					//Send packet through the specific port
					ports[port_no].sendToComputer(packet);
					
					
				} catch (UnknownHostException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	
	        }
        }
    }