01Introduction to Network InterfaceIn the TCP/IP reference model, the network is divided into four layers: application layer, transport layer, network layer and network interface layer. The network interface layer corresponds to our actual network card. LWIP supports multi-port design. LWIP uses netif to describe the characteristics of each network interface, such as the IP address of the interface, interface status, etc. So if there are multiple network cards, how does LWIP organize these network cards? In LWIP, the linked list netif_list is used to manage many network cards. When the upper layer has data to send, LWIP will select a suitable network card from the netif_list linked list to send the data. 02netif structureThe netif structure is defined in the file netif.h. The meaning of each member variable in the netif structure is as follows: next : This field points to the next neitif type structure. Because LWIP can support multiple network interfaces, when the device has multiple network interfaces, LWIP will organize all netif structures into a linked list to manage these network interfaces. ipaddr, netmask and gw : the IP address, subnet mask and default gateway of the network interface respectively. input : This field is a function that passes the data received by the network card to the IP layer. output : This field is a function that is called when the IP layer sends a data packet to the interface. This function usually resolves the hardware address first and then sends the data packet. For this field, we generally use the etharp_output() function in etharp.c. linkoutput : This field is a function that is called by the ARP module to complete the transmission of network data. After the etharp_output function mentioned above encapsulates the IP data packet into an Ethernet data frame, it will call the linkoutput function to send the data out. state : used to define some information about the interface, which can be set by the user. mtu : The maximum data length that the network interface can transmit, usually set to 1500. hwaddr_len : Network card MAC address length, 6 bytes. hwaddr : MAC address. flags : Network interface status, attribute information field. name : The name of the network card. num : This field is a number set by the protocol stack for each network interface, starting from 0. The value of flags: in In network initialization, in ethernetif.c They all correspond to a function etharp_output : IP layer sends data packet function low_level_output : ARP module sending function, a lower-level function, in fact, etharp_output still calls this function 03 Related functions3.1、netif_add
That is, add the netif network interface to the network list queue and add a network card to the network card list 3.2, netif_set_default
Set this network card as the default network card 3.3, netif_set_up
Open the network card |
>>: Z-Wave not concerned about potential threats from Project CHIP
Megalayer is offering a 50% discount promotion fo...
Early morning news on January 11, for communicati...
Looking back at the communications industry this ...
TCP is one of the main protocols of the Internet ...
We are not unfamiliar with number portability. As...
Since 4G, the bandwidth of carriers has increased...
Recently, the three major operators released thei...
[[256146]] Hans Vestberg, CEO of Verizon, the lar...
The essence of penetration testing is information...
[September 11, 2017] On September 7, during HUAWE...
Deutsche Telekom (DT) said it has completed its f...
As a leading enterprise in China's private en...
Since the 1980s, mobile communications have seen ...
On February 25, 2025, Intel released two new Ethe...
According to the information currently available,...