Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just testing whether this can be compiled on other platforms (multi instances) #8134

Closed
wants to merge 32 commits into from

Conversation

Projects
None yet
9 participants
@ANR2ME
Copy link

commented Nov 1, 2015

No description provided.

@sum2012

This comment has been minimized.

Copy link
Collaborator

commented Nov 1, 2015

Seem compile ok

@xiushudongfang

This comment has been minimized.

Copy link
Contributor

commented Nov 2, 2015

Amazing,test some games,and it works fine.

@hrydgard

This comment has been minimized.

Copy link
Owner

commented Nov 2, 2015

So do you actually want me to look at it for merging, or not? :)

If so, please rebase it on master first, it doesn't need all those "merge" commits.

ANR2ME added some commits Nov 2, 2015

Attempt to fix corrupted registers after returning from adhoc matchin…
…g callbacks. (Fixed Dissidia 012 crashing or getting a blank screen when playing with more than 2 players, and probably some other games with similar issue)
@ANR2ME

This comment has been minimized.

Copy link
Author

commented Nov 2, 2015

I was just making sure it's up to date, and has no compilation issue.
Anyone could pick whichever commits i made and make a pull request from their own fork.

@sum2012

This comment has been minimized.

Copy link
Collaborator

commented Nov 2, 2015

I want test myself before pick up commit

ANR2ME added some commits Oct 29, 2015

* Detect multiple instance of PPSSPP running and automatically change…
… the IP and MAC of the 2nd (or more) instance of PPSSPP to allow multiplayer on the same computer.

* Added Port-shifting support for games that use privileged ports (< 1024), all players need to have the same port offset.
  TODO: Add GUI for Port Offset to be configurable by players.
Attempt to fix corrupted registers after returning from adhoc matchin…
…g callbacks. (Fixed Dissidia 012 crashing or getting a blank screen when playing with more than 2 players, and probably some other games with similar issue)
@lightfirst

This comment has been minimized.

Copy link

commented Nov 2, 2015

cool, multiple instance of PPSSPP support you add working fine
4 PPSSPP on one PC
5

2 PPSSPP on one PC
6

Port-shifting support for games that use privileged ports (< 1024) also woring. ( I set portOffset = 5000 and tested on android)
1.png
3.png

@sum2012

This comment has been minimized.

Copy link
Collaborator

commented Nov 2, 2015

@lightfirst Can you help to test Metal Slug XX (ULUS10495) ? Thanks
Android host still fail (Client is windows 7)
I have set portOffset = 5000

@lightfirst

This comment has been minimized.

Copy link

commented Nov 2, 2015

@sum2012 No problem for me. Have you change Core/HLE/proAdhoc.cpp
uint16_t portOffset = 0; //5000 to uint16_t portOffset = 5000;
qq 20151102235453

@LunaMoo

This comment has been minimized.

Copy link
Collaborator

commented Nov 2, 2015

Maybe the port it got is already being used by something else on one of your devices?
Well it needs an option anyway to keep compatibility with PSP/JPCSP, so might as well allow setting custom value, you can try https://github.com/LunaMoo/ppsspp/tree/adhoc_stuff where I just added that.

@hrydgard

This comment has been minimized.

Copy link
Owner

commented Oct 19, 2016

Either way it needs a rebase, @ANR2ME are you up for it?

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Oct 19, 2016

I think we should close this one instead, and move discussion to port offset commit that was merged for further improvement. Since this commit was only used to test whether it can be compiled on non-Windows platform :)
Was it this one? #8496

@Wishdream

This comment has been minimized.

Copy link

commented Oct 19, 2016

I'm not so sure, I think rebasing it is a better idea because recently the
port 0 to psp2 does not work on other builds than this one for some reason.
Could there have been a regression?

On Wed, Oct 19, 2016, 11:55 PM ANR2ME notifications@github.com wrote:

I think we should close this one instead, and move discussion to port
offset commit that was merged for further improvement. Since this commit
was only used to test whether it can be compiled on non-Windows platform :)
Was it this one? #8496 #8496


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#8134 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEcd52B3BcUz1X4mEpkmHekxI0HE6tI_ks5q1j2CgaJpZM4GZrZ0
.

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Oct 19, 2016

Hmm.. probably related to "callbacks inside other callbacks don't work" mentioned by @unknownbrackets above. Where this commit have a workaround to make games that use AdhocMatching a bit more stable (but not perfect)

@Wishdream

This comment has been minimized.

Copy link

commented Oct 19, 2016

Most likely would be the case. Either way, it might be a good idea to
include the workaround for now and rewrite it later. Maybe add a TODO or a
comment there that says so.

On Thu, Oct 20, 2016, 1:07 AM ANR2ME notifications@github.com wrote:

Hmm.. probably related to "callbacks inside other callbacks don't work"
mentioned by @unknownbrackets https://github.com/unknownbrackets above.
Where this commit have a workaround to make games that use AdhocMatching a
bit more stable (but not perfect)


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#8134 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEcd58mLfWUZGZ2ctgdX_MrEksmvAV-Cks5q1k44gaJpZM4GZrZ0
.

@sum2012

This comment has been minimized.

Copy link
Collaborator

commented Oct 19, 2016

I think that it might be need rebased again when @adenovan done network chat in #7451

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Oct 20, 2016

chat and callback workaround aren't related to port offset, so we should make a separated commits right?
Anyway, i will probably delete this old fork and reclone from official repo whenever i wanted to try something in the future. One of the flaw with port shifting is that all players need to have the same port offset, while different computer may have different port usage, one of the player may not have the port available, and not everyone familiar with ports, tunneling might be better since each player can use different tunnel port, and it's easier to forward since the port is known

@Wishdream

This comment has been minimized.

Copy link

commented Oct 20, 2016

Right, tunneling is so much better without screwing up the ports.
Well. At this point I'm not so sure. If either a rebase or a commit is better.

I'll leave the decision up to you guys.

@hrydgard

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2016

How would we go about tunneling? make a little custom packet header containing the destination port, then simulating that when sending the packets into the sceNet libraries? or are there suitable ready made protocols we should use?

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Oct 22, 2016

Hmm for tunneling can we use STTP https://en.m.wikipedia.org/wiki/Secure_Socket_Tunneling_Protocol and use Https port for the TLS it will pass many firewall I think and we need to think for people behind the nat without upnp enabled like android using cellular data. How can torrent software established p2p connection behind nat easily, do we really need a server to do hole punching for user that not having upnp enabled like Skype do?

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Oct 22, 2016

Well for performance reason Encryption isn't really needed as it will give extra overhead, but having encryption may improve security (ie. tampering game data for cheating).

Anyway, i was thinking a simple tunneling by wrapping functions that actually used to send/receive data and then decide whether the data should be tunneled (ie. if remote IP is within group/friendlist) or direct communication (ie. external/WAN IP such as official server), and we can make several mode of tunneling just like what i mentioned here http://forums.ppsspp.org/showthread.php?tid=16972&pid=121429#pid121429

@@ -1637,7 +1640,7 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
}

// Valid Ports
if (!isPTPPortInUse(sport) && dport != 0) {
if (!isPTPPortInUse(sport) /*&& dport != 0*/) {

This comment has been minimized.

Copy link
@ANR2ME

ANR2ME Oct 24, 2016

Author

need to add 1 more line under this to fix connection issue with Phantasy Star Portable 2 when using non-zero PortOffset:

if (sport == 0) sport = -(int)portOffset; //making sure sport is 0 when shifted

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Nov 15, 2016

that one more line used to fix phantasy star portable 2 using offset still have an issues.
its work only if windows form the party.

if android form the party the game still throw network error occured adb logcat show android can't connect to windows with error 114.

join party is fine for android.

we still can't play phatasy star portable 2 betwen android device.

if hosting the quest does the game bind to port 0 which is restricted to android?

@Wishdream

This comment has been minimized.

Copy link

commented Nov 15, 2016

This doesn't work because Android does not generally does not allow Port
Offset 0. Same with Linux. Though, port 0 isn't actually used in
communication but to randomize ports for communication instead.

I am not sure if Android has a firewall or something that prevents Windows
to connect with Android.

Also, be sure that your port offset is greater than 1024. Anything under
that is generally occupied by important apps and the Android OS

On Nov 15, 2016 4:09 PM, "Ade Novan" notifications@github.com wrote:

that one more line used to fix phantasy star portable 2 using offset still
have an issues.
its work only if windows host the party.

if android host the party the game still throw network error occured adb
logcat show android can't connect to windows with error 114.

joining to windows host is fine for android.

we still can't play phatasy star portable 2 betwen android device.

if hosting the quest does the game bind to port 0 which is restricted to
android?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#8134 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEcd5xVu9yFIRi8c6vhObwYPgibgc6Auks5q-WikgaJpZM4GZrZ0
.

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Nov 16, 2016

Additionally to @influxWishdream answer, if i'm not mistaken socket error 114 = Operation already in progress (the socket is in the middle of connecting but another attempt to connect is initiated), it's happened a lot (even on windows) on many games that uses non-blocking socket, it shouldn't be a problem because the games will repeatedly tried to connect until it eventually connected (or a certain time elapsed as timeout) when using non-blocking socket.

PS: I think most of connections issue was because the game is measuring the timeout by them self which may not give enough time to connect and the timeout is difficult to override from host/ppsspp side (unlike blocking-socket where we can use real-life socket timeout on ppsspp side and have enough time to connect through the internet)

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2016

@influxWishdream the offset value i was used is 1100 and its working on matching event but it can't enter the game lobby when android form party (hosting). the offset do the job like it should. its more like socket problem on linux that not found the equivalent error on windows.

@ANR2ME ah this is actually what im looking for right now. this 114 error problem is fixed by #9058 on monster hunter game which have same issues on matching peer. but its not work with this game. i tried to use port offset 0 and i see bind failed on adb logcat it's even worse and can't enter the matching event. so i think its not a port offset problem anymore and looks like something blocking the connection from android to windows when android form the party (firewall turned off and do it on lan and happened between android device too). if android join the party its works. is there something different between build when do PTPListen? looks like its not latency issues too.

the weird part is windows log say its connected when joining to android as host. but android throw many socket error 114 even after executing ptpaccept, ptpsend ,and ptprecv which was respond to estabilished windows connection. windows successfuly connect to android and i think android just doesn't know that windows is connected.

it seems android not entering this if condition https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/sceNetAdhoc.cpp#L1974
when form the party (hosting) and from the windows log i see the log its enter 3 times when hosting and says already connected 3 times after that says connection estabilished. tried to uncomment EALREADY on that if condition and both build can't enter the game after matching event it's even worse.

here is the logcat from android device and the difference when joining and hosting

hosting (failed)
androidformdebug.txt

joining (success if windows host)
windowsform.txt

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Nov 16, 2016

Based on your androidformdebug.txt it seems it tried to connect to it self on listened port 13009 (instead of connecting to remote player/ppsspp) and didn't get accepted.

Are you sure port 13009 not taken by other program or being blocked?
You may want to live debug the source code and trace each line during sceNetAdhocPtpListen(O�S¦Á�,13009,8224,200000,300,5,0) to see whether it really successful in binding port 13009.

PS: as i remember adhoc functions is enabling Reusable sockets which shares the same port on multiple sockets, which probably a bad idea since already taken port can still be binded by another socket successfully, but the one accepting/receiving the data might be the other socket (which can be on a different program) and resulting a miscommunication.

Quoted from https://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx

Once the second socket has successfully bound, the behavior for all sockets bound to that port is indeterminate. For example, if all of the sockets on the same port provide TCP service, any incoming TCP connection requests over the port cannot be guaranteed to be handled by the correct socket — the behavior is non-deterministic.

You may want to disable SO_REUSEADDR (or was it SO_REUSEPORT) during socket creation (in several adhoc functions) to test whether it can successfully binds port 13009 (or getting a socket error: already used) without reusable port

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2016

im not sure its being taken or not because its happens on every android device, using netstat on my rooted device looks like no program bind to that port. also different offset value is not helping too. can we shift that ptp listen port using offset? i tried to do it but the client can't connect to the host.

image

the log above disabled every SO_REUSEADDR on all scenetAdhoc source code and didn't help the game or give info socket error already used. sometimes its cause the game hang when disable it.

left part off the image is android log listening (failed)
right part is windows log listening (success)

like you said its fails to connect to itself on port 13009 . didn't know if this issues can occured on linux build or not. someone need to test it and i think its easier to debug this issues using linux than android.

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Nov 17, 2016

It's strange that it can accept connection from remote player/ppsspp on port 12000 but can't accept connection from it self on port 13009.

Could it be the one listening and the one connecting have a different network interface/IP?
you may want to print additional log to show the IP linked to the socket after it successfully binded and after it calls connect, to make sure both of them are using the same network interface/IP.
Or may be TCP_NODELAY is disabled by default on android.

And yes, we need someone to test this on linux to see whether it also happened on linux.

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2016

yeah great you're right shot into the problem straightly 👍 .

the game use different network interface /ip but this behaviour is not a problem on windows @_@. look at this log its connect to different network interface.
image

it should use 192.168.1.6 for local ip but its used my openvpn ip /interface.

i can't log that INADDR_ANY properly after succesfully binded so i just add additional log on ptpconnect.

have any workaround for this issues?

will post adb logcat soon.

Edit
this is the adb logcat and this is the weird part. its tried to connect to 192.168.12.1 lol, its even not in my local subnet or wan subnet. what is that ip on android?
psp2ip.txt

my android local ip should be 192.168.1.3 and my pc remote ip is 192.168.1.6 hmm

windows use the right ip when hosting (disable all other interface)
image

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Nov 18, 2016

It seems you only show the destination IP on PtpConnect, you may want to show the source IP also to make sure both of them are on the same network/reachable.

Regarding IP 192.168.12.1 even if it's not in your network, it will certainly be existed in the friendlist/peerlist given by your AdhocServer.

Are you using a standalone adhoc server?
Have you tried using the built-in adhoc server to see whether the same issue occurred?
You may want to check your adhoc server log to look for that IP, it might be the IP used to connect to adhoc server or your adhoc server might be converting a local IP to that IP.

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Nov 18, 2016

that test use builtin adhoc server. the standalone and builtin adhoc server seems has the same issues.
ok will do it look for the log on the server and trace the source also.

looks like its make sense the 192.168.12.1 is given by adhoc server.
because this game connect to the server 2 times. first on matching event and after that do a connect again. can it be an ipconflict because its do a login after login and send 2 different ip to the server? AFAIK same ip is rejected from the server.

found the issues looks like its happened on all ip and not the pro adhoc server fault. we need to wrote the equivalent of get hostname on linux.

https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/proAdhoc.cpp#L1305

thanks for the advance adamn. learn alot from you @ANR2ME 👍

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Nov 18, 2016

LOL didn't realize there is a constant IP there O.o
Anyway, gethostbyname does exist on linux but obsolete https://linux.die.net/man/3/gethostbyname

The gethostbyname_() and gethostbyaddr_() functions are obsolete. Applications should use getaddrinfo(3) and getnameinfo(3) instead.

@adenovan

This comment has been minimized.

Copy link
Contributor

commented Nov 18, 2016

can we use this for get the addr info? looks like its work on macos too.

Edit
the ioctl solution ( not work for android ) due to ifaddress.h
http://stackoverflow.com/questions/212528/get-the-ip-address-of-the-machine

found a better solution grab local ip on initNetwork and save for future use. its works on android and looks like grab ip from socket always get the right ip. will do a pull request soon.

@hrydgard hrydgard changed the title Just testing whether these commits can be compiled on other platforms or not. Just testing whether this can be compiled on other platforms (multi instances) Jun 6, 2017

@hrydgard

This comment has been minimized.

Copy link
Owner

commented Jun 6, 2017

Okay, this needs a rebase now. And should we keep it around, or maybe merge it eventually?

@hrydgard

This comment has been minimized.

Copy link
Owner

commented Jan 31, 2019

@ANR2ME are you interested in bringing this up to date?

@ANR2ME

This comment has been minimized.

Copy link
Author

commented Jan 31, 2019

@ANR2ME are you interested in bringing this up to date?

I think most of these already implemented by others in their forks, not sure whether they've been merged to the official one or not (i haven't touched PPSSPP for a long time)

This one should be closed i think, as this was intended for learning purpose only.

@hrydgard hrydgard closed this Jan 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.