A neighborhood aware network, Wi-Fi NAN,-based device connection performed by a first device that supports a neighborhood aware network protocol, wherein the method comprises: receiving a first broadcast message from a second device , wherein the first broadcast message comprises connected device information of the second device and Wi-Fi connection information of the second device, the connected device information is used to represent a device to which the second device is connected through Wi-Fi, and the Wi-Fi connection information refers to information that is used to determine whether the second device has a quantity of available Wi-Fi connections; receiving a second broadcast message from a third device , wherein the second broadcast message comprises Wi-Fi connection information of the third device; determining that the second device is a target device , wherein the target device is a device to which the first device is intended to connect through Wi-Fi; when the quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not a device to which the first device is connected through Wi-Fi, determining, based on the connected device information of the second device and the Wi-Fi connection information of the third device, that the third device belongs to the device to which the second device is connected through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero , wherein the quantity of available Wi-Fi connections of the second device is determined based on the Wi-Fi connection information of the second device; sending a Wi-Fi link establishment request to the third device, to establish a Wi-Fi link between the first device and the third device ; and sending , to the third device through the Wi-Fi link between the first device and the third device, a first packet whose destination is the second device, so that the third device forwards the first packet to the second device through a Wi-Fi link between the third device and the second device. receiving a first broadcast message from a second device , wherein the first broadcast message comprises connected device information of the second device and Wi-Fi connection information of the second device, the connected device information is used to represent a device to which the second device is connected through Wi-Fi, and the Wi-Fi connection information refers to information that is used to determine whether the second device has a quantity of available Wi-Fi connections; receiving a second broadcast message from a third device , wherein the second broadcast message comprises Wi-Fi connection information of the third device; determining that the second device is a target device , wherein the target device is a device to which the first device is intended to connect through Wi-Fi; when the quantity of available Wi-Fi connections of the second device is not greater than zero, and the second device is not a device to which the first device is connected through Wi-Fi, determining, based on the connected device information of the second device and the Wi-Fi connection information of the third device, that the third device belongs to the device to which the second device is connected through Wi-Fi and that a quantity of available Wi-Fi connections of the third device is greater than zero , wherein the quantity of available Wi-Fi connections of the second device is determined based on the Wi-Fi connection information of the second device; sending a Wi-Fi link establishment request to the third device, to establish a Wi-Fi link between the first device and the third device ; and sending , to the third device through the Wi-Fi link between the first device and the third device, a first packet whose destination is the second device, so that the third device forwards the first packet to the second device through a Wi-Fi link between the third device and the second device. <EOS>