This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KillaVanilla's profile picture

Transmission Effects on Wireless Rednet

Started by KillaVanilla, 01 January 2014 - 01:16 AM
KillaVanilla #1
Posted 01 January 2014 - 02:16 AM
I've run a search on "corruption" and "static" and found no topic titles that directly spoke about this, so here goes…

I think that adding destructive effects to wireless rednet transmissions would provide an interesting challenge for those writing communications programs and such. (I'm thinking of file transfer programs)
The effects could vary based on the amount of interference, the distance between the sender and receivers, environmental effects, and so on.

This could also provide some kind of alternative for the "hard" limit for rednet transmission distance; instead of messages simply not being received past the range limit, messages could grow more and more corrupted as the distance grows before reaching the point where the orignal message cannot be recovered.

For example, with a rednet distance limit of 128 blocks on a clear day, rednet messages could be effected along these lines (barring noise effects):
  • 0 - 64 blocks: No effects. Messages are always received clearly in the absence of channel noise.
  • 65 - 96 blocks: Minor effects. Messages receive a minor amount of distance-related corruption. (1 character out of ten, which should be configurable)
  • 97 - 128 blocks: Moderate effects. Messages receive more corruption due to distance. (3 or 4 characters out of ten, or to taste)
  • 129 - 161 blocks: Severe effects. Messages receive even more corruption due to distance. (6 to 8 characters out of ten, or to taste)
  • 162 - 226 blocks: Messages are simply received as pure garbage.
  • 227+ blocks: Messages are not received.
The weather could also effect the amount of "distance-related" corruption incurred; similar to how thunderstorms already reduce the receivable range of transmissions, they could also increase the amount of corruption to messages transmitted.

In my mind, interference effects would manifest the same way, but the amount of corruption would depend on the total "activity" on the channel and "nearby" channels in the past few seconds or so.
For example, programs that transmit huge "bursts" of data all around the same time (like my routing protocol) would get heavily corrupted even if they were relatively close together. The effects of channel noise shouldn't be limited to one channel, as well: Transmissions on one channel should effect "adjacent" channels too. (e.g transmissions on channel 5 increase the "background noise" level of channel 1).

Interference effects could work as follows:
Each channel could have a counter indicating how much interference is present, as a probability of any one character in each message being corrupted, similar to how distance effects.
This counter should range from 0 to 1.
When a message is transmitted, the counter could be incremented like so:

(.01 + ( floor(#message / 10) / 100 )  )
In other words, each message transmitted increases the percentage of corruption by 1%, then increases it further depending on the length of the message transmitted (1% of interference increase per 10 characters); longer messages create more interference.
Interference should also "seep" into adjacent channels; when a message is transmitted on channel n:
  • 50% of its "interference level" should be added to the two channels directly adjacent to it. (i.e channels n+1 and n-1)
  • 40% should then be added to channels n+2 and n-2.
  • And so on, with appropriately decreasing levels of interference being added, with 10% being added to channels n+5 and n-5, and none being added for any channels past that.

However, the counter could be decreased by one-half every tick, finally resetting to zero once it gets below 1%.

As an example: let's examine the interference caused by 4 computers using the GPS program, with one computer (or Turtle) attempting to triangulate its position and the other three providing fixes.
For simplicity's sake, let's assume that the hosts have three-digit X, Y, and Z coordinates.

The position fixes would be transmitted as such: "{[1]=XXX, [2]=YYY, [3]=ZZZ}", with a message length of 26.
This would increase the "interference counter" by 3% for each host / fix.
Taking the initial ping message into account as well as the other two messages into account, each position request would increase the interference counter by 10%, which would fade after 4 ticks, or 0.2 seconds.
This would only increase as more hosts are added.
Five turtles attempting to determine their position at once would increase the corruption rate to 50%, before distance effects.
This type of corruption could be avoided by spreading out GPS requests, like so:

local gps_delay = 4
local delay_timer = -1
local GPS_CHANNEL = 65534
local modem = peripheral.wrap(MODEM_SIDE)

function GPS_Delay_Coroutine()
	delay_timer = os.startTimer(0.05)
	while true do
		local event, side, sCh, rCh, msg, dist = os.pullEvent()
		if ((event == "modem_message") and (sCh == GPS_CHANNEL)) then
			gps_delay = gps_delay+4
		elseif ((event == "timer") and (side == delay_timer)) and (gps_delay > 0) then
			gps_delay = gps_delay -1
		end
	end
end

function get_gps_position(timeout, debug)
	while true do
		os.sleep(0.05)
		if gps_delay <= 0 then
		   return gps.locate( timeout, debug )
		end
	end
end

function main_loop()
	-- ...stuff...
   local pos = get_gps_position()
   -- ... more stuff ..
end
parallel.waitForAll(GPS_Delay_Coroutine, main_loop)

The interference definitely needs some fine-tuning, but the basic idea should remain.


This would give us a use for error-correcting and error-detecting codes, at least. As I said above, it also gives us an interesting challenge to work around.
And for those who just want a sandbox to play with, this could easily be turned into a configuration option.
Edited on 02 January 2014 - 02:16 PM
gollark8 #2
Posted 01 January 2014 - 06:33 AM
It seems like too much data loss IMO.
And I have a computer-controlled IC2 nuclear reactor linked to my control console over wireless.
If one letter of the data sent got corrupted,boom goes the reactor.

(Yes,I know I said on another thread that I'm rubbish with networking code.After lots of looking through the wiki,I managed to work out how to do basic networking with rednet.)
Edited on 01 January 2014 - 05:33 AM
awsmazinggenius #3
Posted 01 January 2014 - 10:55 AM
What would we do with the new "rednet repeaters" in CC 1.6? And, I don't like the idea of corruption before the range limit, but after the message goes outside the area it is corrupted.
Symmetryc #4
Posted 01 January 2014 - 12:37 PM
Hmm sounds interesting, and should definitely be a config option that is off by default it were to be included. However, I could see people getting around this by using the length of a message to send it (i. e. a message of length 400 would be transformed into its binary equivalent and each byte of that would be transformed into a character)
Bomb Bloke #5
Posted 01 January 2014 - 05:03 PM
The idea is that people would have to work out ways around it - even sending a character at a time, you'd still need some sort of parity check. You'd just end up with a lot less re-sends then if you tried to transmit all 400 characters in one go.

Or are you thinking it's possible to send something other then strings via the networking APIs? Converting characters to numeric representations wouldn't help, it'd be a needless complication.
M4sh3dP0t4t03 #6
Posted 01 January 2014 - 07:27 PM
I like this suggestions, although the corruption rates you posted are a little bit high(30-40% while in normal range). Also, like awsmazinggenius already wrote, there would be some problems with repeaters.
awsmazinggenius #7
Posted 02 January 2014 - 01:34 PM
Yeah. I think the message should not be altered when it is sent within range, that's my only complaint.
KillaVanilla #8
Posted 02 January 2014 - 02:06 PM
What would we do with the new "rednet repeaters" in CC 1.6? And, I don't like the idea of corruption before the range limit, but after the message goes outside the area it is corrupted.

I like this suggestions, although the corruption rates you posted are a little bit high(30-40% while in normal range). Also, like awsmazinggenius already wrote, there would be some problems with repeaters.

Yeah. I think the message should not be altered when it is sent within range, that's my only complaint.

Which is why I said "…or to taste". I was thinking that the amount of corruption would be a configurable option, similar to rednet transmission range.

No one seems to have noticed the "noise" corruption effect as well.
gollark8 #9
Posted 02 January 2014 - 02:21 PM
Problem with noise from channels is that I happen to be working on a version of rednet that only takes up 1 channel.Which means that there would be loads of corruption on that channel.
And I have a lot of important stuff running over that,so I wouldn't be too happy if my messages got corrupted a lot.Especially since my API uses a table containing the frequency,message,uuid and other stuff,and if the frequency/uuid get turned into non-number values,crash goes the program.
Symmetryc #10
Posted 02 January 2014 - 02:43 PM
The idea is that people would have to work out ways around it - even sending a character at a time, you'd still need some sort of parity check. You'd just end up with a lot less re-sends then if you tried to transmit all 400 characters in one go.

Or are you thinking it's possible to send something other then strings via the networking APIs? Converting characters to numeric representations wouldn't help, it'd be a needless complication.
Sorry, I meant that the length of the message would be transformed from decimal to binary, and each byte of that into a character, not the message itself :P/>/>. So no matter how corrupted the actual message gets, the message will stood be understood because the length of the message is the only thing that matters, not what the characters are.

So let's say you had a message of length 8, it would become string.char(8) regardless of what was in the message itself.
Edited on 02 January 2014 - 01:47 PM
KillaVanilla #11
Posted 02 January 2014 - 03:24 PM
Problem with noise from channels is that I happen to be working on a version of rednet that only takes up 1 channel.Which means that there would be loads of corruption on that channel.
And I have a lot of important stuff running over that,so I wouldn't be too happy if my messages got corrupted a lot.Especially since my API uses a table containing the frequency,message,uuid and other stuff,and if the frequency/uuid get turned into non-number values,crash goes the program.
..Which is why you use error correction / retransmission, as well as sanity checking.
The whole point of this is requiring people to work around this and make more robust systems and protocols.

The idea is that people would have to work out ways around it - even sending a character at a time, you'd still need some sort of parity check. You'd just end up with a lot less re-sends then if you tried to transmit all 400 characters in one go.

Or are you thinking it's possible to send something other then strings via the networking APIs? Converting characters to numeric representations wouldn't help, it'd be a needless complication.
Sorry, I meant that the length of the message would be transformed from decimal to binary, and each byte of that into a character, not the message itself :P/>/>. So no matter how corrupted the actual message gets, the message will stood be understood because the length of the message is the only thing that matters, not what the characters are.

So let's say you had a message of length 8, it would become string.char(8) regardless of what was in the message itself.
Perhaps adding or removing characters should also be part of the corruption effects.

Also, concerning the interference effects: This opens up a lot of opportunities for malicious interference, especially because interference also "seeps into" adjacent channels.
For example: GPS uses channel 65534 for its transmissions. Meanwhile, Rednet (the API) uses channel 65535 for its broadcast transmissions (rednet.broadcast).
Therefore, a hostile computer that's spamming messages over the broadcast channel could easily interfere with GPS to the point where GPS fixes are hopelessly corrupted.
Likewise, a group of turtles repeatedly requesting GPS fixes could possibly render rednet broadcasts in the area indecipherable.


As I said in the OP: The amount of corruption needs to be adjusted.
The levels of corruption used above were meant to illustrate the basic idea.
Edited on 02 January 2014 - 02:27 PM
Lyqyd #12
Posted 02 January 2014 - 03:42 PM
It is highly unlikely that this would be added. Recent development teasers suggest that future versions of rednet will have message forwarding/repeater functionality built in to the API. In light of that change, which moves the burden of networking off of the user, it is difficult to imagine changes being made that add unnecessary and frustrating error checking to modem transmissions. If anything, users would work around it by simply sending everything several times and looking for the best match.

Separately, your suggestion doesn't make much sense due to being able to send more than just strings via modems.
Bubba #13
Posted 02 January 2014 - 04:17 PM
Yeah, I'm in agreement with Lyqyd here, which is unfortunate because I do very much like the idea and challenge. Anyway, if anyone is curious about how one might go about validity checking and error correcting, Computerphile has a great video that deals with the most basic concepts. It focuses primarily on extremely simple number transmissions, but the principles still apply. And it's cool.
Edited on 02 January 2014 - 03:18 PM
Bomb Bloke #14
Posted 02 January 2014 - 07:19 PM
Granted, I can't see this being added, but the idea's interesting enough that I'm tempted to write a version of the rednet API that implements it anyways. Easy enough for any user to add the distance/channel interference stuff, and handily, the GPS script doesn't use the rednet API anyways. It'd be interesting to see if/how people might deal with it.
KillaVanilla #15
Posted 03 January 2014 - 01:07 AM
It is highly unlikely that this would be added. Recent development teasers suggest that future versions of rednet will have message forwarding/repeater functionality built in to the API. In light of that change, which moves the burden of networking off of the user, it is difficult to imagine changes being made that add unnecessary and frustrating error checking to modem transmissions. If anything, users would work around it by simply sending everything several times and looking for the best match.

Separately, your suggestion doesn't make much sense due to being able to send more than just strings via modems.
That's a shame. It would have made things interesting.

Also, you can send other things than just strings via modems? I wasn't aware.
gollark8 #16
Posted 03 January 2014 - 01:12 AM
It is highly unlikely that this would be added. Recent development teasers suggest that future versions of rednet will have message forwarding/repeater functionality built in to the API. In light of that change, which moves the burden of networking off of the user, it is difficult to imagine changes being made that add unnecessary and frustrating error checking to modem transmissions. If anything, users would work around it by simply sending everything several times and looking for the best match.

Separately, your suggestion doesn't make much sense due to being able to send more than just strings via modems.
That's a shame. It would have made things interesting.

Also, you can send other things than just strings via modems? I wasn't aware.
You can definitely send tables over wireless,I'm using that for my networking API.
awsmazinggenius #17
Posted 03 January 2014 - 01:44 AM
In CC 1.6, you can send anything but functions and coroutines over modems.
Sebra #18
Posted 03 January 2014 - 02:43 AM
Is it means strings are not corrupted anymore? With code>127.

On topic: Error checking would make things worse. Smart people would increase quality, but others - quantity.
Even if simple delivering chances would be lower with distance, it will make people to increase traffic mindlessly. :(/>
theoriginalbit #19
Posted 03 January 2014 - 05:20 AM
In CC 1.6, you can send anything but functions and coroutines over modems.
Not completely true, I believe its only strings and tables, I believe numbers still don't work. Also it is possible to send a function, just not a function pointer…
M4sh3dP0t4t03 #20
Posted 03 January 2014 - 10:07 AM
In CC 1.6, you can send anything but functions and coroutines over modems.
Not completely true, I believe its only strings and tables, I believe numbers still don't work. Also it is possible to send a function, just not a function pointer…
https://twitter.com/DanTwoHundred/status/415974522475397120
theoriginalbit #21
Posted 03 January 2014 - 08:01 PM
Not completely true, I believe its only strings and tables, I believe numbers still don't work. Also it is possible to send a function, just not a function pointer…
https://twitter.com/...974522475397120
Ah ok, thank you, I missed that Tweet. Still though, it is possible to send a function, it always has been.
awsmazinggenius #22
Posted 04 January 2014 - 01:43 AM
Yep. I was mentioning CC 1.6
EDIT: Damn ninja - I posted this and it came up right after your self correction.
Edited on 04 January 2014 - 12:44 AM
robhol #23
Posted 04 January 2014 - 09:27 AM
I can't say I'm a fan. Completely artificial "let's mess up your stuff for no reason" doesn't sit well with me. I don't really see much reason to do it like that, since WiFi in CC already has limits in place.
KillaVanilla #24
Posted 05 January 2014 - 05:24 PM
I can't say I'm a fan. Completely artificial "let's mess up your stuff for no reason" doesn't sit well with me. I don't really see much reason to do it like that, since WiFi in CC already has limits in place.
It wasn't meant to "balance" things out, but rather is / was intended for those who wanted an extra challenge.
mlaga97 #25
Posted 20 January 2014 - 11:41 PM
I like to think of it as the modems have built in error-checking and resend capabilities. Besides, if you really want the extra challenge that bad then it would be rather simple to implement this yourself in lua by replacing the native rednet API in the ROM with your own code that checked the distance traveled by the message and then "corrupted" parts of the message. You don't need the Java end of the mod to be changed at all.
aaa #26
Posted 22 January 2014 - 08:26 PM
I agree with mlaga97, if this is not implemented, many features can be done with lua, rewritting the rednet API (and not using the peripheral methods).

I like some of the ideas, like the interference, and dislike others, but thy are mostly nerf to artifficially add dificulty.

You should try use only bundled cables or analogic redstone to communicate, and many of your desired challenges will "naturally" occurs (even more!)
Edited on 22 January 2014 - 07:26 PM