IncludeOS TCP implementation

tcp

#1

We’re implementing a brand new IP stack and we’re now working on an efficient, more or less core guidelines compliant C++11/14 implementation.

Current issues:

  • GoF State pattern - a good idea in practice?
    • Is the polymorphism a performance issue?
    • In practice you have 11 states, and 10 events in the RFC, making 110 possible combinations. The state pattern seems to be a nice way to partition that space nicely
  • RFC terminology vs. POSIX socket.h terminology - what do you chose?
    • For example the RFC talks about call OPEN, as different functions depending on state. It seems like POSIX uses bind() as a way to do “passive open” and connect as a way to express “active open”.
    • What’s a good way to implement the terms “Socket” and “Connection” in C++?
      • In POSIX you’re used to having sockets as just file descriptors. In IncludeOS I don’t think that makes any sense. The intuitive idea is to have a “socket class” but the RFC talks about a socket as just a pair of IP and port.
      • Is a “connection” something that holds a pair of sockets? Is the RFC’s TCB something we could just embed inside a “connection”

Any comments, tips and clarifications are welcome!


#2

Here’s some (non working) code snippets for a new draft, and used as basis for our discussion earlier today. https://github.com/AndreasAakesson/tcp_v3
It’s not by any means correctly written code, but I rather sketch in code :stuck_out_tongue:


#3

Oh, v3 - fancy! It’s a very good place to start the discussion. Let me know when everything is finished and perfect :wink: No, but seriously - good sketching!


#4

A few comments

  1. I’m thinking we should explicitly incorporate the TCB-term according to the RFC to make the connection between code / RFC crystal
  2. Find a smart way to make the connection between the active_close / passive_close functions and the RFC’s call OPEN clear.
  3. We need to adress the fact that “local IP” in a connection socket-pair is implicit from the inet instance. If it was to be present in the socket object it should be by reference. For IPv4 it doesn’t really matter as it’s 4 bytes anyway but for IPv6 it matters
  4. Templatize every class and function that either interacts with IP addresses or Inet-objects, to use IPV as IP-version type placeholder

…We should aso discuss generalized sockets. Do we need them? Are we doing anythinge with sockets ecept UDP and TCP? Possibly another thread?