Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Communication between ships

Discussion in 'Programming Questions and Suggestions' started by A2K, Jan 3, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. A2K Trainee Engineer

    We need a method to send data between ships.

    There is already antenna block which is supposed to be used for communication.

    Here is how this could look like:

    void HandleMessage(string) method can be implemented in programmable block, it will be called if message is received from other ship
    IMyRadioAntenna can have SendMessage(string shipName, string message) method to send messages to specific ship in range.
    IMyRadioAntenna can have BroadcastMessage(string message) method to send messages to all ships in range.
  2. sioxernic Senior Engineer

    In that case I'd honestly prefer if it was only Broadcast, which means if you want to have a secure connection between two ships you will have encrypt your data yourself somehow, although the HandleMessage should also return the name and owner (Including faction) of the ship sending the message.
    • Like Like x 1
  3. elch Apprentice Engineer

    Hmm, why not just have some remote control object on each grid which holds updated list of all the grids which are in the broadcasting range and have antenna with broadcasting ON.
    You could inquire the name in the list and ask to be returned the grid object of the particular grid.

    Having actual messages could be rather complex and it's not really in the spirit of how the interface is done now.
  4. RTM Apprentice Engineer

    Is there a way to read existing antennas or beacons from the programming block and get what they say?'
    If you could do that, you could easily build a text-message sending program.
  5. elch Apprentice Engineer

    Yes but only on a single grid where both the beacons and antennas are placed.
    You can't read antennas and beacons on remote grids to my knowledge.
  6. mhalpern Senior Engineer

    access to the antenna network is not available through scripting yet.
  7. A2K Trainee Engineer

    I think I can make a mod to exchange information between antennas by manipulating their block names. But to make this work correctly there must be a programmable block on receiver grid which would run in a loop (using timer) and will reset antenna name after processing a message. I don't know any other way to send data into Programmable Blocks.
  8. shimonu Apprentice Engineer

    Block 1 (receiver) reading block2 (sender, on other ship). Check if booth are connected using antenna to work (and to make sure noone could get it). Maybe something like ship_name.block_name:Data_to_send/data_to_receive. Few receivers to read from one sender?
    What do you think? (and please no using antennas and beacons if You can, too many info on those already :D)
  9. Decker_MMIV Trainee Engineer

    I'm bringing forth this old topic, due to a comment I've read in one of the 'Pull Requests' (#400) on GitHub, where JoeTheDestroyer writes; "[..] The main thing preventing us from adding PB access to the antenna network is this exploit [..]".

    I guess we can agree upon, that the IMyRadioAntenna and IMyLaserAntenna block interfaces would become more useful for PB scripts, if those block interfaces had some kind of Send/Receive methods.

    Looking at other GitHub PRs; #75 and #143, there have been suggestions for implementing such a feature. - However those PRs, from reading the comments by their authors, seem to be 'reliable message communication that triggers a PB script at the receiver'.

    What if ship-to-ship communication via radio-antennas isn't supposed to be 'reliable'? And what if the receiving antennas isn't supposed to 'trigger a PB'?

    My suggestion: How about adding a feature for sending messages via;
    - IMyRadioAntenna, which is unreliable due to one-to-many and distance/radio-wave affected communication,
    - IMyLaserAntenna, which will be a bit more reliable due to one-to-one "locked-in" communication,
    where the antenna block itself keeps a 'short-term queue of received messages'.

    This 'queue' (FIFO) must have a limit to the amount of received messages it can hold, and when receiving new messages, any old ones that hasn't yet been 'read' by a PB script will be discarded. - Perhaps this 'short-term queue' should automatically discard 'unread' messages that are older that 10 seconds?

    The ingame interface methods I suggest added to IMyRadioAntenna and IMyLaserAntenna would simply be;
    // SendMessage
    // Instructs antenna block to attempt to send the given message-text to whatever available other Radio-/LaserAntenna(s)
    // that may be listening or are in range of this antenna block.
    // Using a RadioAntenna will be unrestricted one-to-many and unreliable delivery of the message (e.g. "broadcast"),
    // where as using a LaserAntenna is one-to-one communication but still cannot guarantee a 100% reliable message delivery.
    // The 'message' string have a limit of maximum 256 characters. Anything above will not be sent.
    void SendMessage(String message);
    // ReadMessage
    // Allows a PB to read the next message, if any, from the antenna block's short-term FIFO queue of received messages.
    // If no message was available, an empty/blank string is returned.
    String ReadMessage();
    • Like Like x 1
  10. JoeTheDestroyer Junior Engineer

    The limited message queue has been proposed before. The biggest problem I see w/ your proposal is the one-to-many broadcast. First, with the limited queue, a DoS attack against other players would be child's play. Also, I think you might be able to abuse it to destroy a server's performance.

    I think the reason people were down on those other PRs is because they are less than ideal. The desired solution is for the PB to have the same access to remote grids as we do (i.e., direct control of remote blocks). While message passing can accomplish that, it would require a lot of support code to do it and thus (unnecessary) performance drain on the game/server.
  11. Decker_MMIV Trainee Engineer

    Granted that, if implemented wrongly in the game-engine (not taking K#/PB script here), such feature could be used to cripple the server.

    So what if the antenna block gets an extra property; "Listen to messages only from:" - where the available values would be the same as the existing feature of 'block ownership'. I.e.: "Nobody" (default), "Me", "Faction", "Everybody".
    This should allow the owner of the receiving antenna block, to control the amount/type of "unsolicited messages" that particular antenna block would receive and buffer in its short-term queue.

    Please also note, I wrote that a radio-antenna should be an unreliable method of sending messages in-game. - So wouldn't/couldn't this allow the game-engine to just ignore excessive calls to the IMyRadioAntenna::SendMessage() method from a "runaway (or DoS) K# script"? - Who says that the IMyRadioAntenna's one-to-many "broadcast" should be issued every frame (game tick)? Maybe only execute the "send last instructed message to other antennas in range" every 10th or 100th frame? - Radio-antennas should not relay these received messages.

    Besides, if I understand the SHIFT+F11 information correctly, the network msg-packages that are generated by setting an LCD/Text Panel via K# script - in a multiplayer setup (not singleplayer) - could just as easily be problematic, when triggered at a high frequency? I do hope such msg-packages have a lower priority on a stressed server.
  12. JoeTheDestroyer Junior Engineer

    At a glance, this seems like it would work.

    Until this:
    And now we're back to being able to DoS again. If you limit it by in-flight message count, I just need to send more messages. If you limit it per antenna, I'll just build more antennas.

    That's not really what I was talking about. There are ways to write an in-game script to bring the game to a halt, single-player or multi-player. But it's only of significant concern in multiplayer.

    I don't want to get into details, but these methods rely on exponential growth and exploiting work done in functions untracked by the in-game scripting environment. My comment was made because it felt like your proposal could be used to setup such an exponential growth pattern.


    It's moot for me personally anyways, because I don't support the basic idea of a message passing interface, fixed or not. Providing a remote GridTerminalSystem-like interface is the ideal solution, and I can't support anything lesser for fear that if it was implemented we'd never get the better solution.
  13. Immersive Apprentice Engineer

    Remote GridTerminalSystem is ideal, definitely. In the interim, simply being able to see the full names (block name and grid name, if set to broadcast such) of broadcasting antennae in range would be sufficient for a basic text-messaging service. I do, however, disagree with message-push and action-on-message-received.

    Having a message-pull (or "observer", effectively a poll) system negates the possibility of DOS attack, as it's impossible to "force" messages upon a particular receiver. It does also open up some interesting SIGINT possibilities where an enemy may be "listening in" to the broadcasts while they themselves remain silent. Laser antennae would, of course, provide a "secure" link without any extra changes required.

    PBs would be required on both grids and you'd have to work out your own transmission protocol but it would be doable.
  14. Newton Trainee Engineer

    Just an idea - why not give PB access to ingame chat (writing and reading) through IMyAntenna interface? This would be very useful and perhaps wouldn't be as exploitable?
  15. Dvyn1 Trainee Engineer

    Here is a solution to the ship to ship comm that I am considering for my full conversion mod which I'm working on but is way beyond the scope of just me.
    Add a member to antenna objects that a pb or script on the same grid can write data to it. and an other method that sees the data from all other antennas in range realtime.
    this makes a garbled mess but if the script is programmed to filter headers and transport layer decoding and encoding the an effective and "realistic" comm system can be created.
  16. Phoera Senior Engineer

    game already have cross-grid communication in vanilla.
Thread Status:
This last post in this thread was made more than 31 days old.