Presentation is loading. Please wait.

Presentation is loading. Please wait.

LWIP TCP/IP Stack 김백규.

Similar presentations


Presentation on theme: "LWIP TCP/IP Stack 김백규."— Presentation transcript:

1 LWIP TCP/IP Stack 김백규

2 What is LWIP? An implementation of the TCP/IP protocol stack.
The focus of the lwIP stack is to reduce memory usage and code size suitable for embedded systems. uses a tailor made API that does not require any data copying.

3 Features of TCP/IP stack (Traditional version)
Designing in a layered fashion leads to… communication overhead between layers Network communication is similar to IPC or file I/O APP can’t aware of the buffer mechanisms. (e.g. reuse buffers with frequently used data.) <Layered model>

4 Features of TCP/IP stack (LWIP version)
Do not maintain a strict layer. More relaxed scheme for communication between layers. (By means of shared memory) APP layer can use the buffer handling mechanisms used by the lower layers. APP can more efficiently reuse buffers. Application process can use the same memory as the networking code App can read and write directly to the internal buffers. Saving the expense of performing a copy

5 Process model of LWIP All protocols reside in a single process thus are separated from the OS kernel. Allow to be portable across different OS. APP may either reside in the LWIP process or be in separate processes. Communicate are done by function calls. Or a more abstract API.

6 The operating system emulation layers
OS specific function calls and data structures are not used directly in the code. The operating system emulation layer is used. The OS emulation layer provides Timers, process synchronization, message passing mechanisms, and so on. Porting to a different OS Only need the operating system emulation layer.

7 Buffer and memory management
Packet buffers – pbufs LWIP’s internal representation of a packet, Designed for the special needs of the minimal stack. Types of pbufs PBUF_RAM, PBUF_ROM, PBUF_POOL A pbuf chain may consist of multiple types of pbufs.

8 PBUF_RAM pbuf has the packet data stored in memory managed by the pbuf subsystem. used when an application sends data that is dynamically generated.

9 PBUF_ROM pbuf Used when an application sends data that is located in memory managed by the application. The main use is when the data is located in ROM Header that are prepended to the data in a PBUF_ROM pbuf are stored in a PBUF_RAM pbuf.

10 PBUF_POOL Consist of fixed size pbufs allocated from a pool of fixed size pbufs. Mainly used by network device drivers since the operation of allocating a single pbuf is fast and is therefore suitable for use in an interrupt handler

11 The network interfaces are kept on a global linked list.
Reflect the kind of H/W Ex) Bluetooth => bt WLAN => wl The function the device driver should call when a packet has been received. The function in the device driver that transmits a packet on the physical network and it is called by the IP layer when a packet is to be sent. Points to device driver specific state for the network interface and is set by the device driver.

12 IP processing(1/3) Receiving packets Sending packets
Network device driver calls ip_input() function. Checking IP version, header length Computing the header checksum Checking destination address. Sending packets Handled by the function ip_output() Find the appropriate network interface. All IP header fields are filled. IP header checksum is computed. The source and destination address are passed.

13 IP processing(2/3) Forwarding packets The packet should be forwarded…
When none of the network interfaces has the same IP address as an incoming packet’s destination address. This is done by the function ip_forward() ttl field is decreased. If ttl reaches zero, an ICMP error message is sent.

14 IP processing(3/3) ICMP processing
This is for ICMP ECHO message. Just swapping the IP destination and source address of the incoming packet.

15 Called when a datagram is received.
UDP processing(1/2) The udp_pcb structure The UDP PCBs are kept on a linked list which is searched for a match when a UDP datagram arrives. Called when a datagram is received.

16 UDP processing(2/2) UDP processing

17 TCP processing(1/2) Function to call when a listener has been connected. Next sequence number Receiver’s window Timer for TIME-WAIT state Used when passing received data to the application layer.

18 TCP processing(2/2)

19 Application Program Interface
The BSD socket API Require data that is to be sent to be copied from application program to internal buffers in the TCP/IP stack. Since the two layers reside in different protection domains. The LWIP socket API Utilizes knowledge of the internal structure of LWIP to achieve effectiveness. Does not require that data is copied. Since the application program can manipulate the internal buffers directly.


Download ppt "LWIP TCP/IP Stack 김백규."

Similar presentations


Ads by Google