Re: Query on how WWAN and Modem interact

From: Enrico Weigelt, metux IT consult
Date: Fri Apr 05 2019 - 08:31:04 EST


On 29.03.19 05:35, Ajay Garg wrote:

> I am wanting to have some insight on how a modem plugs into the
> linux-kernel at architecture level.

Well, that depends ... which type of modem ? which protocols ?

The most common case are the classical serial modems, attached to
some uart (including those isa or pci cards that just have speaking AT
commands. Here, somebody needs to do the
dialing (eg. 'chat' command) - after dialing the some daemon
for the corresponding (ppp, uucp, ax25, ...) needs to take over.

With async-ppp (ppp over uart) it goes like this:

* pppd is started, sets up tty, etc
* pppd calls a chat script (usually using 'chat' command) for doing
the dialing (AT commands) - this subprocess gets the fd to the
tty as its stdin/stdout
* when this finished, it takes back control and does some ppp handshake
(line probing, authentication, address/routing handshake, ...)
* then it creates a new ppp* device, attaches the ppp line discipline
to the tty and assignes this to the new device
* the unix black magic: line disciplies
-> these are special filters that can be attached to a tty for
intercepting the traffic, eg. for job control or trivial line
editing via a terminal, etc
-> the kernel also has a ppp line discipline which intercepts ppp
frames that contain IP packets puts them into the ppp network
interface's rx queue (so pppd won't ever see them), as well as
writing out the outbound packets back to the tty

Of course, there're are also lots of other kind of modems and protocols
that work differently ...

> Now, we are in a bit of situation, where only the AT-interface (of the
> modem) might be available to us (via a serial /dev/tty interface).

That's the classic old fashioned way - pppd package comes with tools to
handle that. (by the way: I wouldn't like to cope w/ complicated things
like modemmanger, etc).

> Also, using AT-commands to actually set up sockets is also fine.

What do you mean w/ sockets ?

Are you talking about basebands with integrated ip stack ? Those are
nice for tiny MCUs w/o any OS, but tricky to properly integrate into
into the berkeley socket api.

What chips exactly are you talking about ?

> Now, my query is once the AT-commands succesfully set up a socket, how
> does that link to "wwan" interface in "ifconfig" listings.

If the baseband/modem really does the whole IP stack, including sockets,
on its own, the answer most likely is: not at all.

But that depends on what baseband/modem exactly you're talking about.


--mtx

--
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@xxxxxxxxx -- +49-151-27565287