Implement sendPacket function