Emulating 2(or Multiple) Network interfaces in the same QEMU Machine


Juliano S Assine
 

Hello,
Sorry for anything confusing, first timer here, I have a couple of questions.

1. Lets say I'm running one of the networking examples using DBOARD=quemu_cortex_m3.
When I build it with make client/server it runs qemu with the "-serial pipe:/tmp/ip-stack-${target}" flag and link client and server via simlink.

qemu(server) -----> /tmp/ip-stack-server.out ---> /tmp/ip-stack-client.in -----> qemu(client)

As qemu support up to 4 virtual serial ports via the -serial flag, can I have multiple network interfaces on the same emulated machine?

quemu(client2) <-- ip-stack-client2.in <-- ip-stack-server2.out <-- qemu(client)qemu(server) --> ip-stack-server1.out --> ip-stack-client1.in --> qemu(client1)

2. If I have a physical device, can I emulate a networking connection using UART in the same fashion?

Thanks,

Juliano


Michael Hope
 

Hi Juilano.  Replies inline...

On Mon, 8 Jan 2018 at 13:37 Juliano Siloto Assine <jsiloto@...> wrote:
Hello,
Sorry for anything confusing, first timer here, I have a couple of questions.

1. Lets say I'm running one of the networking examples using DBOARD=quemu_cortex_m3.
When I build it with make client/server it runs qemu with the "-serial pipe:/tmp/ip-stack-${target}" flag and link client and server via simlink.

qemu(server) -----> /tmp/ip-stack-server.out ---> /tmp/ip-stack-client.in -----> qemu(client)

As qemu support up to 4 virtual serial ports via the -serial flag, can I have multiple network interfaces on the same emulated machine?

Currently, no.  You can only run one instance of the SLIP interface partly as it depends on the single-instance uart_pipe code.


quemu(client2) <-- ip-stack-client2.in <-- ip-stack-server2.out <-- qemu(client)qemu(server) --> ip-stack-server1.out --> ip-stack-client1.in --> qemu(client1)

2. If I have a physical device, can I emulate a networking connection using UART in the same fashion?

Yip, this works well.  One of the first things I did when I picked up Zephyr was configure SLIP and ping the board :)

-- Michael


Juliano S Assine
 



2018-01-08 16:35 GMT-02:00 Michael Hope <michaelh@...>:
Hi Juilano.  Replies inline...

On Mon, 8 Jan 2018 at 13:37 Juliano Siloto Assine <jsiloto@...> wrote:
Hello,
Sorry for anything confusing, first timer here, I have a couple of questions.

1. Lets say I'm running one of the networking examples using DBOARD=quemu_cortex_m3.
When I build it with make client/server it runs qemu with the "-serial pipe:/tmp/ip-stack-${target}" flag and link client and server via simlink.

qemu(server) -----> /tmp/ip-stack-server.out ---> /tmp/ip-stack-client.in -----> qemu(client)

As qemu support up to 4 virtual serial ports via the -serial flag, can I have multiple network interfaces on the same emulated machine?

Currently, no.  You can only run one instance of the SLIP interface partly as it depends on the single-instance uart_pipe code.


quemu(client2) <-- ip-stack-client2.in <-- ip-stack-server2.out <-- qemu(client)qemu(server) --> ip-stack-server1.out --> ip-stack-client1.in --> qemu(client1)

2. If I have a physical device, can I emulate a networking connection using UART in the same fashion?

Yip, this works well.  One of the first things I did when I picked up Zephyr was configure SLIP and ping the board :)

Any suggestions as to how?
If I use uart0 as uart-pipe I can ping a qemu instance but not my physical board.

On qemu I am running with the flag -serial unix:/tmp/slip.sock and using net/tools scripts -serial unix:/tmp/slip.sock
On my board (nrf52_pca10040) I am trying to use tunslip6 directly like:
> sudo ./tunslip6 -B 115200 -s /dev/ttyUSB0 -T -v2 2001:db8::1/64 &
 

-- Michael


Paul Sokolovsky
 

Hello Michael,

On Mon, 08 Jan 2018 18:35:48 +0000
Michael Hope <michaelh@juju.nz> wrote:

[]

2. If I have a physical device, can I emulate a networking
connection using UART in the same fashion?
Yip, this works well. One of the first things I did when I picked up
Zephyr was configure SLIP and ping the board :)
Perhaps, you should contribute a sample application to samples/ for
that ;-).


-- Michael


--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog


Michael Hope
 

One possibility: the host address should be 2001:db8::2, not ::1.

The net shell is also very useful.  Try 'select net' and 'stats'.  I see things like this:

Host side:

********SLIP started on ``/dev/ttyUSB0''
slipfd and inslip reopened
ip neigh flush dev tap0
Cannot find device "tap0"
opened tap device ``/dev/tap0''
ifconfig tap0 up
ip -6 route add 2001:db8::/64 dev tap0
ip -6 addr add 2001:db8::2/64 dev tap0
ip route add 192.0.2.0/24 dev tap0
ip addr add 192.0.2.2/24 dev tap0
ifconfig tap0

tap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.0.2.2  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 2001:db8::2  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::144a:22ff:feff:a9bf  prefixlen 64  scopeid 0x20<link>
        ether 16:4a:22:ff:a9:bf  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: Packet from TUN of length 90 - write SLIP
tap0: Packet from TUN of length 110 - write SLIP
tap0: Packet from TUN of length 74 - write SLIP
tap0: Packet from TUN of length 54 - write SLIP
tap0: Packet from TUN of length 86 - write SLIP

Device side:

shell> select net
net> stats
IPv6 recv      13       sent    8       drop    0       forwarded       0
IPv6 ND recv   2        sent    5       drop    2
IPv6 MLD recv  0        sent    3       drop    0
IP vhlerr      0        hblener 0       lblener 0
IP fragerr     0        chkerr  0       protoer 0
ICMP recv      10       sent    3       drop    8
ICMP typeer    0        chkerr  0
UDP recv       0        sent    0       drop    3
UDP chkerr     0
TCP bytes recv 0        sent    0
TCP seg recv   0        sent    0       drop    0
TCP seg resent 0        chkerr  0       ackerr  0
TCP seg rsterr 0        rst     0       re-xmit 0
TCP conn drop  0        connrst 0
Bytes received 1584
Bytes sent     564
Processing err 5

-- Michael

On Wed, 10 Jan 2018 at 19:27 Juliano Siloto Assine <jsiloto@...> wrote:
2018-01-08 16:35 GMT-02:00 Michael Hope <michaelh@...>:
Hi Juilano.  Replies inline...

On Mon, 8 Jan 2018 at 13:37 Juliano Siloto Assine <jsiloto@...> wrote:
Hello,
Sorry for anything confusing, first timer here, I have a couple of questions.

1. Lets say I'm running one of the networking examples using DBOARD=quemu_cortex_m3.
When I build it with make client/server it runs qemu with the "-serial pipe:/tmp/ip-stack-${target}" flag and link client and server via simlink.

qemu(server) -----> /tmp/ip-stack-server.out ---> /tmp/ip-stack-client.in -----> qemu(client)

As qemu support up to 4 virtual serial ports via the -serial flag, can I have multiple network interfaces on the same emulated machine?

Currently, no.  You can only run one instance of the SLIP interface partly as it depends on the single-instance uart_pipe code.


quemu(client2) <-- ip-stack-client2.in <-- ip-stack-server2.out <-- qemu(client)qemu(server) --> ip-stack-server1.out --> ip-stack-client1.in --> qemu(client1)

2. If I have a physical device, can I emulate a networking connection using UART in the same fashion?

Yip, this works well.  One of the first things I did when I picked up Zephyr was configure SLIP and ping the board :)

Any suggestions as to how?
If I use uart0 as uart-pipe I can ping a qemu instance but not my physical board.

On qemu I am running with the flag -serial unix:/tmp/slip.sock and using net/tools scripts -serial unix:/tmp/slip.sock
On my board (nrf52_pca10040) I am trying to use tunslip6 directly like:
> sudo ./tunslip6 -B 115200 -s /dev/ttyUSB0 -T -v2 2001:db8::1/64 &
 

-- Michael

_______________________________________________
Zephyr-users mailing list
Zephyr-users@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-users


Michael Hope
 

It turns out that samples/net/http_server already works fine :)

I had to shrink the buffer count to fit on the 32 KiB on the Arduino Zero though.

-- Michael

On Thu, 11 Jan 2018 at 00:15 Paul Sokolovsky <paul.sokolovsky@...> wrote:
Hello Michael,

On Mon, 08 Jan 2018 18:35:48 +0000
Michael Hope <michaelh@...> wrote:

[]

> > 2. If I have a physical device, can I emulate a networking
> > connection using UART in the same fashion?
> >
>
> Yip, this works well.  One of the first things I did when I picked up
> Zephyr was configure SLIP and ping the board :)

Perhaps, you should contribute a sample application to samples/ for
that ;-).

>
> -- Michael



--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog


Paul Sokolovsky
 

Hello Michael,

On Fri, 12 Jan 2018 19:58:12 +0000
Michael Hope <michaelh@juju.nz> wrote:

It turns out that samples/net/http_server already works fine :)

I had to shrink the buffer count to fit on the 32 KiB on the Arduino
Zero though.
Sure, existing samples should work, that's the whole idea. As soon as
you enable bunch of options (and outsider would say "obscure options"),
and run stuff on a host ("obscure stuff", an outsider would say; what
do we do to run SLIP on Linux nowadays? Is it still something simple as
slirp, or it was subsumed by pppd and you need to dig into its obscure
option to make it run, jungling to not affect system-wide setup and
not get an option conflict?).

Effectively, a known working configuration and README describing the
full setup is what would comprise a SLIP sample, the code is definitely
there. So, please don't discount it as something not useful and not
worth a hacking pleasure ;-).


-- Michael

On Thu, 11 Jan 2018 at 00:15 Paul Sokolovsky
<paul.sokolovsky@linaro.org> wrote:

Hello Michael,

On Mon, 08 Jan 2018 18:35:48 +0000
Michael Hope <michaelh@juju.nz> wrote:

[]

2. If I have a physical device, can I emulate a networking
connection using UART in the same fashion?
Yip, this works well. One of the first things I did when I
picked up Zephyr was configure SLIP and ping the board :)
Perhaps, you should contribute a sample application to samples/ for
that ;-).
[]

--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog


Juliano S Assine
 

Thanks Michael, I was able to reproduce on my board. I was having some trouble because there is only one UART on the nrf52 DK so I couldn't access the console to see what was going on.
I agree with Paul, it took me some reading about slip and ppp, tun/tap etc, to figure things out, which is not bad, but a sample in the repo would have been really helpful.

Just a few more questions:
2 - Using the http_server example, tunslip6 -v2 works, but -v4 doesn't, there may be a bug there
3- http_server example works of firefox but not on chrome.

2018-01-13 8:55 GMT-02:00 Paul Sokolovsky <paul.sokolovsky@...>:

Hello Michael,

On Fri, 12 Jan 2018 19:58:12 +0000
Michael Hope <michaelh@...> wrote:

> It turns out that samples/net/http_server already works fine :)
>
> I had to shrink the buffer count to fit on the 32 KiB on the Arduino
> Zero though.

Sure, existing samples should work, that's the whole idea. As soon as
you enable bunch of options (and outsider would say "obscure options"),
and run stuff on a host ("obscure stuff", an outsider would say; what
do we do to run SLIP on Linux nowadays? Is it still something simple as
slirp, or it was subsumed by pppd and you need to dig into its obscure
option to make it run, jungling to not affect system-wide setup and
not get an option conflict?).

Effectively, a known working configuration and README describing the
full setup is what would comprise a SLIP sample, the code is definitely
there. So, please don't discount it as something not useful and not
worth a hacking pleasure ;-).

>
> -- Michael
>
> On Thu, 11 Jan 2018 at 00:15 Paul Sokolovsky
> <paul.sokolovsky@...> wrote:
>
> > Hello Michael,
> >
> > On Mon, 08 Jan 2018 18:35:48 +0000
> > Michael Hope <michaelh@...> wrote:
> >
> > []
> >
> > > > 2. If I have a physical device, can I emulate a networking
> > > > connection using UART in the same fashion?
> > > >
> > >
> > > Yip, this works well.  One of the first things I did when I
> > > picked up Zephyr was configure SLIP and ping the board :)
> >
> > Perhaps, you should contribute a sample application to samples/ for
> > that ;-).

[]

--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog


Michael Hope
 



On Tue, 16 Jan 2018 at 15:28 Juliano Siloto Assine <jsiloto@...> wrote:
Thanks Michael, I was able to reproduce on my board. I was having some trouble because there is only one UART on the nrf52 DK so I couldn't access the console to see what was going on.
I agree with Paul, it took me some reading about slip and ppp, tun/tap etc, to figure things out, which is not bad, but a sample in the repo would have been really helpful.

Just a few more questions:

CONFIG_UART_PIPE is automatically selected when the SLIP driver is selected.  See drivers/net/Kconfig for more.

2 - Using the http_server example, tunslip6 -v2 works, but -v4 doesn't, there may be a bug there
3- http_server example works of firefox but not on chrome.

Yeah, I might be seeing similar - could you log a bug?  What I see with wget on the http_server example is:

```
$ wget -O - http://192.168.1.233/
--2018-01-17 21:17:32--  http://192.168.1.233/
Connecting to 192.168.1.233:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘STDOUT’

-                         [<=>                       ]       0  --.-KB/s               <html>
  <head>
    <meta charset="UTF-8">
    <title>Zephyr HTTP server sample</title>
  </head>

  <body>
    <div>
      <p>It works!</p>
    </div>
  </body>
</html>
-                         [ <=>                      ]     170  --.-KB/s    in 0s     

2018-01-17 21:17:33 (9,03 MB/s) - Read error at byte 170 (Success).Retrying.
```

The interesting bit is the final 'read error - success' which puts wget into a retry loop.

-- Michael


2018-01-13 8:55 GMT-02:00 Paul Sokolovsky <paul.sokolovsky@...>:
Hello Michael,

On Fri, 12 Jan 2018 19:58:12 +0000
Michael Hope <michaelh@...> wrote:

> It turns out that samples/net/http_server already works fine :)
>
> I had to shrink the buffer count to fit on the 32 KiB on the Arduino
> Zero though.

Sure, existing samples should work, that's the whole idea. As soon as
you enable bunch of options (and outsider would say "obscure options"),
and run stuff on a host ("obscure stuff", an outsider would say; what
do we do to run SLIP on Linux nowadays? Is it still something simple as
slirp, or it was subsumed by pppd and you need to dig into its obscure
option to make it run, jungling to not affect system-wide setup and
not get an option conflict?).

Effectively, a known working configuration and README describing the
full setup is what would comprise a SLIP sample, the code is definitely
there. So, please don't discount it as something not useful and not
worth a hacking pleasure ;-).

>
> -- Michael
>
> On Thu, 11 Jan 2018 at 00:15 Paul Sokolovsky
> <paul.sokolovsky@...> wrote:
>
> > Hello Michael,
> >
> > On Mon, 08 Jan 2018 18:35:48 +0000
> > Michael Hope <michaelh@...> wrote:
> >
> > []
> >
> > > > 2. If I have a physical device, can I emulate a networking
> > > > connection using UART in the same fashion?
> > > >
> > >
> > > Yip, this works well.  One of the first things I did when I
> > > picked up Zephyr was configure SLIP and ping the board :)
> >
> > Perhaps, you should contribute a sample application to samples/ for
> > that ;-).

[]

--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog