#P10345. [THUSC 2019] 常见网络校验和计算

[THUSC 2019] 常见网络校验和计算

Background

Pengpeng found that the network quality in the Yulan Student Dormitory of Huaqing University did not seem very good. Due to the quality of the network cables, or maybe because some students were doing some strange experiments, he always received some abnormal content. Luckily, the designers of network protocols had considered this and added checksums in the protocols to detect some obvious problems. As robust router software, it must only accept traffic that passes checksum checks and drop the bad ones. It is said that you can already read the content of the traffic; the next step is to find these abnormal traffic fragments.

Problem Description

You need to verify the given traffic fragments based on the relevant knowledge in the “Study Manual”. Note that since all fragment types are Ethernet frames, you always need to compute CRC32; and for traffic that carries IP packets, you also need to check the checksum of the IP packet header. For simplicity, we do not consider any checksum fields other than those of Ethernet and IP. Only when all checks pass is the traffic fragment considered correct.

Input Format

The input is guaranteed to be well-formed, and each traffic fragment is an Ethernet frame. It contains no more than nn traffic fragments, with a total size of no more than mm bytes. In the testdata of some subtasks, the checksum of the IP packet header is guaranteed to be correct, meaning that you only need to compute the CRC32 of the Ethernet frame.

Output Format

The output consists of nn lines of text, corresponding to the verification result of each fragment in order. If it is correct, output Yes; otherwise output No.

Hint

[Subtasks]

Test Point nn mm Only need to check Ethernet frames
1 =102=10^2 =5×104=5\times 10^4 Yes
2 =1.5×105=1.5\times 10^5 No
3 =103=10^3 =1.5×106=1.5\times 10^6
4 =104=10^4 =1.5×107=1.5\times 10^7
5 =105=10^5 =1.5×108=1.5\times 10^8

[Sample 1]

See the attached files 1.in/ans.

[Sample Explanation 1]

Just like in the pcap problem, you can use the Wireshark software installed on your computer to open the sample input and output data.

The sample input file should contain four Ethernet frames. In the first Ethernet frame, both the FCS and the IP checksum are wrong. The second Ethernet frame is an ARP frame with a correct FCS. The third Ethernet frame has only an incorrect FCS. The fourth Ethernet frame has only an incorrect IP checksum. You can expand the analysis of the current frame in the middle of the page to see more details, including which checksum is wrong and the correct value, etc. This may help you.

By default, Wireshark may not validate whether the FCS is correct. In this case, you can find the line containing Ethernet II in the middle of the page and right-click it. In the pop-up menu, select Protocol Preferences, and check the options Validate the Ethernet checksum if possible and Assume packets have FCS. Then you should be able to see in the top part of the page that frames with FCS errors are clearly marked.

Note that Wireshark will also compute and display whether the UDP Checksum is correct. In this problem, we do not consider the UDP Checksum, so you can ignore those errors.

Translated by ChatGPT 5