Skip to content

Latest commit

 

History

History
102 lines (79 loc) · 5.11 KB

File metadata and controls

102 lines (79 loc) · 5.11 KB

wolfIP

Stack architecture

  • No dynamic allocation (pre-allocated sockets and buffers)
  • Four-steps main loop function
  • Callback-based socket interface (allows implementing blocking BSD calls)

Data structures

  • Two types of circular buffers (fixed size):

    • "fifo" : contains entire frames, including a descriptor.
    • "queue" : contains pure data, indexed by byte. Used for TCP receive buffer only.
  • One binary heap for timers

wolfIP fifo

+---------------------------------------------------------------------------------------------------------------------------+
|               +-----+---+----+-----+------------------+-----+---+----+-----+------------------+                           |
|               | De  | E | IP | TCP |      Payload     | De  | E | IP | TCP |      Payload     |                           |
|               | sc  | T |    |     |                  | sc  | T |    |     |                  |                           |
|* FREE SPACE * | ri  | H |    |     |                  | ri  | H |    |     |                  |   * FREE SPACE*           |
|               | pt  |   |    |     |                  | pt  |   |    |     |                  |                           |
|               | or  |   |    |     |                  | or  |   |    |     |                  |                           |
|               +-----+---+----+-----+------------------+-----+---+----+-----+------------------+                           |
+---------------------------------------------------------------------------------------------------------------------------+
                ^                                                                               ^
                |                                                                               |
                |                                                                               |
                |                                                                               |
                |Tail                                                                       Head|

wolfIP queue

 +--------------+--------------------------------------------+---------------------------------------------------------------+
 |              |*------------------------------------------*|                                                               |
 |              ||                                          ||                                                               |
 |              ||                                          ||                                                               |
 |* FREE SPACE *||                DATA PAYLOAD              ||                           * FREE SPACE *                      |
 |              ||                                          ||                                                               |
 |              ||                                          ||                                                               |
 |              |*------------------------------------------*|                                                               |
 +--------------+--------------------------------------------+---------------------------------------------------------------+
                ^                                            ^
                |                                            |
                |                                            |
                |                                            |
                |Tail                                    Head|

Sockets

TCP socket

                                             +-------------+
                                             |Main loop TX |
                                             +-------------+
                                                        ^
+----------------------------------+                    |
|                                  |             +------+
|  TCP Socket                      |             |
|                                  |             |
|                                  |             |
|                                  |             |
|                                +-----------------------+
|            +---------------+   |                       |
>DATA OUT==>>|socket send()  |-->|  TX buffer (fifo)     |
|            +---------------+   |                       |
|                                +-----------------------+
|                                  |
|                                  |
|                                  |
|                                +-----------------------+
|             +-------------+    |                       |
<DATA IN<<====|socket recv()|<---|  RX buffer (queue)    |
|             +-------------+    |                       |
|                                +-----------------------+
+----------------------------------+      ^
                                          |
                                          |
                                          |
                                    +--------------+
                                    |  tcp_recv()  |
                                    +--------------+