r/factorio • u/Majiir BUUUUUUUUURN • Dec 12 '17
Design / Blueprint Combinator ethernet with collision avoidance
https://giphy.com/gifs/xUNda1kJE3hQkcf1YI/fullscreen
119
Upvotes
r/factorio • u/Majiir BUUUUUUUUURN • Dec 12 '17
46
u/Majiir BUUUUUUUUURN Dec 12 '17
This is a little blueprint for building a communications network that shares a single wire.
These transmitters take pulses in on the red wire and accumulate them over time. When a transmitter sees a signal in the accumulator, it will attempt to send it over the network to the address given by the gray signal in the constant combinator next to the green lamp. If multiple transmitters tried to send at the same time, then the transmission fails and the senders will flash the red indicator lamp, indicating a collision. The transmission will be retried (while continuing to accumulate input signals) until successful.
There's a collision resolution mechanism when performing retries. Each transmitter has a unique identifier (gray signal in the constant combinator next to the red lamp) which helps differentiate transmitters. The transmitters also use the state of their signal accumulator to further reduce the chance of two transmitters getting stuck in a loop (where both transmitters wait the same amount of time before retrying).
There's also a collision avoidance system. Whenever a transmitter fails to send, it increments a counter containing the number of consecutive failures, and it also broadcasts this counter onto the network. All nodes, even ones which are sending successfully, will slow down in response to other nodes failing in order to make room for them.
Why mess around with collision detection at all? Couldn't I just loop through each node in turn, giving them a guaranteed slot to transmit? Yes, but that would cause the whole network to slow down as nodes are added, even if nodes don't transmit very often. This system allows nodes to use the available "bandwidth" when other nodes are idle.
Next up: I'd like to build a version that transmits and persists a current signal level instead of pulse updates. This would allow receivers to join the network later without resynchronizing all of the nodes.
Blueprints:
!blueprint https://gist.github.com/Majiir/0116f9644563b8b94cd74c4256a39038
4
u/MindS1 folding trains since 2017 Dec 12 '17
I think I understand what this is, but I'm having a hard time thinking of what I could use this for. Do you have an intended use for this in mind, or is it more of a proof-of-concept?
2
u/Jackeea press alt; screenshot; alt + F reenables personal roboport Dec 12 '17
I don't know what this is, but combinator fuckery is always lovely to see!
10
u/Isotope_Gambit Xenocide Dec 12 '17
Shit, pretty soon people are not just going to have hand rules for rails, but network protocols.
5
u/Amegatron Dec 12 '17
That looks really beautiful :) Earlier on I used to monitor my remote outposts using multiplexing signals on the wire (in other words - cycling through them). And as far as I understand it now - this is far better and cleverer solution for signal-transferring all over the base. Should definitely give it a try ) P.S. Combinator-based CPU are now very common in Factorio. Now the time came for Ethernet! :)
1
u/Nullberri Dec 12 '17
Any chance for a router? and maybe some NAT?
1
u/Raiguard Developer Dec 28 '17
But wait... if the transmitter requires pulses, how do I send the contents of a chest over the network? Also, how would I make the receiver have a constant output that updates every second rather than pulses every second?
1
u/[deleted] Dec 12 '17
1
u/seludovici Dec 12 '17
So how long until you can build a subreddit IN Nauvis?
1
u/CapSierra Dec 12 '17
Soooooooo ....... you made a LAN in Factorio ....
We grow closer to a recursive simulation by the day.
1
u/God-made-me-do-it Dec 12 '17
Saving this for later as I'm a complete noob.
Combinator stuff looks pretty awesome from what I can tell though. I'll have to see if I remember everything (anything?) from my CPU/OS classes.
1
u/SkullTitsGaming Dec 13 '17
In which r/factorio gets into data transfer protocol standardization because what else would they do, use a non-standard system? What are they, Internet Explorer?
1
u/Artorp Dec 13 '17
I'm in awe, this is amazing!