Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Is TCP communication allowed in-game? (http://www.chiefdelphi.com/forums/showthread.php?t=100102)

Lalaland1125 13-01-2012 21:21

Is TCP communication allowed in-game?
 
Our team is planning to process images on the Classmate. Our plan is to simply open a socket on the classmate on a high number port and simply push data back and forth using TCP. This obviously works right now in testing.

My question is: Can we do this during competition? Are teams allowed to communicate with their robot from a background task on the Classmate over TCP on a high number port?

(I know there will be speed issues due to network congestion etc, during the competition).

bdbayes 13-01-2012 21:25

Re: Is TCP communication allowed in-game?
 
See the rule below.

Quote:

[R53]
Connections to the cRIO Ethernet ports must be compliant with the following parameters:
The DAP-1522 wireless bridge is connected to the cRIO Ethernet port 1 (either directly or via a CAT5 Ethernet pigtail).
Ethernet-connected COTS devices or custom circuits may connect to any remaining Ethernet ports; however, these devices may not transmit or receive UDP packets using ports 1100-1200 except for ports 1130 and 1140.

~Cory~ 13-01-2012 21:30

Re: Is TCP communication allowed in-game?
 
We are also persuing this method. However, one must be VERY careful as to not cause excessive bandwidth/other bottleneck issues because the fms people will complain.

In previous years they had a screen that shows network data for each robot and a log so no funny business::ouch::

Lalaland1125 13-01-2012 21:39

Re: Is TCP communication allowed in-game?
 
So, it seems like there are two main rules:

1. Do not use those port numbers in the range 1100-1200.

2. Try not to act like you are running a Denial of Service attack on the network.

ratdude747 13-01-2012 21:45

Re: Is TCP communication allowed in-game?
 
1 Attachment(s)
you could use the camera direct to the classmate/laptop last year via a special labview .vi for the dashboard (I have a copy if anybody wants it to play with). Last I checked they still are using the 4 port AP's on the bot (only way to use them with the 4 slot crio), so if you connect the camera there, you can view the camera from the dash via the special VI.

I think that is legal... that looks to be the same rule as used in 2011.

edit- attached the .vi

Joe Ross 13-01-2012 22:23

Re: Is TCP communication allowed in-game?
 
Quote:

Originally Posted by ratdude747 (Post 1104907)
you could use the camera direct to the classmate/laptop last year via a special labview .vi for the dashboard (I have a copy if anybody wants it to play with).
edit- attached the .vi

This is included by default this year.

shuhao 14-01-2012 00:07

Re: Is TCP communication allowed in-game?
 
How are you getting the TCP comm link to work?

I'm currently unable to find the networking API from java..

ratdude747 14-01-2012 00:10

Re: Is TCP communication allowed in-game?
 
Quote:

Originally Posted by Joe Ross (Post 1104928)
This is included by default this year.

cool... since I am no longer actively involved with a team this year, I didn't know. Sorry about that.

Lalaland1125 14-01-2012 10:24

Re: Is TCP communication allowed in-game?
 
Quote:

Originally Posted by shuhao (Post 1105039)
How are you getting the TCP comm link to work?

I'm currently unable to find the networking API from java..



http://ideone.com/9dM5E
That's our code as of roughly now(I think the only change was that the robot does not support UTF, so we just switched that to ASCII or something).

javax.microedition.io is where the magic is.

If you want I can give you our server-side code, but it's just standard socket opening and accepting a connection(in C++ that is).

shuhao 14-01-2012 11:08

Re: Is TCP communication allowed in-game?
 
Quote:

Originally Posted by Lalaland1125 (Post 1105197)
http://ideone.com/9dM5E
That's our code as of roughly now(I think the only change was that the robot does not support UTF, so we just switched that to ASCII or something).

javax.microedition.io is where the magic is.

If you want I can give you our server-side code, but it's just standard socket opening and accepting a connection(in C++ that is).


Why can't you just go with message = m_inputStream.readUTF(); instead of all that, which should do the same thing? and same for outputStream with writeUTF

pspeer 15-01-2012 14:22

Re: Is TCP communication allowed in-game?
 
Has anyone been able to get TCP communication from the DriverStation to the cRIO using C++?

Does WPILIB support the use of TCP/UDP sockets?

MohammadAdib 19-01-2012 16:10

Re: Is TCP communication allowed in-game?
 
Quote:

Originally Posted by shuhao (Post 1105039)
How are you getting the TCP comm link to work?

I'm currently unable to find the networking API from java..

In normal Java there are easy ways to implement a client server solution. From what i have seen/learned/experienced, it is always noteworthy that a client and server should talk with each other as little as possible while still maintaining communication. If your program requires sending a large amount of small data (such as coordinates) back and forth, then i suggest that you disable Nagle's algorithm, otherwise all of your small TCP packets will be made into one big packet and get sent, and that can mess things up quite a bit if you have some sort of command parser on the other side waiting to read the packets u send. Now that being said, in my opinion the ideal solution is to have the classmate running a server application listening on an open ServerSocket. A client will be on whatever you decide to send data to the classmate with which will try to connect to the classmate via some method of network communication. Then you can let the data flow. But if you are sending small amounts of data (< 1kb) then i recommend using a DatagramPacket (UDP). Regardless how you do it, Here is a useful site on making server and client solutions in Java: http://systembash.com/content/a-simp...nd-tcp-client/

If you have any technical questions about ANYTHING feel free to email me or something.

EDIT: I forgot to mention an extremely critical thing. Always make your servers threaded! That means for every client that connects to the ServerSocket on your server application, start a new designated thread for handling communication. If your server talks back, then also start another thread for sending info on the socket. Without threading, performance will TANK.

MohammadAdib 19-01-2012 16:55

Re: Is TCP communication allowed in-game?
 
1 Attachment(s)
I just wrote and tested this very simple code for a threaded TCP server template using Java. The server is fully threaded and can read input from incoming clients. There is no limit to how many clients can connect. It uses a thread to search for new clients and once a client connects another thread is started for reading input from that client's socket.

Feel free to use the code as it is a template, but please do not remove the credit comment on the top ;)

Download the file from below:

pavanetti 19-01-2012 19:11

Re: Is TCP communication allowed in-game?
 
I did so:
http://www.chiefdelphi.com/forums/sh...d.php?t=100558
(Post 5)

shuhao 19-01-2012 21:33

What do you guys think about a restful server so it will be easier to develop and test for?

I feel like a constant connection is not necessary. Also, how are you guys structuring rthe network? Server on laptop or server on crio. The formal seems simpler


All times are GMT -5. The time now is 23:24.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi