A delay measurement method, comprising: receiving, by a first network device, a first service flow; and determining, by the first network device, a first delay value based on a first measurement code block in the first service flow, wherein the first delay value is a time difference between a first moment at which the first measurement code block is detected in the first network device and a second moment at which the first measurement code block is detected in the first network device, wherein the determining, by the first network device, a first delay value based on a first measurement code block in the first service flow comprises: when the first network device is a first network device in the transmission direction of the first service flow, setting, by the first network device, the first measurement code block in the first service flow; and when the first network device is not a first network device in the transmission direction of the first service flow, receiving, by the first network device, the first service flow comprising the first measurement code block, wherein the method further comprises: recording, by the first network device, the first moment when the first network device detects the first measurement code block in the first service flow when writing the measurement code block in the first service flow into a cache; recording, by the first network device, the second moment when the first network device detects the first measurement code block when reading the first service flow from the cache and detecting the measurement code block in the first service flow. receiving, by a first network device, a first service flow; and determining, by the first network device, a first delay value based on a first measurement code block in the first service flow, wherein the first delay value is a time difference between a first moment at which the first measurement code block is detected in the first network device and a second moment at which the first measurement code block is detected in the first network device, wherein the determining, by the first network device, a first delay value based on a first measurement code block in the first service flow comprises: when the first network device is a first network device in the transmission direction of the first service flow, setting, by the first network device, the first measurement code block in the first service flow; and when the first network device is not a first network device in the transmission direction of the first service flow, receiving, by the first network device, the first service flow comprising the first measurement code block, wherein the method further comprises: recording, by the first network device, the first moment when the first network device detects the first measurement code block in the first service flow when writing the measurement code block in the first service flow into a cache; recording, by the first network device, the second moment when the first network device detects the first measurement code block when reading the first service flow from the cache and detecting the measurement code block in the first service flow. when the first network device is a first network device in the transmission direction of the first service flow, setting, by the first network device, the first measurement code block in the first service flow; and when the first network device is not a first network device in the transmission direction of the first service flow, receiving, by the first network device, the first service flow comprising the first measurement code block, wherein the method further comprises: recording, by the first network device, the first moment when the first network device detects the first measurement code block in the first service flow when writing the measurement code block in the first service flow into a cache; recording, by the first network device, the second moment when the first network device detects the first measurement code block when reading the first service flow from the cache and detecting the measurement code block in the first service flow. recording, by the first network device, the first moment when the first network device detects the first measurement code block in the first service flow when writing the measurement code block in the first service flow into a cache; recording, by the first network device, the second moment when the first network device detects the first measurement code block when reading the first service flow from the cache and detecting the measurement code block in the first service flow.