View Single Post
  #1   (View Single Post)  
Old 3rd May 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Arrow Java socket programming question

It is the 1st time I seft-study Java and socket programming, and I just started about a week ago, so bear with me.

What Im trying to do is create a network of 3 machines, server, relay and client for reliable data transfer. The client and server dont communicate directly, but via the relay. The client sends a number of packets, one by one, some of them will be dumped (dropped) at the relay.

The reliable transfer method will be implement like this

- Create a protocol.

- Use sequence number. For instance, if the server receives packet which sequence numbers are 1, 2 but the next one is 4, not 3 as expected, it will send a NACK to the relay, the relay now forward the NACK to the client. The client has 2 options, if it is an ACK, sends the packet with the next sequence number, if it is a NACK, retransmit the previous packet.

- Use the timer. Once received packet x, the server sets timeout for the next packet. If timeout is reached, it will send a NACK, and the client will restransmit the packet.

So what I have done is create a protocol, set up a communication between the client and relay. Now I get stuck because I dont know how to implement the sequence number.

I did a search on Google and found 2 functions:

Code:
getSequenceNumber()
setSequenceNumber()
But I think I have a brainstorm atm, can anyone gives me a simple example how to use those functions please.
Reply With Quote