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
【51CTO.com Quick Translation】CIOs of leading comp...
Digital reading has unlimited potential [[400428]...
HostKvm is a foreign hosting service provider fou...
In order to promote the further development of Ci...
The attacks on the large-scale construction of 5G...
[[402903]] 1. Trends in enterprise-level wireless...
In order to thoroughly implement the spirit of th...
Overnight, 5G changed the world. First, Qualcomm ...
While 5G and 6G networks could help first respond...
BuyVM is a long-established foreign VPS hosting c...
StarryDNS is a hosting company registered in Hong...
April 26 is the 17th World Intellectual Property ...
[[387481]] Editor's note: The operators who p...
With the increase in data analysis, media traffic...
[[321085]] Recently, new infrastructure has conti...