Patent Description:
Internet protocol version <NUM> (Internet Protocol version <NUM>, IPv6) segment routing (Segment Routing IPv6, SRv6) is a protocol designed to forward IPv6 packets over a network based on a source routing concept. The protocol defines a forwarding path represented by a segment identifier list (segment list, SID list). An SID list includes a plurality of segment identifiers (segment identifier, SID), and each SID represents a node or link on a forwarding path. SIDs that are arranged in order in the SID list may represent nodes or links along the forwarding path. In an SRv6 network, a controller may calculate an SID list and deliver the SID list to a forwarding device in the network. The forwarding device also needs to report status or policy (policy) information of each SID in the SID list to the controller. Therefore, a message exchanged between the controller and the network forwarding device may need to carry the SID list. Further, the prior art document "<NPL>. , refers to compressed SRv6 network programming.

Also in the prior art, <CIT> discloses a method for forwarding packets in a network based on multiple compact forwarding identifiers represented in a single internet protocol version <NUM> (ipv6) address.

However, currently, the quantity of SID lists carried in a message exchanged between a controller and a headend is limited, and transmission efficiency is low; and when the quantity of SID lists is greater than the quantity of SID lists that can be carried in the message, an SID list may be truncated, and data may be lost, or an excessively long message may be not reported. Consequently, a message transmission failure occurs.

Embodiments of this application provide a message generation method, a message processing method, a message generation apparatus, and a message processing apparatus, so as to increase the quantity of SID lists that can be carried in a message, thereby improving efficiency and a success rate of message transmission. This problem is solved by the subject matter of the independent claims. Further implementation forms are provided in the dependent claims. According to a first aspect, an embodiment of this application provides a message generation method. The method includes the following steps: First, a first device obtains an SID list, where the SID list includes a plurality of SIDs, the first N bits of the plurality of SIDs are the same, and N is a positive integer. Next, the first device generates a first message based on the SID list, where the first message includes a first part and a second part, the first part includes the first N bits of the plurality of SIDs, and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs. Finally, the first device sends the first message to a second device, wherein the first message is a BGP update message. After receiving the first message, the second device may obtain each SID based on a common part of the plurality of SIDs in the first message, namely, the first N bits, and bit N+<NUM> to bit <NUM> of each SID. In this solution, the first message no longer carries <NUM> bits of each SID in the SID list, but removes a common part from a plurality of SIDs, and stores only the remaining part of each SID, so that the length of the SID list in the message is reduced, and the first message can carry a larger quantity of SID lists than a conventional manner, thereby improving efficiency and a success rate of message transmission.

The second part further includes a position indicator indicating a position of the first N bits of the plurality of SIDs in the first part, and the second device may obtain the first N bits of the plurality of SIDs based on the position indicator, and then obtain the SID list based on the first N bits of the plurality of SIDs and bit N+<NUM> to bit <NUM> of each of the plurality of SIDs, so that the second device obtains a complete SID list.

The first part further includes a length of the first N bits, so that the second device can accurately read the first N bits of the SIDs.

According to a second aspect, an embodiment of this application provides a message processing method. The method includes the following steps: First, a second device receives a first message from a first device, wherein the first message is a BGP update message and where the first message includes a first part and a second part, the first part includes the first N bits of a plurality of SIDs in an SID list, that is, a common part of the plurality of SIDs; and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs, and N is a positive integer. Next, the second device obtains the SID list based on the first part and the second part. Because the message stores only the remaining part of each SID other than the common part, a length occupied by the plurality of SIDs is reduced, so that the first message can carry a larger quantity of SID lists, thereby improving efficiency and a success rate of message transmission.

The second part further includes a position indicator indicating a position of the first N bits of the plurality of SIDs in the first part. Then, the second device may obtain the first N bits of the plurality of SIDs based on the position indicator of the first N bits of the plurality of SIDs in the first part, and the second device obtains the SID list based on the first N bits of the plurality of SIDs and bit N+<NUM> to bit <NUM> of each of the plurality of SIDs, so that the second device obtains a complete SID list.

According to a non-claimed third aspect, an embodiment of this application provides a message generation method
The method includes the following steps: First, a first device obtains an SID list identifier. Next, the first device generates a first message, where the first message includes an SID list identifier, where the SID list identifier is used to replace all SIDs in an SID list. Finally, the first device sends the first message to a second device. Because a length of the SID list identifier is less than a sum of lengths of all SIDs in the SID list, the first message can carry a larger quantity of SID lists, thereby improving efficiency and a success rate of message transmission.

Optionally, the method further includes: The first device sends a correspondence to the second device, where the correspondence includes a correspondence between the SID list and the SID list identifier, so that the second device can generate the SID list based on the correspondence and the first message.

According to a non-claimed fourth aspect, an embodiment of this application provides a message processing method. The method includes the following steps: First, a second device receives a first message from a first device, where the first message includes a segment identifier list SID list identifier. Next, the second device obtains an SID list based on the SID list identifier and a correspondence, where the correspondence includes a correspondence between the SID list and the SID list identifier. In the first message, the SID list identifier is used to replace all SIDs in the SID list, so that a length of the SID list is reduced. In addition, because the second device stores the correspondence between the SID list and the SID list identifier, the second device can obtain the SID list from the first message based on the correspondence, so that the SID list is successfully obtained.

Optionally, the method further includes: The second device receives a correspondence sent by the first device, where the correspondence includes a correspondence between an SID list and an SID list identifier, so that the second device can generate the SID list based on the correspondence and the first message.

According to a non-claimed fifth aspect, an embodiment of this application provides a message generation method
The method includes the following steps: First, a first device obtains a locator identifier corresponding to each SID in an SID list, where the locator identifier is used to identify a locator part of an SID corresponding to the locator identifier, and a length of the locator identifier is less than a length of the locator part. Next, the first device generates a first message, where the first message includes a locator identifier corresponding to each SID in the SID list and a function part of each SID. Finally, the first device sends the first message to a second device. Because the length of the locator identifier is less than the length of the locator part, a length of the SIDs in the first message is less than <NUM> bits, so that the length of the SID list is reduced. Therefore, the first message can carry a larger quantity of SID lists, thereby improving efficiency and a success rate of message transmission.

Optionally, the method further includes: The first device sends a correspondence to the second device, where the correspondence includes a correspondence between the locator identifier and the locator part of each SID, so that the second device obtains the SID list based on the correspondence and the first message.

According to a non-claimed sixth aspect, an embodiment of this application provides a message processing method. The method includes the following steps: First, a second device receives a first message from a first device, where the first message includes a locator identifier corresponding to each SID in an SID list and a function part of the SID, the locator identifier is used to identify a locator part of an SID corresponding to the locator identifier, and a length of the locator identifier is less than a length of the locator part. Next, the second device obtains the locator part of each SID based on the locator identifier corresponding to each SID and a correspondence, where the correspondence includes a correspondence between the locator identifier and the locator part of each SID. Finally, the second device obtains the SID list based on the locator part of each SID and a function part of each SID. Because a length of the locator identifier is less than a length of the locator part, the length of the SIDs carried in the first message is less than <NUM> bits. This increases the quantity of SID lists carried in the first message, thereby improving efficiency and a success rate of message transmission. In addition, the second device may determine the locator part of the SID corresponding to the locator identifier of the SID carried in the first message based on the correspondence between the locator identifier of the SID and the locator part of the SID, and combine the locator part with the function part in the first message to obtain the SID. In this way, the SID is successfully obtained, and then the SID list is obtained.

Optionally, the method further includes: The second device receives a correspondence from the first device, so as to obtain the SID list based on the correspondence and the first message.

With reference to the embodiments of the first aspect, the third aspect, and the fifth aspect, in a first possible implementation, the first device is a controller, and the second device is a network forwarding device. Then, the message generation method further includes the following step: The first device receives segment description information of at least one of a plurality of SIDs from the second device, where the segment description information is description information of a segment corresponding to the SID, such as information about an algorithm identifier corresponding to the segment. In a second possible implementation, the first device is a network forwarding device, and the second device is a controller. Then, the first message in the message generation method further includes segment description information of at least one of the plurality of SIDs.

With reference to the embodiments of the second aspect, the fourth aspect, and the sixth aspect, in a first possible implementation, the first device is a controller, and the second device is a network forwarding device. Then, the first message in the message generation method further includes segment description information of at least one of the plurality of SIDs. In a second possible implementation, the first device is a network forwarding device, and the second device is a controller. Then, the message generation method further includes the following step: The first device receives segment description information of at least one of a plurality of SIDs from the second device, where the segment description information is description information of a segment corresponding to the SID, such as information about an algorithm identifier corresponding to the segment.

According to a seventh aspect, an embodiment of this application provides a message generation apparatus. The apparatus is applied to a first device, and the apparatus includes: an acquisition unit, configured to obtain a segment identifier list SID list, where the SID list includes a plurality of segment identifiers SIDs, the first N bits of the plurality of SIDs are the same, and N is a positive integer; a generation unit, configured to generate a first message based on the SID list, where the first message is a BGP update message and includes a first part and a second part, the first part includes the first N bits of the plurality of SIDs, and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs; and a sending unit, configured to send the first message to a second device.

The second part further includes a position indicator indicating a position of the first N bits of the plurality of SIDs in the first part.

The first part further includes a length of the first N bits.

According to an eighth aspect, an embodiment of this application provides a message processing apparatus. The apparatus is applied to a second device, and the apparatus includes: a receiving unit, configured to receive a first message from a first device wherein the first message is a BGP update message and, where the first message is used to carry a segment identifier list SID list, the SID list includes a plurality of segment identifiers SIDs, the first N bits of the plurality of SIDs are the same, N is a positive integer, the first message includes a first part and a second part, the first part includes the first N bits of the plurality of SIDs in the segment identifier list SID list, and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs; and an acquisition unit, configured to obtain the SID list based on the first part and the second part.

The second part further includes a position indicator of the first N bits of the plurality of SIDs in the first part; and
the acquisition unit is configured to: obtain the first N bits of the plurality of SIDs based on the position indicator of the first N bits of the plurality of SIDs in the first part; and obtain the SID list based on the first N bits of the plurality of SIDs and bit N+<NUM> to bit <NUM> of each of the plurality of SIDs.

According to a non-claimed ninth aspect, an embodiment of this application provides a message generation apparatus. The apparatus is applied to a first device, and the apparatus includes: an acquisition unit, configured to obtain a segment identifier list SID list identifier, where the SID list identifier corresponds to an SID list; a generation unit, configured to generate a first message, where the first message includes the SID list identifier; and a sending unit, configured to send the first message to a second device.

Optionally, the sending unit is further configured to send a correspondence to the second device, where the correspondence includes a correspondence between the SID list and the SID list identifier.

According to a non-claimed tenth aspect, an embodiment of this application provides a message processing apparatus. The apparatus is applied to a second device, and the apparatus includes: a receiving unit, configured to receive a first message from a first device, where the first message includes a segment identifier list SID list identifier, and the SID list identifier corresponds to an SID list; and an acquisition unit, configured to obtain the SID list based on the SID list identifier and a correspondence, where the correspondence includes a correspondence between the SID list and the SID list identifier.

Optionally, the receiving unit is further configured to receive a correspondence from the first device.

According to a non-claimed eleventh aspect, an embodiment of this application provides a message generation apparatus. The apparatus is applied to a first device, and the apparatus includes: an acquisition unit, configured to obtain a locator identifier corresponding to each segment identifier SID in a segment identifier list SID list, where the locator identifier is used to identify a locator part of an SID corresponding to the locator identifier, and a length of the locator identifier is less than a length of the locator part;
a generation unit, configured to generate a first message, where the first message includes a locator identifier corresponding to each SID in the SID list and a function part of each SID; and a sending unit, configured to send the first message to a second device.

Optionally, the sending unit is further configured to send a correspondence to the second device, where the correspondence includes a correspondence between the locator identifier and the locator part of each SID.

According to a non-claimed twelfth aspect, an embodiment of this application provides a message processing apparatus. The apparatus is applied to a second device, and the apparatus includes: a receiving unit, configured to receive a first message from a first device, where the first message includes a locator identifier corresponding to each segment identifier SID in a segment identifier list SID list and a function part of the SID, the locator identifier is used to identify a locator part of an SID corresponding to the locator identifier, and a length of the locator identifier is less than a length of the locator part; a determining unit, configured to obtain the locator part of each SID based on the locator identifier corresponding to each SID and a correspondence, where the correspondence includes a correspondence between the locator identifier and the locator part of each SID; and an acquisition unit, configured to obtain the SID list based on the locator part of each SID and the function part of each SID.

With reference to the embodiments of the seventh aspect, the ninth aspect, and the eleventh aspect, in a first possible implementation, the first device is a controller, and the second device is a network forwarding device. Then, the message generation apparatus further includes a receiving unit, configured to receive segment description information of at least one of a plurality of SIDs from the second device, where the segment description information is description information of a segment corresponding to the SID, such as information about an algorithm identifier corresponding to the segment. In a second possible implementation, the first device is a network forwarding device, and the second device is a controller. Then, the first message in the message generation apparatus further includes segment description information of at least one of the plurality of SIDs.

With reference to the embodiments of the eighth aspect, the tenth aspect, and the twelfth aspect, in a first possible implementation, the first device is a controller, and the second device is a network forwarding device. Then, the first message in the message generation apparatus further includes segment description information of at least one of the plurality of SIDs. In a second possible implementation, the first device is a network forwarding device, and the second device is a controller. Then, the receiving unit in the message generation apparatus is further configured to receive segment description information of at least one of a plurality of SIDs from the second device, where the segment description information is description information of a segment corresponding to the SID, such as information about an algorithm identifier corresponding to the segment.

The first message is a border gateway protocol (Border Gateway Protocol, BGP) update message (update message).

According to a thirteenth aspect, an embodiment of this application provides a message processing device. The device includes: a processor and a memory, where the memory is configured to store an instruction; and the processor is configured to execute the instruction in the memory, so as to perform the foregoing message generation method or message processing method.

According to a fourteenth aspect, an embodiment of this application provides a computer-readable storage medium, where the computer-readable storage medium includes an instruction, and when instruction is run on a computer, the computer is enabled to perform the foregoing message generation method or message processing method.

<FIG> is a schematic diagram of a format of a type-length-value (type-length-value, TLV) field carrying an SID list in a conventional message. The TLV field includes four sub TLV (sub TLV) fields (the four sub TLV fields are distinguished in <FIG> by color depth), where the first sub TLV field is of type <NUM>, indicating that the sub TLV field is a sub TLV related to an SR segment list; and the last three sub TLV fields are of type <NUM>, indicating that the sub TLV fields are sub TLVs related to an SR segment.

The first sub TLV field further includes a length (Length) field, a flags (Flags) field, a reserved (Reserved) field, a multi-topology identifier (multi-topology identifier, MTID) field, an algorithm (Algorithm) field, and a weight (Weight) field. The first sub TLV field occupies a total of <NUM> bytes. The flags field carries attribute information and/or status information of a segment list, for example, whether a path corresponding to an SID list is an explicit path or a dynamic path, or whether all SIDs in an SID list belong to a specific algorithm.

Each of the last three sub TLV fields further includes a length (Length) field, a reserved (Reserved) field, a flags (Flags) field, an SID field, and a segment descriptor (Segment Descriptor) field. Each sub TLV field occupies <NUM> bytes. The flags field carries attribute information and/or status information of a segment, for example, whether an SID is verified.

In a conventional message, an SID field carries an IPv6 address of a network forwarding device, which is a total of <NUM> bits. The SID field generally includes a locator (Locator) field and a function (Function) field. For example, for an SID with an IPv6 address of "<NUM>::<NUM>::<NUM>", the locator field may carry "<NUM>::<NUM>", and the function field may carry "::<NUM>".

A Locator is an IPv6 network segment under which all IPv6 addresses can be assigned as SRv6 SIDs. After a node configures the Locator, a system generates a Locator network segment route, through which the local node can be located, and all SIDs published by the local node can be reached through the Locator network segment route.

Currently, RFC <NUM> specifies that a length of a border gateway protocol message is <NUM> bytes. Then, when an SID list includes <NUM> SIDs, if other content of the TLV of the SID list and content of the segment descriptor field in the SID list are not considered, a length of the SID list is <NUM> x <NUM> + <NUM> = <NUM> bytes, and the message can carry a maximum of <NUM>/<NUM>≈<NUM> SID lists (it is assumed that the SID lists are of the same length). When more than <NUM> SID lists need to be carried, data exceeding <NUM> bytes needs to be truncated. Consequently, data loss occurs, or the message is too long to be sent, resulting in a message transmission failure.

To resolve the foregoing technical problem, embodiments of this application provide a message generation method and a message processing method, so as to increase the quantity of SID lists that can be carried in a message, and increase a success rate of message transmission.

For ease of understanding, the following first describes an application scenario of the embodiments of this application.

<FIG> is a schematic structural diagram of a network system <NUM> according to an embodiment of this application.

The network system <NUM> shown in <FIG> includes a terminal device <NUM>, a terminal device <NUM>, a network forwarding device <NUM>, a network forwarding device <NUM>, a network forwarding device <NUM>, a network forwarding device <NUM>, and a controller <NUM>. The terminal device <NUM> is connected to the network forwarding device <NUM>; the network forwarding device <NUM> is connected to the network forwarding device <NUM>; the network forwarding device <NUM> is connected to the network forwarding device <NUM>; the network forwarding device <NUM> is connected to the terminal device <NUM>; the network forwarding device <NUM> is connected to the network forwarding device <NUM>, the network forwarding device <NUM>, and the network forwarding device <NUM>; and the controller <NUM> is connected to the network forwarding device <NUM>.

Each of the terminal device <NUM> and the terminal device <NUM> may also be referred to as user equipment (user equipment, UE), a mobile station (mobile station, MS), a mobile terminal (mobile terminal, MT), a terminal, or the like, and is a device for providing voice and/or data connectivity to a user, or a chip disposed in the device, for example, a handheld device or a vehicle-mounted device having a wireless connection function. Currently, some examples of the terminal device include a mobile phone, a desktop computer, a tablet computer, a notebook computer, a palmtop computer, a mobile internet device (mobile internet device, MID), a wearable device, a virtual reality (virtual reality, VR) device, an augmented reality (augmented reality, AR) device, a wireless terminal in industrial control (industrial control), a wireless terminal in self driving (self driving), a wireless terminal in remote medical surgery (remote medical surgery), a wireless terminal in a smart grid (smart grid), a wireless terminal in transportation safety (transportation safety), a wireless terminal in a smart city (smart city), a wireless terminal in a smart home (smart home), and a home gateway device supporting <NUM> access (<NUM>-residential gateway, <NUM>-RG).

Each of the network forwarding device <NUM>, the network forwarding device <NUM>, and the network forwarding device <NUM> may be a forwarding device such as a router (router) or a switch (switch).

The network forwarding device <NUM> is, for example, a route reflector (Route Reflector, RR).

The controller <NUM> may be, for example, a software-defined networking (Software Defined Network, SDN) controller.

In this embodiment of this application, the controller <NUM> may obtain topology information of the network forwarding device <NUM>, the network forwarding device <NUM>, and the network forwarding device <NUM> by using the network forwarding device <NUM>, generate an SID list indicating a forwarding path based on the topology information, and send a first BGP update message to the network forwarding device <NUM> by using the network forwarding device <NUM>, where the first BGP update message carries the information indicating the SID list, and SIDs included in the SID list represent the network forwarding device <NUM>, the network forwarding device <NUM>, and the network forwarding device <NUM>, respectively, and the SID list is used to transmit a message to the terminal device <NUM> for the terminal device <NUM>.

After receiving the first BGP update message, the network forwarding device <NUM> forwards the message based on a path indicated by the SID list in the first BGP update message.

In addition, the network forwarding device <NUM> may generate a second BGP update message, and send the message to the controller by using the network forwarding device <NUM>, where the second BGP update message carries information representing an SID list and segment description information, and the segment description information may be carried in the segment descriptor field of the second BGP update message. The segment description information may include, for example, information about an algorithm identifier, where the algorithm identifier may be used to perform network fragmentation. The segment description information may also include, for example, information about a network forwarding device and/or status information of a tunnel between network forwarding devices, where the information about a network forwarding device includes, for example, a BGP router identifier (BGP router ID), an autonomous system number (Autonomous System Number), and an endpoint (Endpoint). The status information of a tunnel is information indicating a status of the tunnel, for example, an active (UP) state, or a failed (Down) state.

The network forwarding device <NUM> may transparently transmit the BGP update message between the controller <NUM> and the network forwarding device <NUM>, or may parse a received BGP update message and then generate a new BGP update message for sending. A parsing process includes converting a message representing an SID list in the BGP update message to the SID list. A process of generating a new BGP update message includes converting an SID list to a message representing the SID list.

Certainly, it can be understood that in actual application, the network system <NUM> may not include the network forwarding device <NUM>; that is, the controller is directly connected to the network forwarding device <NUM> to the network forwarding device <NUM>. For example, the controller <NUM> may obtain topology information of the network forwarding device <NUM>, the network forwarding device <NUM>, and the network forwarding device <NUM> directly without using the network forwarding device <NUM>.

<FIG> is a schematic flowchart of a message generation method according to an embodiment of this application.

The following describes the message generation method provided in this embodiment of this application with reference to <FIG> and <FIG>. The method includes the following steps:.

S101: A first device obtains an SID list, where the SID list includes a plurality of SIDs, and the first N bits of the plurality of SIDs are the same.

In this embodiment of this application, the first device may be, for example, the controller <NUM> in the embodiment shown in <FIG>, and a second device mentioned below may be, for example, the network forwarding device <NUM> in the embodiment shown in <FIG>. Alternatively, the first device may be, for example, the network forwarding device <NUM> in the embodiment shown in <FIG>, and the second device mentioned below may be the controller <NUM> in the embodiment shown in <FIG>. Alternatively, the first device may be, for example, the network forwarding device <NUM> in the embodiment shown in <FIG>, and the second device may be, for example, the network forwarding device <NUM> in the embodiment shown in <FIG>. Alternatively, the first device may be, for example, the network forwarding device <NUM> in the embodiment shown in <FIG>, and the second device may be, for example, the network forwarding device <NUM> in the embodiment shown in <FIG>.

In this embodiment of this application, an SID includes a locator part and a function part, and the locator part and the function part occupy a total of <NUM> bits. The first N bits are counted from the first bit of the locator part of the SID, and N is an integer greater than or equal to <NUM> and less than <NUM>. In this embodiment of this application, the first N bits of an SID refer to content of the first N bits of the SID.

In this embodiment of this application, the first device obtains an SID list, where the first N bits of all of the plurality of SIDs included in the SID list are the same.

For example, Table <NUM> shows a plurality of SIDs included in the SID list obtained by the first device.

In Table <NUM>, SID list1 includes SID1, SID2, and SID3, where SID1 is "<NUM>::<NUM>::<NUM>", SID2 is "<NUM>::<NUM>::<NUM>", and SID3 is "<NUM>::<NUM>::<NUM>". The first <NUM> bits of the three SIDs are the same and are "<NUM>::".

In Table <NUM>, SID list2 includes SID4 and SID5, where SID4 is "<NUM>::<NUM>::<NUM>", and SID5 is "<NUM>::<NUM>::<NUM>". The first <NUM> bits of the two SIDs are the same and are "<NUM>::".

It should be noted that, that the first N bits of the plurality of SIDs are the same does not mean that bits N+<NUM> of the plurality of SIDs are different. That is, it is assumed that the first M bits of the plurality of SIDs are the same but bits M+<NUM> of the plurality of SIDs are different. Then, N is greater than or equal to <NUM> and less than or equal to M.

S102: The first device generates a first message based on the SID list, where the first message includes a first part and a second part, the first part includes the first N bits of the plurality of SIDs, and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs.

In this embodiment of this application, bit N+<NUM> to bit <NUM> of an SID refer to content of bit N+<NUM> to bit <NUM> of the SID.

In this embodiment of this application, the first message is, for example, the first BGP update message or the second BGP update message in the embodiment shown in <FIG>. The first part and the second part in the first message may be one of the foregoing implementations of representing an SID list.

<FIG> is a schematic diagram of a TLV carrying an SID list in a BGP update message according to an embodiment of this application.

In <FIG>, the first N bits of the plurality of SIDs are carried in the locator field as a common part of the plurality of SIDs, and are placed before the SID list. Certainly, it can be understood that the common part may alternatively be placed at another position in the first message. This is not specifically limited in this application. The remaining parts of the plurality of SIDs, that is, bit N+<NUM> to bit <NUM>, are carried in the function (Func for short) field of each sub TLV. It can also be understood that the foregoing locator field and Func field are not intended to limit names of fields carrying the first part and the second part, and persons skilled in the art may also design the locator field and the Func field based on an actual situation. If the first message carries a plurality of SID lists, the common parts of all of the plurality of SID lists may be placed together, for example, be placed before the first SID list, or the common part of each SID list may be placed before the respective SID list, and so on. This is not specifically limited in this embodiment of this application.

In this embodiment of this application, the first part (marked in light gray in <FIG>) may include a length of the first N bits in addition to the first N bits of a plurality of SIDs. For example, in <FIG>, the length of the first N bits is carried in a prefix length (Prefix Length) field and is placed before an SID list together with a locator field. Each locator field corresponds to one prefix length field. Certainly, the name and position of the prefix length field are not intended to limit the technical solution of this application, and persons skilled in the art may also design the prefix length field based on an actual situation.

In this embodiment of this application, the second part (marked in dark gray in <FIG>) may include a position indicator in addition to the remaining part of each of the plurality of SIDs, where the position indicator indicates the position of the first N bits of the plurality of SIDs in the first message. For example, in <FIG>, the position indicator is carried in a Locator Position (LocatorPos for short) field of the sub TLV of each SID, and each locator field corresponds to one LocatorPos field. It can be understood that the name and position of the LocatorPos field in <FIG> are not intended to limit the technical solution of this application, and persons skilled in the art may design the LocatorPos field based on an actual situation.

With reference to Table <NUM> and <FIG>, the first message may include two locator fields: a locator field <NUM> and a locator field <NUM>, where the locator field <NUM> carries the first N bits of "<NUM>::" of SID list1, and locator field <NUM> carries the first N bits of "<NUM>::" of SID list2. A value of a prefix length field corresponding to the locator field <NUM> is <NUM>, and a value of a prefix length field corresponding to the locator field <NUM> is <NUM>.

A value of the LocatorPos field included in SID1 in SID list1 is <NUM>, which indicates a position of the locator field <NUM>; and a value of the Func field included in SID1 is "<NUM>:<NUM>".

A value of the LocatorPos field included in SID2 in SID list1 is <NUM>, which indicates a position of the locator field <NUM>; and a value of the Func field included in SID1 is "<NUM>:<NUM>".

A value of the LocatorPos field included in SID3 in SID list1 is <NUM>, which indicates a position of the locator field <NUM>; and a value of the Func field included in SID1 is "<NUM>:<NUM>".

A value of the LocatorPos field included in SID4 in SID list2 is <NUM>, which indicates a position of the locator field <NUM>; and a value of the Func field included in SID1 is "::<NUM>::<NUM>".

A value of the LocatorPos field included in SID5 in SID list2 is <NUM>, which indicates a position of the locator field <NUM>; and a value of the Func field included in SID1 is "::<NUM>::<NUM>".

S103: The first device sends the first message to the second device.

S104: The second device receives the first message, and obtains the SID list based on the first part and the second part of the first message.

In this embodiment of this application, because the first part includes the first N bits of the plurality of SIDs in the SID list, and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs, each of the plurality of SIDs may be obtained by combining the first N bits and bit N+<NUM> to bit <NUM>. After obtaining the plurality of SIDs included in the SID list, the SID list is generated based on a sequence of the plurality of SIDs in the first message.

If the second part further includes the position indicator of the first N bits of the plurality of SIDs in the first part, the second device may obtain the first N bits of the plurality of SIDs based on the position indicator, then obtain the plurality of SIDs based on the first N bits of the plurality of SIDs and bit N+<NUM> to bit <NUM> of each of the plurality of SIDs, and then obtain the SID list based on the sequence of the plurality of SIDs in the first message.

For example, the first device may obtain the value "<NUM>::" of the locator field <NUM> based on the value "<NUM>" of the LocatorPos field included in SID1, and obtain the value "<NUM>::<NUM>::<NUM>" of SID1 by combining content of the locator field and content of the Func field based on the value "<NUM>::<NUM>" of the Func field included in SID1.

For another example, the first device obtains the value "<NUM>::" of the locator field <NUM> based on the value "<NUM>" of the LocatorPos field included in SID3, and obtains the value "<NUM>::<NUM>::<NUM>" of SID3 by combining content of the locator field and content of the Func field based on the value "::<NUM>::<NUM>" of the Func field included in SID3.

In this embodiment of this application, the first N bits of the plurality of SIDs are extracted and separately carried in a field as a common part. This differs from a conventional manner in which each SID includes <NUM> bits, so that a length occupied by the SID list in the first message is reduced as compared with the conventional manner, and the first message can carry a larger quantity of SID lists than in the conventional manner, thereby improving efficiency and a success rate of message transmission.

For example, it is assumed that one SID list includes <NUM> SIDs, the first <NUM> bytes (that is, <NUM> bits) of all SIDs are the same, and the last byte of each SID is different from the last byte of any other SID. The prefix length field occupies one byte, and then, the length of the SID list is <NUM> x <NUM> + <NUM> + <NUM> + <NUM> = <NUM> bytes; and a message with a message length of <NUM> bytes can carry a maximum of <NUM>/<NUM>≈<NUM> SID lists (it is assumed that all SID lists are of the same length). As mentioned above, only a maximum of <NUM> SID lists can be carried in the conventional manner. Therefore, the first message in this embodiment of this application can carry a larger quantity of SID lists than in the conventional manner, thereby improving efficiency of message transmission, reducing a risk that the message is truncated or not sent, and improving a success rate of message transmission.

<FIG> is another flowchart of a message generation method according to an embodiment of this application.

The following describes the message generation method provided in this embodiment of this application with reference to <FIG> and <FIG>. The method includes the following steps:
S201: A first device obtains an SID list identifier.

When the first device is a controller, the first device may generate a corresponding identifier for the SID list. When the first device is a network forwarding device, the controller may deliver a correspondence between the SID list and the SID list identifier to the network forwarding device in advance, so that the network forwarding device obtains the SID list identifier.

For example, Table <NUM> shows correspondences between an SID list and an SID list identifier.

In Table <NUM>, an SID list identifier A is an SID list identifier including SID1, SID2, and SID3; and an SID list identifier B is an SID list identifier including SID4 and SID5.

In this embodiment of this application, the SID list identifier may be a character, a number, or the like. This is not specifically limited in this embodiment of this application.

S202: The first device generates a first message, where the first message includes the SID list identifier.

In this embodiment of this application, the first message is, for example, the first BGP update message or the second BGP update message in the embodiment shown in <FIG>.

<FIG> is a schematic diagram of a TLV carrying an SID list identifier (ID) in a BGP update message according to an embodiment of this application.

In <FIG>, the TLV includes an SID list ID field, where the SID list ID field may occupy four bytes. Each SID list ID field may be placed before a sub TLV that is used to carry the segment descriptor field of each SID included in the SID list, so as to indicate that the sub TLV corresponding to the SID list ID carried in the SID list ID field is placed after the SID list ID field. Correspondingly, the sub TLV in <FIG> reduces the quantity of SID fields carrying the SID, and therefore the quantity of bytes of the entire SID list is reduced. Certainly, it can be understood that <FIG> does not limit the position of the SID list ID field in the first message; and persons skilled in the art may also design the position of SID list ID field based on an actual situation.

With reference to Table <NUM> and <FIG>, the first message may include two SID list ID fields: an SID list ID field <NUM> and an SID list ID field <NUM>. The SID list ID field <NUM> carries an SID list identifier A; and the SID list ID field <NUM> carries an SID list identifier B. The SID list identifier A includes three sub TLVs, where the three sub TLVs include the segment descriptor fields of SID1, SID2, and SID3, respectively. The SID list identifier B includes two sub TLVs, where the two sub TLVs include the segment descriptor fields of SID4 and SID5, respectively. Each SID list ID field may be placed before or after the corresponding sub TLV in the first message. This is not specifically limited in this embodiment of this application.

It should be noted that the sub TLVs corresponding to the SID lists may be arranged in the order of the SIDs in the SID lists, so that the second device can accurately find a sub TLV corresponding to an SID.

S203: The first device sends a first message to the second device.

S204: The second device receives the first message from the first device.

S205: The second device obtains the SID list based on the SID list identifier and a correspondence, where the correspondence includes a correspondence between the SID list and the SID list identifier.

In this embodiment of this application, the second device obtains the correspondence between the SID list and the SID list identifier in advance, and obtains the SID list based on the SID list identifier and the correspondence after receiving the first message.

For example, the second device obtains an SID list including SID1, SID2 and SID3 based on Table <NUM> and the SID list identifier A in the SID list ID field <NUM> in the first message. After obtaining the SID list, the second device may obtain the sub TLVs corresponding to the SID list identifier A in the first message, so as to extract values of the segment descriptor fields from the sub TLVs. Because the sub TLVs corresponding to the SID list identifier A are arranged in the order of the SIDs in SID list1, the values of the segment descriptor fields extracted by the first device from all sub TLVs based on the order of the sub TLVs can correspond to the SIDs included in the SID list.

In this embodiment of this application, because the SID list identifier is used to replace a plurality of SIDs included in the SID list, the length of the SID list identifier is less than the length of the plurality of SIDs included in the SID list, so that the length of the SID list is reduced, and the first message can carry a larger quantity of SID lists.

For example, it is assumed that one SID list includes <NUM> SIDs, and the SID list ID field in the first message occupies four bytes. Then, the length of the SID list is <NUM> x <NUM> + <NUM> + <NUM> = <NUM> bytes, and a message with a message length of <NUM> bytes can carry a maximum of <NUM>/<NUM>≈<NUM> SID lists (it is assumed that the SID lists are of the same length). As mentioned above, only a maximum of <NUM> SID lists can be carried in the conventional manner. Therefore, the first message in this embodiment of this application can carry a larger quantity of SID lists than in the conventional manner, thereby reducing a risk that the message is truncated or not sent, and improving efficiency and a success rate of message transmission.

The following describes the message generation method provided in this embodiment of this application with reference to <FIG> and <FIG>. The method includes the following steps:
S301: A first device obtains a locator identifier corresponding to each SID in an SID list, where a length of the locator identifier is less than a length of a locator.

In this embodiment of this application, the locator identifier is used to identify the locator part of an SID in the SID list.

In this embodiment of this application, when the first device is a controller, the first device may generate a corresponding identifier for the locator part of an SID, or may obtain the locator identifier assigned by the network forwarding device corresponding to the SID. In the latter case, each network forwarding device pre-assigns its own locator identifier, then sends a correspondence between the locator part and the locator identifier to a headend (in <FIG>, the headend is the network forwarding device <NUM>) through flooding; and then the headend reports the received correspondence between the locator part and the locator identifier from each network forwarding device to the controller. Alternatively, each network forwarding device may directly send the correspondence between its own locator part and the locator identifier to the controller.

When the first device is a network forwarding device, the first device may receive the correspondence between the locator identifier and the locator part of the SID that are pre-configured for each network forwarding device, or may receive the correspondence delivered by the controller. This is not specifically limited in this embodiment of this application.

Table <NUM> shows an example of the correspondence between the locator part and the locator identifier (ID).

In this embodiment of this application, the locator identifier may be a character, a number, or the like. This is not specifically limited in this embodiment of this application.

S302: The first device generates a first message, where the first message includes a locator identifier and a function part corresponding to each SID in the SID list.

In this embodiment of this application, the first device may generate the first message after obtaining the locator identifier of the SID included in the SID list. The first message may include a first field and a second field, where the first field carries the locator identifier of the SID, and the second field carries the function part of the SID.

<FIG> is a schematic diagram of a TLV carrying an SID list in a BGP update message according to an embodiment of this application. In <FIG>, the first field is a locator ID field (marked in light gray in <FIG>), which occupies four bytes; and the second field is a function (func) field (marked in dark gray in <FIG>).

With reference to Table <NUM> and <FIG>, a value of the locator ID field included in a sub TLV corresponding to SID1 is <NUM>, and a value of the func field is "::<NUM>"; a value of the locator ID field included in a sub TLV corresponding to SID2 is <NUM>, and a value of the func field is "::<NUM>"; and a value of the locator ID field included in a sub TLV corresponding to SID3 is <NUM>, and a value of the func field is "::<NUM>".

S303: The first device sends the first message to the second device.

S304: The second device receives the first message from the first device.

S305: The second device obtains the locator part of each SID based on the locator identifier corresponding to each SID and a correspondence.

S306: The second device obtains the SID list based on the locator part of each SID and the function part of each SID.

After obtaining the locator part and the function part of an SID, the SID can be obtained by placing the function part after the locator part.

For example, the second device obtains "<NUM>::<NUM>" of the locator part based on Table <NUM> and the value "<NUM>" of the locator ID field corresponding to SID1 in the first message, and then obtains "<NUM>::<NUM>::<NUM>" of SID1 based on the value "::<NUM>" of the func field corresponding to SID1; the second device obtains "<NUM>::<NUM>" of the locator part based on Table <NUM> and the value "<NUM>" of the locator ID field corresponding to SID2 in the first message, and then obtains "<NUM>::<NUM>::<NUM>" of SID2 based on the value "::<NUM>" of the func field corresponding to SID1; and the second device obtains "<NUM>::<NUM>" of the locator part based on Table <NUM> and the value "<NUM>" of the locator ID field corresponding to SID3 in the first message, and then obtains "<NUM>::<NUM>::<NUM>" of SID3 based on the value "::<NUM>" of the func field corresponding to SID3.

In this embodiment of this application, because the length of the locator identifier is less than the length of the locator part, the length of the SID list is reduced, and the first message may carry a larger quantity of SID lists than in the conventional manner, thereby improving transmission efficiency.

For example, it is assumed that one SID list includes <NUM> SIDs, the locator part of each SID occupies <NUM> bytes, and the function part of each SID occupies one byte. If the locator part of each SID is replaced by a locator ID that occupies only four bytes, the length of one SID list is <NUM> x <NUM> + <NUM> = <NUM> bytes; and a message with a message length of <NUM> bytes can carry a maximum of <NUM>/<NUM>≈<NUM> SID lists (it is assumed that the SID lists are of the same length). As mentioned above, only a maximum of <NUM> SID lists can be carried in the conventional manner. Therefore, the first message in this embodiment of this application can carry a larger quantity of SID lists than in the conventional manner, thereby reducing a risk that the message is truncated or not sent, and improving a success rate of message transmission.

Correspondingly, referring to <FIG>, an embodiment of this application further provides a message generation apparatus <NUM>. The apparatus <NUM> is configured to implement functions of the first device in the embodiment shown in <FIG>. The apparatus <NUM> includes an acquisition unit <NUM>, a generation unit <NUM>, and a sending unit <NUM>, where the acquisition unit <NUM> is configured to perform S101 in the embodiment shown in <FIG>; the generation unit <NUM> is configured to perform S102 in the embodiment shown in <FIG>; and the sending unit <NUM> is configured to perform S103 in the embodiment shown in <FIG>.

The acquisition unit <NUM> is configured to obtain a segment identifier list SID list, where the SID list includes a plurality of segment identifiers SIDs, the first N bits of the plurality of SIDs are the same, and N is a positive integer.

The generation unit <NUM> is configured to generate a first message based on the SID list, where the first message includes a first part and a second part, the first part includes the first N bits of the plurality of SIDs, and the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs.

The sending unit <NUM> is configured to send the first message to a second device.

For related content of the message generation apparatus <NUM> provided in this embodiment of this application, reference may be made to the description of the first device in the embodiment shown in <FIG>, and details are not described herein again.

Referring to <FIG>, an embodiment of this application provides a message processing apparatus <NUM>. The apparatus <NUM> is configured to implement functions of the second device in the embodiment shown in <FIG>. The apparatus <NUM> includes a receiving unit <NUM> and an acquisition unit <NUM>, where the receiving unit <NUM> and the acquisition unit <NUM> are configured to perform S104 in the embodiment shown in <FIG>.

The receiving unit <NUM> is configured to receive a first message from a first device, where the first message is used to carry a segment identifier list SID list, the SID list includes a plurality of segment identifiers SIDs, the first N bits of the plurality of SIDs are the same, the first message includes a first part and a second part, the first part includes the first N bits of the plurality of SIDs in the SID list, the second part includes bit N+<NUM> to bit <NUM> of each of the plurality of SIDs.

The acquisition unit <NUM> is configured to obtain the SID list based on the first part and the second part.

For related content of the message generation apparatus <NUM> provided in this embodiment of this application, reference may be made to the description of the second device in the embodiment shown in <FIG>, and details are not described herein again.

Referring to <FIG>, an embodiment of this application provides a message generation apparatus <NUM>. The apparatus <NUM> is configured to implement functions of the first device in the embodiment shown in <FIG>. The apparatus <NUM> includes an acquisition unit <NUM>, a generation unit <NUM>, and a sending unit <NUM>, where the acquisition unit <NUM> is configured to perform S201 in the embodiment shown in <FIG>; the generation unit <NUM> is configured to perform S202 in the embodiment shown in <FIG>; and the sending unit <NUM> is configured to perform S203 in the embodiment shown in <FIG>.

The acquisition unit <NUM> is configured to obtain a segment identifier list SID list identifier, where the SID list identifier corresponds to an SID list.

The generation unit <NUM> is configured to generate a first message, where the first message includes the SID list identifier.

Referring to <FIG>, an embodiment of this application provides a message processing apparatus <NUM>. The apparatus <NUM> is configured to implement functions of the second device in the embodiment shown in <FIG>. The apparatus <NUM> includes a receiving unit <NUM> and an acquisition unit <NUM>, where the receiving unit <NUM> is configured to perform S204 in the embodiment shown in <FIG>; and the acquisition unit <NUM> is configured to perform S205 in the embodiment shown in <FIG>.

The receiving unit <NUM> is configured to receive a first message from a first device, where the first message includes a segment identifier list SID list identifier, and the SID list identifier corresponds to an SID list.

The acquisition unit <NUM> is configured to obtain the SID list based on the SID list identifier and a correspondence, where the correspondence includes a correspondence between the SID list and the SID list identifier.

Referring to <FIG>, an embodiment of this application provides a message generation apparatus <NUM>, where the apparatus <NUM> is configured to implement functions of the first device in the embodiment shown in <FIG>. The apparatus <NUM> includes an acquisition unit <NUM>, a generation unit <NUM>, and a sending unit <NUM>, where the acquisition unit <NUM> is configured to perform S301 in the embodiment shown in <FIG>; the generation unit <NUM> is configured to perform S302 in the embodiment shown in <FIG>; and the sending unit <NUM> is configured to perform S303 in the embodiment shown in <FIG>.

The acquisition unit <NUM> is configured to obtain a locator identifier corresponding to each segment identifier SID in a segment identifier list SID list, where the locator identifier is used to identify a locator part of an SID corresponding to the locator identifier, and a length of the locator identifier is less than a length of the locator part.

The generation unit <NUM> is configured to generate a first message, where the first message includes a locator identifier corresponding to each SID in the SID list and a function part of each SID.

Referring to <FIG>, an embodiment of this application provides a message processing apparatus <NUM>. The apparatus <NUM> is configured to implement functions of the second device in the embodiment shown in <FIG>. The apparatus <NUM> includes a receiving unit <NUM>, a determining unit <NUM>, and an acquisition unit <NUM>, where the receiving unit <NUM> is configured to perform S304 in the embodiment shown in <FIG>; the determining unit <NUM> is configured to perform S305 in the embodiment shown in <FIG>; and the acquisition unit <NUM> is configured to perform S306 in the embodiment shown in <FIG>.

The receiving unit <NUM> is configured to receive a first message from a first device, where the first message includes a locator identifier corresponding to each segment identifier SID in a segment identifier list SID list and a function part of the SID, the locator identifier is used to identify a locator part of an SID corresponding to the locator identifier, and a length of the locator identifier is less than a length of the locator part.

The determining unit <NUM> is configured to obtain the locator part of each SID based on the locator identifier corresponding to each SID and a correspondence, where the correspondence includes a correspondence between the locator identifier and the locator part of each SID.

The acquisition unit <NUM> is configured to obtain the SID list based on the locator part of each SID and the function part of each SID.

It should be noted that a hardware structure of a message generation device corresponding to the message generation apparatus <NUM>, the message generation apparatus <NUM>, and the message generation apparatus <NUM>, and a hardware structure of a message processing device corresponding to the message processing apparatus <NUM>, the message processing apparatus <NUM>, and the message processing apparatus <NUM> may be both the structure shown in <FIG> is a schematic structural diagram of a device according to an embodiment of this application.

As shown in <FIG>, the device <NUM> includes a processor <NUM>, a communications interface <NUM>, and a memory <NUM>. The device <NUM> may include one or more processors <NUM>. In <FIG>, one processor is used as an example. In this embodiment of this application, the processor <NUM>, the communications interface <NUM>, and the memory <NUM> may be connected using a bus system or another method. In <FIG>, a connection based on a bus system <NUM> is used as an example.

The processor <NUM> may be a central processing unit (central processing unit, CPU), a network processor (network processor, NP), or a combination of a CPU and an NP. The processor <NUM> may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (application-specific integrated circuit, ASIC), a programmable logic device (programmable logic device, PLD), or a combination thereof. The PLD may be a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a generic array logic (generic array logic, GAL), or any combination thereof.

The memory <NUM> may include a volatile memory (English: volatile memory), such as a random-access memory (random-access memory, RAM). The memory <NUM> may also include a non-volatile memory (English: non-volatile memory), such as a flash memory (English: flash memory), a hard disk drive (hard disk drive, HDD), or a solid-state drive (solid-state drive, SSD). The memory <NUM> may also include a combination of memories of the foregoing types.

Optionally, the memory <NUM> stores an operating system and a program, an executable module or a data structure, or a subset thereof, or an extended set thereof, where the program may include various operation instructions for implementing various operations. The operating system may include various system programs for implementing various basic services and processing hardware-based tasks. The processor <NUM> may read the program in the memory <NUM> to implement the message generation method or the message processing method provided in the embodiments of this application.

The bus system <NUM> may be a peripheral component interconnect (peripheral component interconnect, PCI) bus, an extended industry standard architecture (extended industry standard architecture, EISA) bus, or the like. The bus system <NUM> may be classified into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used to represent the bus in <FIG>, but this does not mean that there is only one bus or only one type of bus.

An embodiment of this application further provides a message generation system, where the system includes a first device and a second device. The first device in the system may perform processing steps of the first device in the embodiment shown in <FIG>, or correspondingly, the first device in the system is the message generation apparatus <NUM> in the embodiment shown in <FIG>. The second device in the system may perform processing steps of the second device in the embodiment shown in <FIG>, or correspondingly, the second device in the system is the message processing apparatus <NUM> in the embodiment shown in <FIG>.

An embodiment of this application further provides a computer-readable storage medium, where the computer-readable storage medium includes an instruction, and when the instruction is run on a computer, the computer is enabled to perform the message generation method that is provided in the foregoing method embodiments and that is performed by the first device.

An embodiment of this application further provides a computer-readable storage medium, where the computer-readable storage medium includes an instruction, and when the instruction is run on a computer, the computer is enabled to perform the message processing method that is provided in the foregoing method embodiments and that is performed by the second device.

An embodiment of this application further provides a computer program product including an instruction, where when the computer program product runs on a computer, the computer is enabled to perform the message generation method that is provided in the foregoing method embodiments and that is performed by the first device.

An embodiment of this application further provides a computer program product including an instruction, where when the computer program product runs on a computer, the computer is enabled to perform the message processing method that is provided in the foregoing method embodiments and that is performed by the second device.

In the specification, claims, and accompanying drawings of this application, the terms "first", "second", "third", "fourth", and so on (if existent) are intended to distinguish between similar objects but do not necessarily indicate a specific order or sequence. It should be understood that the data termed in such a way are interchangeable in proper circumstances so that the embodiments of the present invention described herein can be implemented in other orders than the order illustrated or described herein. In addition, the terms "include", "contain" and any other variants mean to cover the non-exclusive inclusion, for example, a process, method, system, product, or device that includes a list of steps or units is not necessarily limited to those units, but may include other units not expressly listed or inherent to such a process, method, system, product, or device.

In this application, "at least one" means one or more, and "a plurality of" means two or more. "At least one of the following" or a similar expression thereof indicates any combination of the following, and includes any combination of one or more of the following. For example, at least one of a, b, or c may indicate: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c may indicate a singular or plural form. In this application, "A and/or B" is considered to include A alone, B alone, and A+B.

It may be clearly understood by persons skilled in the art that, for the purpose of convenient and brief description, for a detailed working process of the foregoing system, apparatus, and unit, reference may be made to a corresponding process in the foregoing method embodiments, and details are not described herein again.

When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, the integrated unit may be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of this application essentially, or the part contributing to the prior art, or all or some of the technical solutions may be implemented in the form of a software product. The software product is stored in a storage medium and includes several instructions for instructing a computer device (which may include a personal computer, a server, or a network device) to perform all or some of the steps of the methods described in the embodiments of this application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk, or an optical disc.

Persons skilled in the art should be aware that in the foregoing one or more examples, functions described in the present invention may be implemented by hardware, software, firmware, or any combination thereof. When the present invention is implemented by software, the foregoing functions may be stored in a computer-readable medium or transmitted as one or more instructions or code in the computer-readable medium. The computer-readable medium includes a computer storage medium and a communications medium, where the communications medium includes any medium that enables a computer program to be transmitted from one place to another. The storage medium may be any available medium accessible to a general-purpose or dedicated computer.

Claim 1:
A message generation method performed by a first device, wherein the method comprises:
• obtaining (S <NUM>) a segment identifier list, SID list, wherein the SID list comprises a plurality of segment identifiers, SIDs, the length of each SID being <NUM> bit, wherein the first N bits of the plurality of SIDs are the same, and N is a positive integer;
• generating (S <NUM>) a first message based on the SID list, wherein the first message is a border gateway protocol, BGP, update message and comprises a first part and a second part, the first part comprises the first N bits of the plurality of SIDs, and the second part comprises bit N+<NUM> to bit <NUM> of each of the plurality of SIDs,
wherein the second part further comprises a position indicator indicating a position of the first N bits of the plurality of SIDs in the first part,
and wherein the first part further comprises a length of the first N bits; and
• sending (S <NUM>) the first message to a second device to enable the second device to obtain the SID list based on the first part and the second part.