A traffic scheduling method, wherein the traffic scheduling method is applied to time-sensitive networking, TSN, using a fully distributed model, the TSN comprises a first network device, a talker device, and a listener device, the first network device, the talker device, and the listener device are configured to transmit a data stream, and the method comprises: receiving, by the first network device, a first talker attribute message sent by the talker device, wherein the first talker attribute message comprises a port identifier of the talker device and traffic scheduling enabling information, the traffic scheduling enabling information indicates to request the first network device to allocate first traffic scheduling information of a first data stream, the port identifier of the talker device is used to indicate an egress port of the first data stream, and a first destination media access control, MAC, address comprised in the first talker attribute message is a MAC address of the first network device; receiving (S 102), by the first network device, a listener attribute message sent by the listener device, wherein the listener attribute message is used to indicate that the listener device is a receiving end of the first data stream, the listener attribute message comprises a port identifier of the listener device, and the port identifier of the listener device is used to indicate an ingress port of the first data stream; determining, by the first network device, the first traffic scheduling information and a transmission path of the first data stream based on the first talker attribute message and the listener attribute message; and sending, by the first network device, a first traffic scheduling message to a network device on the transmission path, wherein the first traffic scheduling message comprises the first traffic scheduling information, the first traffic scheduling information indicates the network device on the transmission path to generate a gate control list, and the gate control list indicates the network device on the transmission path to control, based on the gate control list, a state of a port used to transmit the first data stream, wherein the first traffic scheduling information further comprises a start time of a period of the gate control list and a gate state of the gate control list, and the first traffic scheduling information further comprises at least two pieces of the following information: a quantity of timeslots in each period of the gate control list, a length of the period of the gate control list, and a length of a timeslot of the gate control list. receiving, by the first network device, a first talker attribute message sent by the talker device, wherein the first talker attribute message comprises a port identifier of the talker device and traffic scheduling enabling information, the traffic scheduling enabling information indicates to request the first network device to allocate first traffic scheduling information of a first data stream, the port identifier of the talker device is used to indicate an egress port of the first data stream, and a first destination media access control, MAC, address comprised in the first talker attribute message is a MAC address of the first network device; receiving (S 102), by the first network device, a listener attribute message sent by the listener device, wherein the listener attribute message is used to indicate that the listener device is a receiving end of the first data stream, the listener attribute message comprises a port identifier of the listener device, and the port identifier of the listener device is used to indicate an ingress port of the first data stream; determining, by the first network device, the first traffic scheduling information and a transmission path of the first data stream based on the first talker attribute message and the listener attribute message; and sending, by the first network device, a first traffic scheduling message to a network device on the transmission path, wherein the first traffic scheduling message comprises the first traffic scheduling information, the first traffic scheduling information indicates the network device on the transmission path to generate a gate control list, and the gate control list indicates the network device on the transmission path to control, based on the gate control list, a state of a port used to transmit the first data stream, wherein the first traffic scheduling information further comprises a start time of a period of the gate control list and a gate state of the gate control list, and the first traffic scheduling information further comprises at least two pieces of the following information: a quantity of timeslots in each period of the gate control list, a length of the period of the gate control list, and a length of a timeslot of the gate control list.