""
All times are GMT +2. The time now is 05:11 AM.  

Go Back   PSX/PS2/PS3 Scene Newz > PlayStation2 Forums > PS2 Homebrew/Dev & Emu Scene > Official SMS Forums

Official SMS Forums Forum for discussing SMS: Simple Media System player for the ps2.

Reply
 
Thread Tools Display Modes
  #51  
Old 07-12-2007, 03:12 AM
vtecorona's Avatar
vtecorona vtecorona is offline
Registered User
 
Join Date: Jan 2005
Location: NJ
Posts: 256
Thumbs up

New version is in the first page. Enjoy!
__________________
HDL_Dump GUI v1.5 - GUI application that simplifies the use of hdl_dump.

PS2Client Loader v1.3 - GUI application that automates the loading\unloading of PS2Client. Multiple consoles supported.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #52  
Old 07-12-2007, 07:16 AM
dlanor dlanor is offline
Contributor
 
Join Date: Sep 2004
Posts: 4,773
Quote:
Originally Posted by vtecorona View Post
New version is in the first page. Enjoy!
I'm afraid there's some bug in the initial ping attempts, causing a false indication of connection and thus also an unwarranted launch of ps2client, almost every time PS2ClientLoader v1.3 is started without any PS2 connected. The problem is only temporary, as the proper disconnected state is then detected and ps2client.exe terminated again, whereafter the program works properly.

To be more precise, the following is what I see with the ping delay set to 2000 ms:
Code:
Second:   Behaviour:
0.0-1.9   Red Icon with no ps2client launched
2.0-7.9   Green Icon with ps2client running
8.0-etc   Red Icon with ps2client terminated
Like I said above, the problem is inconsistent, and sometimes I even get several launches in a row where it doesn't happen at all, but it still happens in the majority of all my attempts.

Since it's just a temporary condition during initialization, it won't affect normal usage of the program, but it's still something you should fix.


Another thing you need to look into is how the set ping timeout affects connection state detection delays. For example, when browsing to host: in uLE there is a delay of appx 12 seconds (with same 2000ms setting) before the icon turns green. Granted that a few of those seconds are used to initialize the driver in uLE, but 12 seconds is still too long for this detection IMO. There is a similar long delay when I turn off the PS2, of appx 9-10 seconds before the icon turns red again.

I can understand a long delay in detecting a timeout, since there is no way to do that other than waiting for a reply that never comes, but I can't really understand why the resulting timeout delay is over four times larger than what the user entered (4 sequential timeouts ?).

I also can't understand why the same long delay must occur for the case where a reply is received from the other party. That makes no sense at all to me, since no timeout is occurring here. The timeout must be started, sure, but as soon as a reply is received that timeout should be terminated, and if you need another ping to confirm the connection, then this should be sent immediately after receiving the latest reply. But right now it seems to be working such that only one ping may be sent per timeout period, with the check for a received reply being made only at the end of each such period, which causes unnecessary detection delays.


Edit:
In rereading the paragraph above, I realized that you probably use the same ping method both to detect a newly established connection and to detect the failure of an existing connection (due to PS2 turn-off or ELF relaunch). That can cause delays such as discussed above, since the pings used to confirm an existing connection should only be sent once per timeout period, regardless of when the reply to each arrives.

The solution is simply to use two different methods. One for establishing connections, and another for confirming continued connections. The former should send a new ping immediately after receiving a reply, until you have the number of replies required to accept the connection as established, at which point you switch to the second method, which works approximately as your current code. The main problems are that the code for these two methods needs to be combined, and also has to handle multiple connections. Here is a brief outline of how I would do it:

You need to check for ping replies much more frequently (say each 100ms), regardless of the timeout setting, and whenever a reply is detected you need to respond differently to it depending on whether it comes from a PS2 in unconnected or already connected state. For an unconnected PS2 you increment an initial reply counter for that PS2, and if that is still less than the required amount you directly send another ping and reset the ping timer variable for that PS2, but when you have sufficient replies you just set the connection state flag for that PS2 as well as a flag to note that the last ping was replied to. And for an already connected PS2 you simply set the latter flag, to note that the latest ping was replied.

Edit2: Ooops 1! I forgot to include the 'slight detail' of launching an instance of ps2client.exe in addition to setting the connection state flag above.

Regardless of whether any reply was received in the current check period you also increment the ping timer variable of each PS2 by the check interval and see if the resulting sum exceeds the timeout value. When such a timeout occurs you always check whether the previous ping was replied to or not (copying it to another flag), after which you reset the ping reply flag of that PS2 and send it a new ping.

Now, if the previous ping had a reply, then that PS2 is already in connected state (or we wouldn't reach timeout), and the only work to do here is to clear the timeout counter of this PS2. If there was no ping reply, then you clear the initial reply counter and check if this PS2 was already connected or not. If not, then no more needs to be done here. But when you get timeout without reply for a connected PS2, you increment a timeout counter for that PS2 and check if you've reached the amount required for disconnection, in which case you reset all variables for that PS2 to initial state.

Edit2: Ooops 2! In the above I forgot to mention that 'reset all variables for that PS2' also implies terminating the ps2client.exe instance that was launched for traffic with that PS2.

Summing up variables you need:
Connection state flag for each PS2 - initialized zero == disconnected
Initial reply counter for each PS2 - initialized zero and reset at unreplied ping timeout
Last ping reply flag for each PS2 - initialized zero and reset each timeout period
Ping timer variable for each PS2 - initialized zero and reset each time a ping is sent
Ping timeout counter for each PS2 - initialized zero and reset at replied ping timeout

This method should allow the program to respond much quicker to new connections, even when using the highest timeout delay setting.

Best regards: dlanor

Last edited by dlanor; 07-12-2007 at 09:23 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #53  
Old 07-12-2007, 08:17 AM
vtecorona's Avatar
vtecorona vtecorona is offline
Registered User
 
Join Date: Jan 2005
Location: NJ
Posts: 256
I did notice that upon starting it would sometimes give a false reporting of a valid ping when there was really not. This was only happening for the initial ping so in an attempt to fix this I made it send 3 "starter" pings before it started to monitor the reply but I guess it isn't working. There is not much documentation on the icmpsendecho2 API so I am kind of learning it along as I go. Maybe I will just switch back to the original icmpsendecho if I cant get this worked out.

As for the delays, I tried to make it so that ps2 wasn't constantly bombarded with pings, rapidly, one after the other. Would it be better if pings were sent constantly? Send a ping to ps2, it replies, and then another one gets sent immediately after? I was trying to make it so the ps2 wouldn't have to be replying to tons of pings sent every millisecond while it is trying to handle streaming music\movies and file transfers. For me, it detected uLe host initialization and the switch to SMS so I figured all was good.

Let me know what you think is best; you know ps2 stuff better than I do
Thanks for the detailed reply
__________________
HDL_Dump GUI v1.5 - GUI application that simplifies the use of hdl_dump.

PS2Client Loader v1.3 - GUI application that automates the loading\unloading of PS2Client. Multiple consoles supported.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #54  
Old 07-12-2007, 09:11 AM
dlanor dlanor is offline
Contributor
 
Join Date: Sep 2004
Posts: 4,773
Quote:
Originally Posted by vtecorona View Post
I did notice that upon starting it would sometimes give a false reporting of a valid ping when there was really not. This was only happening for the initial ping so in an attempt to fix this I made it send 3 "starter" pings before it started to monitor the reply but I guess it isn't working. There is not much documentation on the icmpsendecho2 API so I am kind of learning it along as I go. Maybe I will just switch back to the original icmpsendecho if I cant get this worked out.
I really have no idea why/how these API functions differ, so I can't help with that choice. Still, we never had this problem before, so unless you can get the new method to work better, then I agree that going back to the old one is the best solution.

Quote:
As for the delays, I tried to make it so that ps2 wasn't constantly bombarded with pings, rapidly, one after the other.
For most cases I agree, such as for an already established working connection (no use blocking it with ping traffic), or in checking for a first response from a PS2 not turned on yet (total waste of time ). It is only for the case where we receive replies from a previously unconnected PS2 that we need a quicker response, not dependent on the timeout value.

Quote:
Would it be better if pings were sent constantly? Send a ping to ps2, it replies, and then another one gets sent immediately after?
I want this only during the initial connection phase.

Quote:
I was trying to make it so the ps2 wouldn't have to be replying to tons of pings sent every millisecond while it is trying to handle streaming music\movies and file transfers.
I agree completely.

Quote:
For me, it detected uLe host initialization and the switch to SMS so I figured all was good.
Good enough to be useful, sure, but not as good as it might become. Cutting maybe 8 seconds off the first host: response in each uLE session makes for a big difference in convenience to me.

In SMS that delay is not as noticeable, since SMS is normally used with networking auto-started. But for uLE that is not a good idea, since uLE needs to be able to launch ELFs without having networking modules in IOP space. That sort of thing is the main reason why uLE avoids loading most drivers at startup, doing it for specific devices only when the user requests it by direct browsing or launch path usage.

Quote:
Let me know what you think is best;
While you were making your latest post I was editing my old post, so it already has a verbal description (but no real C code) for what I feel you need to do, in making the program quicker to respond to new connections.

Best regards: dlanor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #55  
Old 07-13-2007, 05:54 AM
vtecorona's Avatar
vtecorona vtecorona is offline
Registered User
 
Join Date: Jan 2005
Location: NJ
Posts: 256
Sounds wayy confusing but I'm sure it makes total sense. I'm still trying to digest all of it. Let me see if I'm understanding correctly.

When a PS2 is not replying, send pings fast to detect a newly online ps2 faster.

When a ps2 first replies, send a few pings (counting replies with a variable) to flag it as being active when the counter is satisfied.

Once the ps2 is officially flagged as online, use a timeout (500ms) between pings so that the ps2 is not bombarded while trying to steam music\video and files.

When that ps2 becomes inactive again, start sending pings fast again to detect when it is online again, if it does at all.

I think I am confused because you are trying to explain it in english\programming-code wording. If you word it out like I have it above I will be able to understand it much better.

As always, thanks for the great reply. It really helps out.
__________________
HDL_Dump GUI v1.5 - GUI application that simplifies the use of hdl_dump.

PS2Client Loader v1.3 - GUI application that automates the loading\unloading of PS2Client. Multiple consoles supported.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #56  
Old 07-13-2007, 08:04 AM
dlanor dlanor is offline
Contributor
 
Join Date: Sep 2004
Posts: 4,773
Quote:
Originally Posted by vtecorona View Post
Sounds wayy confusing but I'm sure it makes total sense. I'm still trying to digest all of it. Let me see if I'm understanding correctly.
I think you are close to full understanding of what I meant, missing only a few minor details. Hopefully my replies below will clear those up for you.

Quote:
When a PS2 is not replying, send pings fast to detect a newly online ps2 faster.
That's not really necessary, because we should be able to tolerate a nearly full timeout period for the very first reply from a newly activated PS2. We don't want to flood the network with pings, or slow down traffic with any active PS2s, just because some defined PS2 is not currently active.

By using the 'fast re-ping' method only when we see a reply from a PS2, and only while that PS2 is still considered unconnected, continuous flooding becomes impossible. Either the PS2 will continue to reply, in which case it will soon reach fully connected state causing PS2CL to revert to slow pings, or else the PS2 will stop replying, in which case pings will automatically become slow again, occurring only once per full timeout period (per defined PS2 of course).

Quote:
When a ps2 first replies, send a few pings (counting replies with a variable) to flag it as being active when the counter is satisfied.
Yes. It is when a reply comes back from an as yet 'unconnected' PS2 that we need to send a new ping immediately, repeating that procedure until we have the number of replies needed to verify the connection as stable.

The necessary number is really an arbitrary choice, but we can never settle for just one packet, since basic IP is a lossy protocol without error correction, and quite lousy error checking as well (1/256 errors misdetected). So occasional packets will be missed while others will occasionally be accepted as correct despite packet errors. That is one of the reasons why higher level protocols are required for really safe traffic.

Quote:
Once the ps2 is officially flagged as online, use a timeout (500ms) between pings so that the ps2 is not bombarded while trying to steam music\video and files.
Yes, for this case you can use such a timeout, much as the current version does. But even then it is still important to check more frequently than that for replies from any other PS2 which is not yet active in the network. So the timeout period can never be used as basis for the main checking loop, which will have to use some much shorter period, which is why I earlier suggested using 100ms for that purpose.

Quote:
When that ps2 becomes inactive again, start sending pings fast again to detect when it is online again, if it does at all.
Again, not necessarily (though it would work). The quick 're-ping' method only needs to be used when a reply has been received from such an 'inactive' PS2.

Quote:
I think I am confused because you are trying to explain it in english\programming-code wording. If you word it out like I have it above I will be able to understand it much better.
In the above I've tried to give separate replies to each of your separate paragraphs, so I hope all is now clear.


Quote:
As always, thanks for the great reply. It really helps out.
I'm glad you think so. But I'm not entirely unselfish in providing this feedback, as I consider PS2CL quite important for my own use of uLE networking too...

Best regards: dlanor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #57  
Old 07-13-2007, 08:49 PM
vtecorona's Avatar
vtecorona vtecorona is offline
Registered User
 
Join Date: Jan 2005
Location: NJ
Posts: 256
I worked on it some last night and I think I did most of what you are explaining. Each PS2 machine has it's own variables for everything, including timeouts between pings and such so each machine is independent from the others. The only variable that is used for all machines is the ping timeout. I changed the coding to make it wait until it gets 3 successful ping replies before being flagged as active (that should fix the bug of giving false active readings); I have a similar variable to check for an inactive ps2 after 3 unsuccessful pings from a currently online ps2 machine (this was already in the the previous version). Once a ps2 becomes online, I make it pause between each ping (I added a slider to the settings window so the user can adjust this). For inactive ps2's I have it at a different pause (I added a slider on the settings window for this as well) between pings but I'm not quite sure what I should set this at by default. What do you think?

So far with testing, it is detecting ps2 as online within 4-7 seconds from the initial click of host: and it is also detecting the switch from active to inactive faster, almost instantly. When the ps2 host is initialized already prior to starting ps2cl, it is detected immediately after clicking Start. I did all of the testing with 5 IP addresses used (3 active and 2 not).

One part I am not 100% grasping is what to change the frequency of pings when a PS2 goes from active to inactive. Should it get treated the same as if it were not just previously active?

Quote:
Quote:
When that ps2 becomes inactive again, start sending pings fast again to detect when it is online again, if it does at all.
Again, not necessarily (though it would work). The quick 're-ping' method only needs to be used when a reply has been received from such an 'inactive' PS2.
Thanks
__________________
HDL_Dump GUI v1.5 - GUI application that simplifies the use of hdl_dump.

PS2Client Loader v1.3 - GUI application that automates the loading\unloading of PS2Client. Multiple consoles supported.

Last edited by vtecorona; 07-14-2007 at 12:34 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #58  
Old 07-14-2007, 08:21 AM
dlanor dlanor is offline
Contributor
 
Join Date: Sep 2004
Posts: 4,773
Quote:
Originally Posted by vtecorona View Post
I worked on it some last night and I think I did most of what you are explaining. Each PS2 machine has it's own variables for everything, including timeouts between pings and such so each machine is independent from the others. The only variable that is used for all machines is the ping timeout. I changed the coding to make it wait until it gets 3 successful ping replies before being flagged as active (that should fix the bug of giving false active readings); I have a similar variable to check for an inactive ps2 after 3 unsuccessful pings from a currently online ps2 machine (this was already in the the previous version). Once a ps2 becomes online, I make it pause between each ping (I added a slider to the settings window so the user can adjust this).
This all sounds fine to me.

Quote:
For inactive ps2's I have it at a different pause (I added a slider on the settings window for this as well) between pings but I'm not quite sure what I should set this at by default. What do you think?
Well, if you implemented the other stuff as I described it, then this interval will only affect the first ping response of a PS2 that needs to re-establish a connection. Because as soon as its first ping reply arrives at the PC, PS2CL will send the next ping without delay. So this interval is not very critical. Any value in the current timeout range will do fine for its default as far as I'm concerned, though the shorter ones will give the quickest connection response. Perhaps 500ms would be a good compromise.

Quote:
So far with testing, it is detecting ps2 as online within 4-7 seconds from the initial click of host:
That's quite good, considering that a few seconds are inevitably lost in the initialization of the PS2 network drivers of uLE.

Quote:
and it is also detecting the switch from active to inactive faster, almost instantly.
But that seems a bit odd. Such detection should not be considered verified until the program has waited for missing replies for three full timeout periods. And with the testing timeout we discussed earlier (2000ms) that should take a minimum of six seconds. An instant response indicates that the code is glitching past the proper timeout counting.

Quote:
When the ps2 host is initialized already prior to starting ps2cl, it is detected immediately after clicking Start.
Excellent. That's the main point of this ping method, so it's good to know that it works as planned.

Quote:
I did all of the testing with 5 IP addresses used (3 active and 2 not).
Nice. I only have two PS2 units myself, and they are in different rooms, so my ability to test active multi-console use is rather limited.

Quote:
One part I am not 100% grasping is what to change the frequency of pings when a PS2 goes from active to inactive.
My original idea didn't require any change here, as it assumed that the main timeout setting would rule all normal pings, except during the short phase where a new connection is verified by direct 're-ping' at each reply.

It may be better to have separate settings though, as you say, since it's more likely that a change of activity will occur on an active connection than on a dead one. And it can't hurt to let the user set his preferences for both cases anyway.

Quote:
Should it get treated the same as if it were not just previously active?
Yes, I think so, since it's just reverting to the state it originally had.

Sure, the fact that this console was recently active might be taken as a hint that it's more likely to reactivate soon. But that's not really a good enough reason to modify the method. The gains from doing so would be minimal, or even absent in all those cases where such a console really won't reactivate in the immediate future.

Best regards: dlanor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #59  
Old 07-17-2007, 04:04 AM
vtecorona's Avatar
vtecorona vtecorona is offline
Registered User
 
Join Date: Jan 2005
Location: NJ
Posts: 256

New revision released


A new revision is posted in the main thread. Enjoy
__________________
HDL_Dump GUI v1.5 - GUI application that simplifies the use of hdl_dump.

PS2Client Loader v1.3 - GUI application that automates the loading\unloading of PS2Client. Multiple consoles supported.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #60  
Old 07-18-2007, 02:40 AM
dlanor dlanor is offline
Contributor
 
Join Date: Sep 2004
Posts: 4,773
Quote:
Originally Posted by vtecorona View Post
A new revision is posted in the main thread. Enjoy
Good job!
I've been testing this new version today, and it works perfectly.

Best regards: dlanor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #61  
Old 08-19-2008, 06:38 PM
Zephyro Zephyro is offline
Registered User
 
Join Date: Apr 2008
Posts: 3
Awesome work! Thank you very much! working with no problem here..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT +2. The time now is 05:11 AM.