Networking Forums

Networking Forums > Computer Networking > Linux Networking > Reception procedure in an embedded device

Reply
Thread Tools Display Modes

Reception procedure in an embedded device

 
 
Riccardo Manfrin
Guest
Posts: n/a

 
      04-06-2011, 08:38 AM
I'm writing the reception mechanism for an embedded device equipped
with a "generic" radio interface.
My question regards the implementation of the reception passing
through the various layers of the stack. Assume that different users
(e.g. UDP clients) can request a reception, by submitting a buffer,
the buffer length and a rx callback. The application should allowed to
allocate the buffers statically or dynamically depending on its needs.
When a packet is received at the lower layer, the layer doesn't know
who such packet belongs to (because it hasn't parsed it yet).
Therefore the first operation is to copy the packet from the radio
buffer to the first available buffer in the list of buffers submitted
for reception (precisely: the one with the smallest length allowing
the full storage of the packet).
While climbing up the stack layers with packet parsing, a layer finds
out that the packet belonged to a different user than the one whose
buffer had been used for temporarily holding the packet (e.g. UDP port
mismatching).
In such case the layer could swap the buffers of the two users
involved in the mismatching OR memcopy the data from the wrong buffer
to the right one.
While swapping is a computational efficient choice it requires buffers
to have the same properties in terms of
* length,
* type of allocation (static/dynamic).
Indeed when releasing the buffers to the users, those should be
allowed to assume to be using the same buffer they had submitted for
reception (rather reasonable). If this assumption doesn't hold because
of swapping, the only way to cope with it is to have the above
described characteristics for all buffers (same length and allocation
type).

My question is if linux has a smart way to do these kind of jobs (or
eventually if you know any).

Thanks in advance.
RM



 
Reply With Quote
 
 
 
 
Tauno Voipio
Guest
Posts: n/a

 
      04-06-2011, 05:05 PM
On 6.4.11 11:38 , Riccardo Manfrin wrote:
> I'm writing the reception mechanism for an embedded device equipped
> with a "generic" radio interface.
> My question regards the implementation of the reception passing
> through the various layers of the stack. Assume that different users
> (e.g. UDP clients) can request a reception, by submitting a buffer,
> the buffer length and a rx callback. The application should allowed to
> allocate the buffers statically or dynamically depending on its needs.
> When a packet is received at the lower layer, the layer doesn't know
> who such packet belongs to (because it hasn't parsed it yet).
> Therefore the first operation is to copy the packet from the radio
> buffer to the first available buffer in the list of buffers submitted
> for reception (precisely: the one with the smallest length allowing
> the full storage of the packet).
> While climbing up the stack layers with packet parsing, a layer finds
> out that the packet belonged to a different user than the one whose
> buffer had been used for temporarily holding the packet (e.g. UDP port
> mismatching).
> In such case the layer could swap the buffers of the two users
> involved in the mismatching OR memcopy the data from the wrong buffer
> to the right one.
> While swapping is a computational efficient choice it requires buffers
> to have the same properties in terms of
> * length,
> * type of allocation (static/dynamic).
> Indeed when releasing the buffers to the users, those should be
> allowed to assume to be using the same buffer they had submitted for
> reception (rather reasonable). If this assumption doesn't hold because
> of swapping, the only way to cope with it is to have the above
> described characteristics for all buffers (same length and allocation
> type).
>
> My question is if linux has a smart way to do these kind of jobs (or
> eventually if you know any).
>


This is the classical networking buffer problem.

The common solutions are:

1. There is a separate buffer for the receiver, and its contents are
copied to the client buffer when the proper client is found. The
receive buffer is then recycled to the receiver.

2. There is a generic buffer pool. The receiver picks a buffer from
the pool and passes it to the proper user when the user is decoded
from the message. It is the the responsibility of the user to
return the buffer to the common pool.

Both methods have memory space problems if the message lengths
vary wildly, so that a single length for the buffer won't do.
An often used solution is to use pretty small buffers with
chaining pointers, so that a longer message is split between
shorter buffers which are chained together.

--

Tauno Voipio
tauno voipio (at) iki fi
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Orange cancellation procedure Vaso Broadband 10 01-09-2008 08:47 AM
DHCP Restore Procedure JimMatelski Windows Networking 0 07-19-2005 06:57 PM
Migrating procedure David G Broadband 8 12-15-2004 10:37 PM
Remote Procedure Call (RPC) Michel Windows Networking 3 09-23-2004 11:40 PM
Wi-Fi Access Procedure Dick Wireless Internet 18 05-07-2004 10:57 PM



1 2 3 4 5 6 7 8 9 10 11