conn: Initial import of a light-weight network application API#3615
conn: Initial import of a light-weight network application API#3615miri64 merged 3 commits intoRIOT-OS:masterfrom
Conversation
|
At a first glance, it looks like sockets. |
|
... with multi-stack support ... @OlegHahm But the interface does work without dynamic memory. |
|
@authmillenon I'm sorry, but this does not seem lightweight to me. |
|
Can you remind me where I need dynamic memory for sockets? |
|
@OlegHahm Sorry, I meant 'preallocated or dynamic memory'. edit As in, |
|
+1 for the general approach, but I also don't see the light-weight here. I think we can do even more simple, like a stateless, one function call for sending UDP for example. |
|
btw are we talking about a layer between application layer and lower layers or between applications and the network stack in general? |
|
|
@authmillenon If you drop support for multiple interfaces, you basically end up with gnrc's interface, right? |
|
@OlegHahm application <-> network stack |
and
IMO that's contradicting. An application developer is not necessarily a RIOT-developer and usually doesn't care about which transport layer, routing, or whatever is used below. If we want to design an interface for applications to the network stack this has to be more generic and agnostic to lower layers. If we want to design an interface from application layer protocol implementations to lower layers (transport layer or similar), your assumption is valid (I guess). |
|
@authmillenon Let me be more specific when I mean "this is not lightweight". In order to bind to an udp port, all you need is "udp_bind(port)". What do you estimate is the overhead in code, memory and stack for this bind, comparing to calling "null_udp_bind(port)"? Whatever number you say, all of it is overhead brought by "conn", and should be avoided. |
Yes. Sure. He doesn't care. We all agree on that. We want our poor baby developers to be able to shout "DO!" at the RIOT node, and it does it. We want to make it even easier than Oracle does for its well-known enterprise language. In reality, there are a lot of compromises to be made if we want a RIOT application developer to be able to do "connect me to X", not caring about whether it's TCP or not, abstracting that technicality away. I think we should summon all devs and have a big, long talk if we want RIOT to go that way. Or just provide sane, small, efficient APIs for people that do want to open a TCP connection. |
You're mixing things up. An application developer wants to transmit data over lwm2m, CoAP, MQTT, whatever... It's RIOT's duty to chose and provide the proper transport/network/link layer and routing protocol implementations for that and provide an API to the application developer that does not require internal knowledge about the stack. There's non inherent contradiction in making this sane, small, and efficient. People who do want to open a TCP connection are typically no application developers. |
lwm2m, CoAP, MQTT are "application" when seen from the perspective of Those libs will use whatever API they need to. If at that level we're And if we re-use libs implementing those protocols, we will probably Complicated. Bloated. |
Go back to my initial question and your answer. You're talking about application layer <-> network stack. |
|
You're talking about application **layer** <-> network stack.
I'm talking about the API proposed by this PR.
It is a stack-agnostic light-weight "socket" API, the kind of API that
is used to write libs like mqtt or coap libraries or applications that
want to use e.g., UDP or TCP.
@authmillenon Did I get that right?
|
but never mind |
|
@kaspar030 let me get your argument straight: you say it is not lightweight because it offers multi-task support / because of I tend to agree, that dynamic stack support isn't really necessary (and when thinking about it really hard to do with the concept I have for sockets in mind), so I guess I can make it a little more static, using macro magic instead of switch cases and inline functions. Multi-task support can also be achieved by writing a netapi adapter for a non-profit stack ;). The reason this API looks so much like sockets is, because it IS a pointer based socket API. This is the main reason I did not re-purposed the socket_base header. The fact alone that I don't use file descriptors or other numerical id's makes the module itself very RAM-memory efficient (about ROM we can argue, but let me rewrite it first a little), because the module does not need to maintain a (possibly huge but largely unused) socket table, as socket_base did. The other reason I did not call it socket_whatever was to avoid user confusion *we already faced_ about which socket API to use. I say: If you are an inexperienced user: use POSIX sockets (or whatever library will wrap around them) because you are used to them, which will be the only API in RIOT that has "socket" in name, when I'm done. No ambiguity possible. More experienced users still can use |
In general yes. It is the base for a very slim POSIX socket API, which allows then for very easy porting of external libs. |
It does not seem light-weight because of multi stack support and because
IMHO, we have a need for a "socket" kind of API which is not directly IMHO, this proposed API is too inefficient.
We need to be careful with that. At some point, user-friendlyness comes |
An transport layer API is not a user API in my opinion. |
What is it? |
|
A networking API (like netapi). |
8a8f58e to
f5244ee
Compare
|
Squashed and rebased to current master. |
f5244ee to
24c679b
Compare
There was a problem hiding this comment.
why this include? The generic conn interface should not care about a GNRC specific header, right?
There was a problem hiding this comment.
Because you need some magic (that I don't know) to get gcc to recognize the width of an externally defined struct.
|
just these two optional remarks -> ACK once Travis... |
|
Addressed comments and added test application for |
b526087 to
06183cb
Compare
|
addressed external comment. |
tests/conn_ip/main.c
Outdated
There was a problem hiding this comment.
main does not receive, right?
|
re-ACK when comment for test application is addressed. |
fdcf7f3 to
9205d90
Compare
|
Addressed comments and squashed immediately. |
9205d90 to
e3746c0
Compare
|
Fixed doc error and squashed immediately. |
e3746c0 to
4d9ca33
Compare
|
Fixed avr-related bug in |
4d9ca33 to
c60fd48
Compare
|
Defined boards with insufficient memory for test application... Now it should work ……… |
c60fd48 to
39f8a41
Compare
|
(Hopefully) one last fix. |
conn: Initial import of a light-weight network application API
Leight-weight, but stack agnostic. I tried to keep it as close to the socket API as possible to write very simple wrappers for that in the posix module.
Depends on #3608.