A method for implementing a Mux machine, wherein the method is applied to a network running the link aggregation control protocol, LACP, the network comprises a first network device and a second network device, a first aggregation port of the first network device is connected to a second aggregation port of the second network device over an aggregated link, and the method comprises: setting, by the first network device, the first aggregation port to a collecting and distributing state when the first network device determines that a Mux machine of the first aggregation port is in a COLLECTING_DISTRIBUTING state, wherein the COLLECTING_DISTRIBUTING state is used to indicate that the first aggregation port is allowed to receive and send data packets; starting, by the first network device, a timer, and determining, before the timer expires, whether a first link aggregation control protocol data unit, LACPDU, packet from the second network device is received, wherein the first LACPDU packet is used to indicate that the second aggregation port is in the collecting and distributing state; and switching, by the first network device, the Mux machine from the COLLECTING_DISTRIBUTING state to an ATTACHED state if the first network device determines, when the timer expires, that the first LACPDU packet from the second network device is not received, wherein the ATTACHED state is used to indicate that the first aggregation port stops receiving and sending data packets; switching, by the first network device, the Mux machine from the COLLECTING_DISTRIBUTING state to a Double-port_COLLECTING_DISTRIBUTING state when the first network device determines, before the timer expires, that the first LACPDU packet from the second network device is received, wherein the Double-port_COLLECTING_DISTRIBUTING state is used to indicate that both the first aggregation port and the second aggregation port are in the collecting and distributing state; wherein the Mux machine of the first aggregation port is in the ATTACHED state before being in the COLLECTING_DISTRIBUTING state, and the method further comprises: receiving, by the first network device, a second LACPDU packet from the second network device; and switching, by the first network device, the Mux machine from the ATTACHED state to the COLLECTING_DISTRIBUTING state when the first network device determines that the first aggregation port is in a selected state, determines, based on the second LACPDU packet, that the second aggregation port is in a synchronization state, and determines, based on the second LACPDU packet, that the second aggregation port is not in the collecting and distributing state. setting, by the first network device, the first aggregation port to a collecting and distributing state when the first network device determines that a Mux machine of the first aggregation port is in a COLLECTING_DISTRIBUTING state, wherein the COLLECTING_DISTRIBUTING state is used to indicate that the first aggregation port is allowed to receive and send data packets; starting, by the first network device, a timer, and determining, before the timer expires, whether a first link aggregation control protocol data unit, LACPDU, packet from the second network device is received, wherein the first LACPDU packet is used to indicate that the second aggregation port is in the collecting and distributing state; and switching, by the first network device, the Mux machine from the COLLECTING_DISTRIBUTING state to an ATTACHED state if the first network device determines, when the timer expires, that the first LACPDU packet from the second network device is not received, wherein the ATTACHED state is used to indicate that the first aggregation port stops receiving and sending data packets; switching, by the first network device, the Mux machine from the COLLECTING_DISTRIBUTING state to a Double-port_COLLECTING_DISTRIBUTING state when the first network device determines, before the timer expires, that the first LACPDU packet from the second network device is received, wherein the Double-port_COLLECTING_DISTRIBUTING state is used to indicate that both the first aggregation port and the second aggregation port are in the collecting and distributing state; wherein the Mux machine of the first aggregation port is in the ATTACHED state before being in the COLLECTING_DISTRIBUTING state, and the method further comprises: receiving, by the first network device, a second LACPDU packet from the second network device; and switching, by the first network device, the Mux machine from the ATTACHED state to the COLLECTING_DISTRIBUTING state when the first network device determines that the first aggregation port is in a selected state, determines, based on the second LACPDU packet, that the second aggregation port is in a synchronization state, and determines, based on the second LACPDU packet, that the second aggregation port is not in the collecting and distributing state. receiving, by the first network device, a second LACPDU packet from the second network device; and switching, by the first network device, the Mux machine from the ATTACHED state to the COLLECTING_DISTRIBUTING state when the first network device determines that the first aggregation port is in a selected state, determines, based on the second LACPDU packet, that the second aggregation port is in a synchronization state, and determines, based on the second LACPDU packet, that the second aggregation port is not in the collecting and distributing state.