#P10346. [THUSC 2019] 数据链路层协议数据处理
[THUSC 2019] 数据链路层协议数据处理
Background
The lowest layer that router software needs to handle is the data link layer. On top of it runs a series of complex protocols, such as various mysterious sliding window protocols. Although Pengpeng never really understands them, he knows that the most important protocol at this layer is ARP. It serves as a bridge across the upper and lower layers: only through an ARP query can a router know which neighbor it should send an IP packet to. Your router software needs to respond enthusiastically to every query in order to correctly receive the subsequent traffic.
Problem Description
Based on the relevant knowledge in the “Study Manual”, you need to process protocol data at the data link layer. In the given traffic fragments, some are ARP queries for you (that is, the queried IP, the TPA field, belongs to you; please find the IP address you own and the corresponding MAC address in the pcap statement). You must reply to them correctly. The data guarantees that, in ARP requests with correct FCS checksums, the sender’s MAC address (SHA field) matches the sender’s MAC address in the Ethernet frame. Note that the destination address of the Ethernet frame in an ARP request may be different from the MAC address you own (such as the broadcast address FF:FF:FF:FF:FF:FF); in this case, you still need to respond to the ARP request. You need to construct the correct ARP protocol data, as well as the outer Ethernet frame format (including the header and checksum, and also note the Ethernet frame length requirements), and then write these Ethernet frames, in the order of replies, into the output file in PCAP format as required by the “Study Manual”.
In all of the following problems (including this one), if a traffic fragment fails checksum verification, it should be discarded directly. The fragment data may not match what is described in the “Study Manual”, so you must not make any assumptions and should not process it in any way.
Input Format
The input is guaranteed to be in a valid format. It contains at most traffic fragments, with a total size of at most bytes. You need to reply to traffic fragments.
Output Format
It will be compared byte by byte with the answer file.
Hint
【Subtasks】
| Test Point | |||
|---|---|---|---|
| 1 | Yes | ||
| 2 | No | ||
| 3 | |||
| 4 | |||
| 5 |
【Sample Explanation 1】
Since providing samples would greatly reduce the difficulty of this problem, no samples are provided.
Translated by ChatGPT 5