A communication method, comprising: obtaining , by a first network device, first link layer topology information corresponding to a first network slice; obtaining , by the first network device, second link layer topology information corresponding to a second network slice; determining , by the first network device based on the first link layer topology information and the second link layer topology information, that a link layer topology of the second network slice is comprised in a link layer topology of the first network slice; receiving , by the first network device, network layer topology information that is of the first network slice and that is sent by a second network device; and determining , by the first network device, network layer topology information of the second network slice based on the second link layer topology information and the network layer topology information of the first network slice, wherein the determining, by the first network device based on the first link layer topology information and the second link layer topology information, that a link layer topology of the second network slice is comprised in a link layer topology of the first network slice comprises: when M interfaces of the second link layer topology and M interfaces of the first link layer topology are separately located on M physical interfaces, determining that the link layer topology of the second network slice is comprised in the link layer topology of the first network slice, wherein a quantity of all interfaces of the second link layer topology is M, a quantity of all interfaces of the first link layer topology is N, M is less than or equal to N, and M and N are positive integers. obtaining , by a first network device, first link layer topology information corresponding to a first network slice; obtaining , by the first network device, second link layer topology information corresponding to a second network slice; determining , by the first network device based on the first link layer topology information and the second link layer topology information, that a link layer topology of the second network slice is comprised in a link layer topology of the first network slice; receiving , by the first network device, network layer topology information that is of the first network slice and that is sent by a second network device; and determining , by the first network device, network layer topology information of the second network slice based on the second link layer topology information and the network layer topology information of the first network slice, wherein the determining, by the first network device based on the first link layer topology information and the second link layer topology information, that a link layer topology of the second network slice is comprised in a link layer topology of the first network slice comprises: when M interfaces of the second link layer topology and M interfaces of the first link layer topology are separately located on M physical interfaces, determining that the link layer topology of the second network slice is comprised in the link layer topology of the first network slice, wherein a quantity of all interfaces of the second link layer topology is M, a quantity of all interfaces of the first link layer topology is N, M is less than or equal to N, and M and N are positive integers. <EOS>