lepass7
Posts: 2
Joined: Mon Mar 25, 2019 8:24 pm

RPI acting both as slave and as master device on its usb ports

Tue Mar 26, 2019 5:14 am

Hi guys,
I was wondering if it's possible to use one port of my raspberry pi as slave usb (otg mode) and the other port as master.
For example let's say on one port I will connect a USB keyboard (RPI as master) and on the other port I will connect my RPI to my pc (otg).
I would like to manipulate the input from the user that is coming from the keyboard and then send it to my pc.
I know it's possible to do this directly on my pc, but I would like to prepare this configuration just for research.
The configuration it should be like this:
(Keyboard)<->(RPI)<->(PC).
I did my research and I have found that RPI zero can be set up as slave device but I am not sure if this configuration could only be just for one port.
I am looking forward to read your opinion on this.

Thank you

hippy
Posts: 5760
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: RPI acting both as slave and as master device on its usb ports

Tue Mar 26, 2019 9:54 am

lepass7 wrote:
Tue Mar 26, 2019 5:14 am
I was wondering if it's possible to use one port of my raspberry pi as slave usb (otg mode) and the other port as master.
Short answer; no.

But you could use a Zero as an OTG gadget and another Pi as a USB host and link the two through GPIO UART using PPP or some other means.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Tue Mar 26, 2019 10:26 am

I agree with Hippy, you can't use the one USB on the SOC as both host and device at the same time. The four USB ports on Pi are a USB hub attached to the single USB host port, so you can't use OTG gadget mode on a Pi with four USB sockets.

You can run in gadget mode so the Pi looks like a keyboard and you can connect some sort of user input device to GPIO. You may be able to interface a PS/2 keyboard or even bit-bang a USB1 host port to talk to a keyboard.
A switch matrix on gpio would work.
You could also use a Bluetooth keyboard.

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Tue Mar 26, 2019 12:19 pm

lepass7 wrote:
Tue Mar 26, 2019 5:14 am
I did my research and I have found that RPI zero can be set up as slave device but I am not sure if this configuration could only be just for one port.
To add to what's already been said, the zero has only one port. It has two connectors but only one of those has the data lines.

There are ICs available that add USB host ports via SPI. I've not used them but at least one person on the forum has done so.
This space unintentionally left blank.

lepass7
Posts: 2
Joined: Mon Mar 25, 2019 8:24 pm

Re: RPI acting both as slave and as master device on its usb ports

Tue Mar 26, 2019 3:50 pm

hippy wrote:
Tue Mar 26, 2019 9:54 am
lepass7 wrote:
Tue Mar 26, 2019 5:14 am
I was wondering if it's possible to use one port of my raspberry pi as slave usb (otg mode) and the other port as master.
Short answer; no.

But you could use a Zero as an OTG gadget and another Pi as a USB host and link the two through GPIO UART using PPP or some other means.
That's a good idea. So the configuration it would be like this:

[keyboard] <-USB-> [RPI] <- [SPI or I2C or serial through CPIO ] -> [RPI] <-> [PC]

Maybe I will try this and I will let you know.

Thank you guys, :D

treefella
Posts: 9
Joined: Thu Mar 24, 2016 11:59 pm

Re: RPI acting both as slave and as master device on its usb ports

Fri May 17, 2019 9:31 pm

Hey there, wondering If you where able to get this to work?

I'm thinking of creating a device with the Compute Module and using the USB as a way to bridge a network connection between multiple Pis in a sort of mesh network.

One could use an ethernet controller like the one implemented on the bigger pis but that seems kinda silly if its going into USB anyway.

Anyone tried this before? Any reason why this wouldn't be possible?

------

Config would be [RPI] <-> [RPI] <-> [PC] and I plan to use this as a way to pass around video/audio feeds with NDI.
Ron Sardarian
instagram.com/teafela/
teafella.com

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Sat May 18, 2019 10:40 am

A LAN is better suited to a mesh than USB which operates as master/slave. If you connect many RPi slaves to a host RPi through USB hubs the slaves can't talk to each other, only to the host.

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Sat May 18, 2019 3:42 pm

PiGraham wrote:
Sat May 18, 2019 10:40 am
A LAN is better suited to a mesh than USB which operates as master/slave. If you connect many RPi slaves to a host RPi through USB hubs the slaves can't talk to each other, only to the host.
Not necessarily true.

If the slave Pi are zero/zeroW/A/A+ running as ethernet gadgets (or as serial gadgets witth PPP/SLIP) you can ru a software bridge on the host Pi and add all the slave Pi to that.

Of course, the more slave Pi you have the less bandwidth available to each but that will apply however they're connected.
This space unintentionally left blank.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Sat May 18, 2019 8:43 pm

thagrol wrote:
Sat May 18, 2019 3:42 pm
PiGraham wrote:
Sat May 18, 2019 10:40 am
A LAN is better suited to a mesh than USB which operates as master/slave. If you connect many RPi slaves to a host RPi through USB hubs the slaves can't talk to each other, only to the host.
Not necessarily true.

If the slave Pi are zero/zeroW/A/A+ running as ethernet gadgets (or as serial gadgets witth PPP/SLIP) you can ru a software bridge on the host Pi and add all the slave Pi to that.

Of course, the more slave Pi you have the less bandwidth available to each but that will apply however they're connected.

But that is via the host, not direct between slaves.
Isn't it better to use a switch or router and network the devices?

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 10:14 am

PiGraham wrote:
Sat May 18, 2019 8:43 pm
Isn't it better to use a switch or router and network the devices?
For some values of "better" perhaps. And that wasn't my point, I was clarifying your misleading statement that " the slaves can't talk to each other"

A lot depends on the use case. Slaves may not have any need to communicate with each other. Communications with the master may be small and infrequent.

There is a significant cost increase in using a LAN: slaves need to be ethernet (or wifi) capable. Moving from a zero to a zeroW doubles the cost per slave. Moving to a slave with onboard ethernet is seven times the cost. Plus the cost of PSUs, Pi 3 need more power than can be drawn from a USB port. Adding ethernet via USB will likely add at least as much cost per slave as moving from a zero to a zeroW.

As for the bandwidth issue, it's probable that a 100Mb LAN would top out before USB. WiFi wouldn't be any better. I'd expect Gigabit to top out at around the same level as USB.

About the only thing a LAN brings to the party is larger seperation between host and slaves. Without active compnents USB has a max cable length of 5m whereas ethernet has a limit of 100m. It could allow more mslave devices than USB but if you're looking at that many slaves (over 100) you should probably be looking at a different network arcitechture.
This space unintentionally left blank.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 10:48 am

thagrol wrote:
Sun May 19, 2019 10:14 am
PiGraham wrote:
Sat May 18, 2019 8:43 pm
Isn't it better to use a switch or router and network the devices?
For some values of "better" perhaps. And that wasn't my point, I was clarifying your misleading statement that " the slaves can't talk to each other"
You say it's misleading, but your answer is not that slaves can talk to each other but that they have to communicate via a host, which confirms my point. That difference may or may not be important in some use cases, but the term "mesh" is inconsistent with USB topology. So I think your statement is the misleading one.
A mesh network is a network in which the devices -- or nodes -- are connected so that at least some, and sometimes all, have multiple paths to other nodes. This creates multiple routes for information between pairs of users, increasing the resilience of the network in case of a failure of a node or connection. In a full mesh topology, each network node is connected directly to each of the others.

https://internetofthingsagenda.techtarg ... sh-network
What you propose lacks the central features of a mesh network.
thagrol wrote:
Sun May 19, 2019 10:14 am
A lot depends on the use case. Slaves may not have any need to communicate with each other. Communications with the master may be small and infrequent.
Then is what sense is that a mesh network?
treefella wrote: I'm thinking of creating a device with the Compute Module and using the USB as a way to bridge a network connection between multiple Pis in a sort of mesh network.
LAN or WLAN allows for multiple reduncant connections, USB does not. There are other options of course, amany of which might use a USB connected interface.

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 11:39 am

I admit, I overlooked the mesh network.

However, I fail to see the difference in connecting multiple Pi via a switch and connecting multiple pi via a USB host acting as a switch (that's what a bridge does in this instance).

In neither case do the Pi communicate directly to each other. In both cases they go through another device that does routing and forwarding at a low level in the ethernet stack.

Further, and I may very well be wrong on this, mesh networking originated in the WiFi environment as a way to allow multiple stations to provide an internet like connectivity without the cables etc. So it's not really applicable, or practical within a wired LAN.

Ad Hoc wifi is about the only way I can see stations talking directly to each other without going through some sort of additional hardware. Or with each PI having as many ethernet interfaces and cables are there are Pi with each Pi directly connected by cable to every other Pi. That'd be a nightmare just on the cable routing alone.

I found you statement " If you connect many RPi slaves to a host RPi through USB hubs the slaves can't talk to each other, only to the host." to be inaccurate (and therefore misleading) as it gave the impression that slaves connected via USB ethernet gadget can communicate only with the host and never with other devices. It implied that routing and bridging on the USB host could not be used.

Also, strictly speaking, within a LAN, Pi, and switch environment, the only thing the Pi can communicate with directly is the switch. It relies on hardware and software insdide the switch to reach other devices.

As for "What you propose lacks the central features of a mesh network.". Sure, but I'm not convinced that the person who asked the question fully understands what a mesh network is, as their question was somewhat vague: "bridge a network connection between multiple Pis in a sort of mesh network"

My proposal isn't a mesh network but does address the bridge part of that requirement and their reqirement to use USB.

Mesh networks definitely have their place but without further information from @treefella about precisely what they're trying to acheive we don't know which is more apropriate. We don't know if @treefella actually requires a mesh network and can jutify the significant additional cost involved over USB.
This space unintentionally left blank.

fruitoftheloom
Posts: 20439
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 11:52 am

lepass7 wrote:
Tue Mar 26, 2019 5:14 am
Hi guys,
I was wondering if it's possible to use one port of my raspberry pi as slave usb (otg mode) and the other port as master.
For example let's say on one port I will connect a USB keyboard (RPI as master) and on the other port I will connect my RPI to my pc (otg).
I would like to manipulate the input from the user that is coming from the keyboard and then send it to my pc.
I know it's possible to do this directly on my pc, but I would like to prepare this configuration just for research.
The configuration it should be like this:
(Keyboard)<->(RPI)<->(PC).
I did my research and I have found that RPI zero can be set up as slave device but I am not sure if this configuration could only be just for one port.
I am looking forward to read your opinion on this.

Thank you

Despite the dis-agreement in responses the answer is still No

The Raspberry Pi SBCs with either 2 or 4 USBs are Host Mode.

The Raspberry Pi SBCs with a single USB can be either a Host or a Slave, but not both at same time.


You appear to be under the impression the Zero has 2 USB, one is power only........
adieu

Asus CS10 Chromebit / HP Envy 4500 Wireless Printer / Raspberry Pi Model 2B v1.1 / RealVNC Software...

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 12:31 pm

thagrol wrote:
Sun May 19, 2019 11:39 am

I found you statement " If you connect many RPi slaves to a host RPi through USB hubs the slaves can't talk to each other, only to the host." to be inaccurate (and therefore misleading) as it gave the impression that slaves connected via USB ethernet gadget can communicate only with the host and never with other devices. It implied that routing and bridging on the USB host could not be used.
As You read it that way I'll accept I could have been clearer, but of course, if any slave can communicate with the host and the host can communicate with any slave then any slave can get the host to relay a message to any other slave. It's just not a mesh network.
thagrol wrote:
Sun May 19, 2019 11:39 am
Also, strictly speaking, within a LAN, Pi, and switch environment, the only thing the Pi can communicate with directly is the switch. It relies on hardware and software insdide the switch to reach other devices.
Ethernet emerged from ARPANET that was designed for multiple redundancy. It is a highly redundant network that transparently routes messages over available connections.
A mesh network (or simply meshnet) is a local network topology in which the infrastructure nodes (i.e. bridges, switches and other infrastructure devices) connect directly, dynamically and non-hierarchically to as many other nodes as possible and cooperate with one another to efficiently route data from/to clients. This lack of dependency on one node allows for every node to participate in the relay of information. Mesh networks dynamically self-organize and self-configure, which can reduce installation overhead. The ability to self-configure enables dynamic distribution of workloads, particularly in the event that a few nodes should fail. This in turn contributes to fault-tolerance and reduced maintenance costs.
Mesh topology may be contrasted with conventional star/tree local network topologies in which the bridges/switches are directly linked to only a small subset of other bridges/switches, and the links between these infrastructure neighbours are hierarchical. While star-and-tree topologies are very well established, highly standardized and vendor-neutral, vendors of mesh network devices have not yet all agreed on common standards, and interoperability between devices from different vendors is not yet assured.

https://en.wikipedia.org/wiki/Mesh_networking
Ethernet LANs or WiFi WLANs are examples of the first and USB is an example of the second.
thagrol wrote:
Sun May 19, 2019 11:39 am
As for "What you propose lacks the central features of a mesh network.". Sure, but I'm not convinced that the person who asked the question fully understands what a mesh network is, as their question was somewhat vague: "bridge a network connection between multiple Pis in a sort of mesh network"
Of course that is possible, but "mesh network" was the term used and that was the basis of my reply and not the basis of yours so we gave different answers. Granted, if they didn't mean that then your answer is a good answer for getting USB devices to communicate over USB hierarchical topology.

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 2:47 pm

PiGraham wrote:
Sun May 19, 2019 12:31 pm
Ethernet emerged from ARPANET that was designed for multiple redundancy. It is a highly redundant network that transparently routes messages over available connections.
Nope.

Ethernet came out of Xerox PARC in the 70s (Source: https://en.wikipedia.org/wiki/Ethernet).

Mesh networks appear to date from the late 90s. (source https://en.wikipedia.org/wiki/Mesh_networking)

The internet developed from ARPANET and it's a packet switched network not a mesh one.

Ethernet is not a requirement for the internet. Internet proctocols have been implimeted over serial (PPP/SLIP for dial up internet). carrier pigeon (https://en.wikipedia.org/wiki/IP_over_Avian_Carriers), a soggy piece of string (https://www.bbc.com/news/technology-42338067), and many other media.

I suspect you're confusing a hardware level technology (ethernet) with a high level software one (IP aka the internet).

Regardless of that, a switch provides no redundancy. If it goes down so does all networking for machines behind that switch. Given that a switch sits between machines (so they are not directly connected) by definition that can't be a mesh network. Well not as I understand it anyway.

Eitherway we're getting far away from @treefella's question. Which can't be answered without more information from them. Though I suspect the answer is either "it depends" or "not without additional hardware".

@treefella: if performance isn't a major requirement ethernet can be added to any Pi over SPI, for example https://raspi.tv/2015/ethernet-on-pi-ze ... on-your-pi
This space unintentionally left blank.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 7:44 pm

thagrol wrote:
Sun May 19, 2019 2:47 pm

I suspect you're confusing a hardware level technology (ethernet) with a high level software one (IP aka the internet).

Regardless of that, a switch provides no redundancy.

You are obviously in a very argumentative mood. Aren't we all trying to help others?

The hardware provides multiple redundant connections, if it is connected that way. You can have multiple switches and routers and the IP stack on top of that hardware can use those redundant connections to deliver data even if multiple switches, routers, servers or backbones fail. IP can't do better than the hardware is capable of. If you run a bridge on your one USB host IP has no way to route round faults. Ethernet hardware can be connected as a mesh rather than a star / tree.

You can connect a RPi to router by both WiFi and Ethernet so that if one interface fails the other still works. You can connect WiFi to a router and Ethernet to a separate Ethernet switch.
Examples of network topologies are found in local area networks (LAN), a common computer network installation. Any given node in the LAN has one or more physical links to other devices in the network; graphically mapping these links results in a geometric shape that can be used to describe the physical topology of the network. A wide variety of physical topologies have been used in LANs, including ring, bus, mesh and star.

https://en.wikipedia.org/wiki/Network_t ... chnologies
In contrast standard USB hubs can't be connected to provide automatic redundancy.If a hub fails every device connected downstream of it loses connectivity.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 8:18 pm

This thread touches on mesh WiFi networks on Pi and mentions BATMAN. Could be relevant.

https://www.raspberrypi.org/forums/view ... 3#p1470093

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Sun May 19, 2019 9:46 pm

PiGraham wrote:
Sun May 19, 2019 7:44 pm
thagrol wrote:
Sun May 19, 2019 2:47 pm

I suspect you're confusing a hardware level technology (ethernet) with a high level software one (IP aka the internet).

Regardless of that, a switch provides no redundancy.

You are obviously in a very argumentative mood. Aren't we all trying to help others?
I am trying to help folks by clearing up some incorrect information.
The hardware provides multiple redundant connections, if it is connected that way. You can have multiple switches and routers and the IP stack on top of that hardware can use those redundant connections to deliver data even if multiple switches, routers, servers or backbones fail. IP can't do better than the hardware is capable of. If you run a bridge on your one USB host IP has no way to route round faults. Ethernet hardware can be connected as a mesh rather than a star / tree.

You can connect a RPi to router by both WiFi and Ethernet so that if one interface fails the other still works. You can connect WiFi to a router and Ethernet to a separate Ethernet switch.
Sure but that isn't what you suggested or what we were talking about (a bunch of Pi connected via USB to a server/host vs a bunch of Pi connected to a server/host via a single switch). Pi connected "to router by both WiFi and Ethernet" is not a mesh network. Please stop moving the goalposts.

There's a lot more to network redundancy than just having both WiFi and ethernet conections in the same LAN/subnet.

Your original suggestion provides no more redundancy than mine, and adds significant cost. Whether or not it provides better performance is unknown. That depends on both the precise hardware in use and the frequency and volumne of data being exchanged.
Examples of network topologies are found in local area networks (LAN), a common computer network installation. Any given node in the LAN has one or more physical links to other devices in the network; graphically mapping these links results in a geometric shape that can be used to describe the physical topology of the network. A wide variety of physical topologies have been used in LANs, including ring, bus, mesh and star.

https://en.wikipedia.org/wiki/Network_t ... chnologies
I'm not entirely sure how that's relevant. And again, if every node does not have a physical connection (I include point to point WiFi as a physical connection but not WiFi via an AP) to every other node it's not a full/true mesh network.

The solution you gave was a bunch of Pi connected via ethernet to a switch. That's not a mesh, that's a star or a tree depending on how many switches you have and how they're connected. Or a combination of both.
In contrast standard USB hubs can't be connected to provide automatic redundancy.If a hub fails every device connected downstream of it loses connectivity.
Same thing with an ethernet switch. Especially an unmanaged one.

I don't believe I ever claimed otherwise for USB.

The whole multiply linked switches for redundancy thing can get very complicated very quickly leading to loops and floods of broadcast messages. Read up on spanning tree protocl or ask a network admin (I ain't one).

AIUI, the simple case of wired ethernet with fall back to WiFi only works because the computer will only use one of those interfaces at a time even though both may be connected. And even then other devices making new incoming connections to that computer will likely have problems until DNS catches up with reality. That's if your DNS server and clients can cope with multiple IP address for the same hostname.

To those who may think I'm be needlessly argumentative or pedantic:
  1. Without everyone using the same terms to mean the same things accurate comminication is impossible.
  2. There's a lot of misleading, poor, or simply wrong information on internet forums (and the internet in general). Today happens to be a day when I feel able to attempt to correct a tiny portion of it.
  3. The goalposts appear to have moved beneath my feet.
Giving up now largely due to an Out of Cheese Error and not being arrogant or childish enough to descend into sticking my fingers in my ears and shouting "I'm right, you're wrong" repeatedly.
This space unintentionally left blank.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23326
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPI acting both as slave and as master device on its usb ports

Mon May 20, 2019 8:40 am

Let's keep it on topic shall we? And without the arguments.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

treefella
Posts: 9
Joined: Thu Mar 24, 2016 11:59 pm

Re: RPI acting both as slave and as master device on its usb ports

Tue May 21, 2019 1:16 am

Oh hey guys didn't mean to start a riot here haha....

Not sure if "Mesh Network" is the correct term here. Open to correcting my terminology as it may help me in my searches.

Some details on my use case:

I am developing a system for modular video synthesis with raspberry pis. The idea is to route GPU accelerated video processing by sending video feeds around with the NDI Protocol (https://www.newtek.com/ndi/). This is what many video artists use in Resolume and other "Video DJ" software. The rationale behind doing LAN/NDI is that converting to composite (or HDMI) and back is pricy and would get even more costly as you venture into higher resolutions. Ideally setup would be as simple as daisy chaining multiple pis with something like ethernet or USB on a single physical tabletop (no long range cables necessary).

I was wondering if it is possible to just have 2 USB ports on each pi in a system (lets say 2-4 devices) and send around these NDI packets over a network connection. I have this working with ethernet on a switch on my PI3s and it works well. However the LAN controller takes a bunch of current and when I found out its implemented through the USB channels anyway I figured there must be some way to just pass the network along via USB.

So my question is:
Hardware wise, how do I have 2 devices connected to a given pi, sharing a network and passing it along a larger chain of pis? Is it possible to have this be "effectively" de-centralized as far as the end user is concerned?
Last edited by treefella on Tue May 21, 2019 7:02 pm, edited 2 times in total.
Ron Sardarian
instagram.com/teafela/
teafella.com

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RPI acting both as slave and as master device on its usb ports

Tue May 21, 2019 11:43 am

treefella wrote:
Tue May 21, 2019 1:16 am
Oh hey guys didn't mean to start a riot here haha....

Not sure if "Mesh Network" is the correct term here. Open to correcting my terminology as it may help me in my searches.
Not gonna go there ;)
Some details on my use case:
<snip>
I was wondering if it is possible to just have 2 USB ports on each pi in a system (lets say 2-4 devices) and send around these NDI packets over a network connection. I have this working with ethernet on a switch on my PI3s and it works well. However the LAN controller takes a bunch of current and when I found out its implemented through the USB channels anyway I figured there must be some way to just pass the network along via USB.

So my question is:
Hardware wise, how do I have 2 devices connected to a given pi, sharing a network and passing it along a larger chain of pis? Is it possible to have this be "effectively" de-centralized as far as the end user is concerned?
Firstly, I would advise against using a daisy chain approach. For two main reasons (using A - B - C - D as an example config):
  1. Performance. Every packet from machine A to machine D has to go through machines B and C. This reduces available bandwidth between them and adds load on their CPUs.
  2. Vulnerability. If B goes down A can no longer reach C or D.
As you're using Pi 3, you cannot go down the USB ethernet gadget route as the on board USB hub prevents them acting as USB slave devices.

If you're determined to go down the daisy chain route, each Pi (except the ones at each end) will need two ethernet interfaces and you'll need to configure those as a bridge. Or you alternate the links between ethernet and WiFi (A wired to B, B to C via WiFi, C wired to D, etc.) or bluetooth but that would require routing/NAT rather than bridging so would add complexity.

Addiditonal ethernet interfaces can be added by USB (fastest) and SPI (slow). There are SPI to USB chips out there, and at least one person has used them with Pi but I've no idea if they can do slave mode and will likely not provide enough bandwidth.

Given that you're using Pi 3, that they have on board WiFI, that you don't want a network switch, and subject to bandwidth requirements you should probably investiagte WiFi AdHoc networks (https://wiki.debian.org/WiFi/AdHoc that link is for debian from which raspbian is derived) or true WiFi mesh networks (hit your favourite search engine)

You could build a mesh network over wired ethernet but bear in mind that:
  • Each node must have as many ethernet interfaces as there are other nodes (for N nodes that's N - 1 interfaces)
  • Because the ethernet intefaces are connected via USB total bandwidth will be limited by that provided by USB. Expect slow downs for high bandwidth applications once you go beyond two or three interfaces (USB 2 provides 480Mb/s bandwidth less overhead)
Another alternative would be to have one of your Pi 3 with multiple ethernet interfaces each connected to one other PI and those interfaces configured as a bridge. That doesn't decentralise your network but does remove the need for a switch as a Pi performs that job. Though, again, this won't scale well due to limitation in USB bandwidth.

Frankly, if you need high performance you need to find a switch whose current draw fits within what you have available.

I'm not able to help further with AdHoc or mesh networking as I've never had to use either.

Don't forget that you'll likely need to provide a DHCP server somewhere or configure static IPs for everything.

Oh, and your link to newtek is broken.
This space unintentionally left blank.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Tue May 21, 2019 2:49 pm

treefella wrote:
Tue May 21, 2019 1:16 am

So my question is:
Hardware wise, how do I have 2 devices connected to a given pi, sharing a network and passing it along a larger chain of pis? Is it possible to have this be "effectively" de-centralized as far as the end user is concerned?
Two devices? Is that all you need, one host and two slaves?
In what sense do you want it "decentralised"?
The more clearly you can describe what you want to do the better people making suggestions can focus in.

It seems power consumption is important to you. What is your target for the whole system? How many Watts?
How many devices?
What data throughput between host and slave?
Do slaves need to communicate with each other, is so what throughput?

I should think you would get better performance with dedicated network switch(es). A Pi can bridge network segments but that is an extra task. Maybe not significant load. It may depend on what network throughput you have.

Surely you can get a network switch that consumes power comparable to a Raspberry Pi.
This one from TPLink is specified at 2.4W Max and claims various power saving features.


Still, if you need so few devices you could use USB. If you had a Pi 3B+ as the host device and two Pi Zeros in Ethernet Gadget mode.
You could have up to four slaves on the four USB host ports of the 3B+

You might get better performance using 3B+ as slaves given they have more CPU grunt, and they don't run as USB gadgets, so in that case connect via Ethernet.

PiGraham
Posts: 3574
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: RPI acting both as slave and as master device on its usb ports

Tue May 21, 2019 3:22 pm

I found what I take to be the newtek site
https://www.newtek.com/ndi/

Return to “General discussion”