<> data link layer —— Ethernet protocol
<> Section 1 shut : Analysis of Ethernet frame
Task description
Supplementary code , Parsing received Ethernet frames , According to the type of outgoing frame , Call the corresponding processing function .
The Ethernet frame byte stream given in this task does not include the previous 7 Byte synchronization code ,1 Byte frame start delimiter and subsequent 4 Byte check code .
task 1: Completion function
unsigned char* get_eth_dst_addr(unsigned char eth);
Enter a pointer to the first byte of the frame , Request return purpose MAC First address of .
task 2: Completion function
unsigned char get_eth_src_addr(unsigned char eth);
Enter a pointer to the first byte of the frame , Request to return to source MAC First address of .
task 3: Completion function
void eth_dispatch(unsigned char eth);
Enter a pointer to the first byte of the frame , Request to return to source MAC First address of . It is required to parse the type field in the frame , The frame encapsulation is determined according to the type coding IP,ARP Or other protocol packages . Note that the network byte order may be different from the local byte training . already IP The frame type code corresponding to the protocol is 0x0800,ARP The frame type corresponding to the protocol is 0x0806.
Ethernet is the simplest network protocol , Mastering the method of Ethernet frame parsing is very helpful for subsequent parsing of other protocol packages .
In order to complete the task of this level , You need to master : Ethernet protocol syntax and semantics .
Technology