TCPUDP
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:TCP/UDP Assignment for ORF401
Solomon Abiola
April 11, 2012

The purpose of this program is to demonstrate the capabilities of a TCP/UDP system. While relatively straight forward to implement in Ruby, you run into a problem when you try and create a GUI interface, considering the level of robustness of your options out there. For this matter, the GUI employed here is actually the web browser.

Based on how this assignment works initially the client (host) communicates with two servers, in a handshake manner, registers on them and begins to receive data. (we have confirmed you can unregister with a simple DROP IP PORT statement) In order to remove the need for the user to figure out his or her own IP address we have incorporated a publicly known script to figure out ones IP. Once the data has arrived on the client machine it is presented to them in a terminal format. Which is fine depending on the purpose of the application. However, given that in the previous assignments the focus has been on web applications we decided to place the GUI also online.

The way this works is using the Redis server, which in the video that is attached you can see this running in the lower terminal screen. Basically it is set to broadcast Juggernaut (a websocket wrapper) on port 8080 on the local host. There we have part of the Ruby script devoted to feeding this information across this port, now we are able to use the same port - 8080 for the two airlines because we have them on two different channels. By doing this we can now do a bunch of cool secure things like SSL, and also have the advantage of CSS, etc now that it's basically a web app, vs a stand alone local app.

Now on the appropriateness of UDP/TCP for this application: Well the best way to think about it is what are both good at and were the implemented correctly in this case. UDP is primarily intended for streaming information, where packet loss is acceptable, so like your typical VoIP or when you are playing video games (of course you get annoyed by lag though), but that's less a problem when you are streaming video. So in this case UDP is appropriately used as the means by which to stream our information. TCP on the other hand is reliable unlike UDP, so we use this for our single request like registration, dropping, etc. 

So now how would this fit into what we already have developed in the past. We simply put we would have our users register on the site still, and when you register what you would do is select a movie - some authentication and stuff would be done via TCP, while the movie is streamed to you via UDP. Now of course you can run into an issue with there being a finite amount of ports for a number of movies which exceeds this, and ideally a user base that also exceeds that. Now if millions of people are using the service we should use a protocol known as websockets, because as we have shown in this little demonstration we can have people on the same port, but seeing different things because they are on different channels. So this would allow us to say port 8080 is for USA users, while port 8090 is for those in China, etc. It's also a more secure and up to date protocol than TCP, and is being rapidly adopted by the top browsers.

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。