diff --git a/.gitignore b/.gitignore index 1474cb7..ab68491 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ *.a *.pcap build/* -test/unit/unit-core +test/unit/unit tags diff --git a/core.md b/core.md new file mode 100644 index 0000000..aaa4ace --- /dev/null +++ b/core.md @@ -0,0 +1,107 @@ +# FemtoTCP + +## 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 + + + +### FemtoTCP 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| + +``` + + + +### FemtoTCP queue + +``` + +--------------+--------------------------------------------+---------------------------------------------------------------+ + | |*------------------------------------------*| | + | || || | + | || || | + |* FREE SPACE *|| DATA PAYLOAD || * FREE SPACE * | + | || || | + | || || | + | |*------------------------------------------*| | + +--------------+--------------------------------------------+---------------------------------------------------------------+ + ^ ^ + | | + | | + | | + |Tail Head| +``` + + + +## Sockets + +### TCP socket + +``` + +-------------+ + |Main loop TX | + +-------------+ + ^ ++----------------------------------+ | +| | +------+ +| TCP Socket | | +| | | +| | | +| | | +| +-----------------------+ +| +---------------+ | | +>DATA OUT==>>|socket send() |-->| TX buffer (fifo) | +| +---------------+ | | +| +-----------------------+ +| | +| | +| | +| +-----------------------+ +| +-------------+ | | +