Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Capturing Non-Unity Network Traffic?

Discussion in 'Multiplayer' started by devook, Jul 15, 2013.

  1. devook

    devook

    Joined:
    May 21, 2013
    Posts:
    11
    I'm working on creating a virtual simulation in Unity3d for a real-world robotic assembly line testbed we have set up at my university. The testbed consists of a network of pneumatic devices, conveyer belts, and some 24V I/O lines for various things that need to be turned on/off. I've had little trouble creating the virtual environment, but the second part of the project is to interface the simulation with the testbed's network. The idea is that we could plug the simulation into our SoftPLC (which communicates with EtherNet/IP), capture the packets it sends out, and make the virtual environment respond in the same way the real-world testbed would.

    My first question is simply: is this possible? I've been looking at Unity's networking references and it seems like most of Unity's networking stuff is limited to Unity <-> Unity communication. Is there a way to make a Unity program simply capture packets being sent to the machine's IP? Or even better, is it possible to intercept ALL LAN traffic? Our testbed operates on a local network using a managed switch without any WAN connection.

    I'm afraid my knowledge of network communication is rudimentary so please feel free to tell me if I'm obviously wrong or off-base about something. I know there's probably not a simple answer to this question but I'd appreciate any links to references that I could research or any advice anyone might have.
     
  2. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,102
    Unity uses Mono for scripting. Mono is open source implementation of Microsoft's .NET framework, so you can use all classes of System.Net namespace of .NET to do networking. Take a look at any C# networking tutorial to see some examples.
    Be aware that you should do all of your networking stuff on other threads and don't block the main unity thread for them.
    Also when returning from the thread, execute unity code in the main thread.
    What protocol are you using for your hardware?
     
  3. devook

    devook

    Joined:
    May 21, 2013
    Posts:
    11
    Thank you for the response! Some previous googling led me to a similar thread with a similar response. I am currently digging for C# networking tutorials and simple implementations to see if I can get a grasp on the methods. It's looking like writing drivers from scratch may be outside of my envelope of understanding.

    We haven't made a definitive decision on what controller we will be installing, but we are positive that we will be using the EtherNet/IP protocol.
     
  4. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,102
    Hope it goes well for you. In case you needed help we provide both support and development in our company. Feel free to mail us.