Author | Message | Time |
---|---|---|
LockesRabb | I've been having problems getting UDP to work on my machine. Basically, I added UDP support to my bot. But for some inexplicable reason I was not receiving any UDP packets, even after sending 0x08 or 0x09. My machine is DMZ'ed, firewall and anti-virus is disabled. So those aren't the issues. I sent a copy of my bot to l2k-Shadow, and without any modifications, the bot worked fine, INCLUDING UDP support. This came as a surprise to me. I packet logged via WireShark. No UDP packets... RealityRipple sent me the source to one of his bots, I added UDP support to it, tested it-- didn't work. Sent the bot back to RealityRipple INCLUDING UDP support. He tested it without any modifications. UDP worked fine. Now, here's the interesting thing. I went in Starcraft, went on battle.net, and joined a game. Game started. Played. Lost. I won't get into details, but the point is, game was fine. I know for a fact games require UDP. So UDP seems to be working? This is driving me insane. So I can confirm it isn't my code. It's likely an issue on my machine or in my network. Or maybe an issue with the winsock driver on my machine? I'm fresh out of ideas. l2k-Shadow, RealityRipple, and DevCode also were fresh out of ideas. Any ideas you guys could suggest to pinpoint the problem? | October 19, 2007, 12:45 AM |
laurion | Do you have another machine on your network that you can test it on? This would be effective as to concluding whether the issue is your machine or your network. | October 19, 2007, 1:07 AM |
LockesRabb | There is another machine on the network, but it's Win Vista. I tried copying over my bot, but it wasn't able to run the bot. I also ran StarCraft (edit: on my machine), logged on, with WireShark packetlogging it. Guess what? WireShark shows UDP traffic at the port 6112. This is bewildering. Edit: Tried updating VB to SP6. Update was successful. UDP still didn't work though. Checked mswinsck.ocx version, it's 6.1.97.82. Compared that to RealityRipple's, he had 6.1.97.82, and UDP works fine for him. Also tried rebooting. Still the same result. Edit 2: Performed a hard reset of router, and set machine to DMZ once more, the results are still the same. | October 19, 2007, 1:14 AM |
DDA-TriCk-E | Haha stupid question probably, but have you set the socket to UDP? It defaults as TCP... | October 19, 2007, 1:42 AM |
devcode | [quote author=Don Cullen link=topic=17120.msg173976#msg173976 date=1192756460] There is another machine on the network, but it's Win Vista. I tried copying over my bot, but it wasn't able to run the bot. I also ran StarCraft (edit: on my machine), logged on, with WireShark packetlogging it. Guess what? WireShark shows UDP traffic at the port 6112. This is bewildering. Edit: Tried updating VB to SP6. Update was successful. UDP still didn't work though. Checked mswinsck.ocx version, it's 6.1.97.82. Compared that to RealityRipple's, he had 6.1.97.82, and UDP works fine for him. Also tried rebooting. Still the same result. Edit 2: Performed a hard reset of router, and set machine to DMZ once more, the results are still the same. [/quote] If SC works, then it's most likely your code that's wrong. | October 19, 2007, 2:01 AM |
l2k-Shadow | He sent the exact same code without any changes to several different people. The exact same code worked on all of their machines. Therefore, it is his machine, not his code. | October 19, 2007, 2:25 AM |
devcode | [quote author=l2k-Shadow link=topic=17120.msg173980#msg173980 date=1192760721] He sent the exact same code without any changes to several different people. The exact same code worked on all of their machines. Therefore, it is his machine, not his code. [/quote] Yet SC works. So it MUST be his machine | October 19, 2007, 2:36 AM |
LockesRabb | http://rafb.net/p/Tv3o2A54.html That's the code pertaining to UDP. | October 19, 2007, 2:55 AM |
Yegg | [quote author=devcode link=topic=17120.msg173981#msg173981 date=1192761417] [quote author=l2k-Shadow link=topic=17120.msg173980#msg173980 date=1192760721] He sent the exact same code without any changes to several different people. The exact same code worked on all of their machines. Therefore, it is his machine, not his code. [/quote] Yet SC works. So it MUST be his machine [/quote] [quote author=l2k-Shadow link=topic=17120.msg173980#msg173980 date=1192760721] He sent the exact same code without any changes to several different people. The exact same code worked on all of their machines. Therefore, it is his machine, not his code. [/quote] | October 19, 2007, 3:56 AM |
devcode | [quote author=Don Cullen link=topic=17120.msg173976#msg173976 date=1192756460] There is another machine on the network, but it's Win Vista. I tried copying over my bot, but it wasn't able to run the bot. I also ran StarCraft (edit: on my machine), logged on, with WireShark packetlogging it. Guess what? WireShark shows UDP traffic at the port 6112. This is bewildering. Edit: Tried updating VB to SP6. Update was successful. UDP still didn't work though. Checked mswinsck.ocx version, it's 6.1.97.82. Compared that to RealityRipple's, he had 6.1.97.82, and UDP works fine for him. Also tried rebooting. Still the same result. Edit 2: Performed a hard reset of router, and set machine to DMZ once more, the results are still the same. [/quote] | October 19, 2007, 4:15 AM |
squiggly | [quote author=Don Cullen link=topic=17120.msg173971#msg173971 date=1192754751] I've been having problems getting UDP to work on my machine. Basically, I added UDP support to my bot. But for some inexplicable reason I was not receiving any UDP packets, even after sending 0x08 or 0x09. My machine is DMZ'ed, firewall and anti-virus is disabled. So those aren't the issues. I sent a copy of my bot to l2k-Shadow, and without any modifications, the bot worked fine, INCLUDING UDP support. This came as a surprise to me. I packet logged via WireShark. No UDP packets... RealityRipple sent me the source to one of his bots, I added UDP support to it, tested it-- didn't work. Sent the bot back to RealityRipple INCLUDING UDP support. He tested it without any modifications. UDP worked fine. Now, here's the interesting thing. I went in Starcraft, went on battle.net, and joined a game. Game started. Played. Lost. I won't get into details, but the point is, game was fine. I know for a fact games require UDP. So UDP seems to be working? This is driving me insane. So I can confirm it isn't my code. It's likely an issue on my machine or in my network. Or maybe an issue with the winsock driver on my machine? I'm fresh out of ideas. l2k-Shadow, RealityRipple, and DevCode also were fresh out of ideas. Any ideas you guys could suggest to pinpoint the problem? [/quote] | October 19, 2007, 4:18 AM |
St0rm.iD | I feel like there's a NAT somewhere that you missed. Oftentimes when one sends a UDP packet on a certain post to a certain host, the NAT opens a hole in the firewall for packets coming from that host and that port. This is how two people behind NATs can play StarCraft. I'd suggest sending a dummy UDP packet to the host you're trying to reach (BNET) on the port you're trying to use (6112?) before trying to login. | October 19, 2007, 5:22 AM |
UserLoser | what are you setting the local port to for the UDP socket ? | October 19, 2007, 5:29 AM |
LockesRabb | [quote author=Banana fanna fo fanna link=topic=17120.msg173988#msg173988 date=1192771337] I feel like there's a NAT somewhere that you missed. Oftentimes when one sends a UDP packet on a certain post to a certain host, the NAT opens a hole in the firewall for packets coming from that host and that port. This is how two people behind NATs can play StarCraft. I'd suggest sending a dummy UDP packet to the host you're trying to reach (BNET) on the port you're trying to use (6112?) before trying to login. [/quote] 0x09 is sent prior to logon. No response is gotten. WireShark doesn't even catch the 0x09 outgoing udp packet. [quote author=UserLoser link=topic=17120.msg173989#msg173989 date=1192771787] what are you setting the local port to for the UDP socket ? [/quote] 6112. I uploaded the source if you'd like to see if the UDP works fine. If you do test it, basically, you should get a pop up msgbox saying "Got udp" when an udp packet comes in. For me, nothing pops up, but for the others who've tested it so far, it did pop up for them. http://www.bnetdocs.org/archives/SanityOCX.zip | October 19, 2007, 5:42 AM |
DDA-TriCk-E | Shouldn't you be calling BNETUDP.Connect() instead of BNETUDP.Bind()? | October 19, 2007, 6:04 AM |
LockesRabb | [quote author=Chriso.de link=topic=17120.msg173992#msg173992 date=1192773893] Shouldn't you be calling BNETUDP.Connect() instead of BNETUDP.Bind()? [/quote] UDP is stateless/connectionless, so no. .Bind is used. For more information on UDP: http://en.wikipedia.org/wiki/User_Datagram_Protocol Edit: I just realized something. It's definitely not a network issue. Here's my logic: SanityOCX sends 0x09 (udp) during the connection rountine. That's an originating packet. So, as per that logic, even if there was network issues preventing outgoing UDP packets, WireShark should have been able to log the outgoing UDP packet at the very least since it originated on my machine. The fact WireShark logged absolutely no UDP packets, either outgoing or incoming, indicates that it isn't a network issue, the issue is on my machine. So we definitely can rule out network issues, especially all the more so since my machine has a static ip, and has DMZ set for it. | October 19, 2007, 6:08 AM |
DDA-TriCk-E | Ahh I see, I've never really been interested in UDP protocol, guess I should have a read. | October 19, 2007, 6:30 AM |
St0rm.iD | try sending 2 udp packets at the start. | October 19, 2007, 7:41 AM |
tagban | [quote author=Don Cullen link=topic=17120.msg173976#msg173976 date=1192756460] There is another machine on the network, but it's Win Vista. I tried copying over my bot, but it wasn't able to run the bot. I also ran StarCraft (edit: on my machine), logged on, with WireShark packetlogging it. Guess what? WireShark shows UDP traffic at the port 6112. This is bewildering. Edit: Tried updating VB to SP6. Update was successful. UDP still didn't work though. Checked mswinsck.ocx version, it's 6.1.97.82. Compared that to RealityRipple's, he had 6.1.97.82, and UDP works fine for him. Also tried rebooting. Still the same result. Edit 2: Performed a hard reset of router, and set machine to DMZ once more, the results are still the same. [/quote] Vista works fine with VB bots. I can still use Invigoration. You need to make sure all the OCX files and whatnot are registered on your Vista machine though just like you would an XP machine. I also have Visual Studio 6 installed on this vista machine. | October 19, 2007, 12:06 PM |
Leaky | sound like your windows firewall didn't allow your program to send try manually adding it to the allowed list on the windows firewall | October 19, 2007, 1:51 PM |
LW-Falcon | [quote author=Leaky link=topic=17120.msg174002#msg174002 date=1192801884] sound like your windows firewall didn't allow your program to send try manually adding it to the allowed list on the windows firewall [/quote] [quote] My machine is DMZ'ed, firewall and anti-virus is disabled. So those aren't the issues. [/quote] | October 19, 2007, 3:36 PM |
Leaky | i do ISP tech support so i can tell you that disabling the windows firewall doesn't always disable it.. that's like saying turning off automatic updates turns automatic updates off... i would still add your program to the exception list trust me i've seen that be the issue way to many times to ignore it | October 19, 2007, 11:24 PM |
Barabajagal | That's why one disables the Windows Firewall and Automatic Update services ;D | October 19, 2007, 11:44 PM |
-MichaeL- | what router do you use? as some linksys routers have dmz problems. and since starcraft uses upnp (i think, don't quite remember.) that would explain why it works and your bot doesn't. or reformat :D | October 20, 2007, 12:36 AM |
LockesRabb | I added the application to the exception. No change. I'm using a DI-604 router to go online. However, I just went over to my girlfriend's home, and went on their internet (2wire), then tested my program. No change. So it's definitely not a network issue. The problem is localized on my laptop. I'm not sure what's wrong... :\ | October 20, 2007, 3:18 AM |
Kp | What does sendto return when you try to send the datagram? What is the value of the last error code? | October 20, 2007, 3:58 PM |
LockesRabb | [quote author=Kp link=topic=17120.msg174035#msg174035 date=1192895934] What does sendto return when you try to send the datagram? What is the value of the last error code? [/quote] Sendto? And how would I obtain the value of the last error code? Edit: The value of last error code is 0. As in zero. Using FormatMessage in conjunction with lastdllerror, it returns: The operation completed successfully. I'm not sure what you mean by 'sendto'... I just googled it, VB 6 doesn't make use of sendto. However, if the socket had errored when attempting transmission, I assume it'd trip the error event. [code]Private Sub BNETUDP_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) RaiseError 4 OCXEvents 1, "BNETUDP Error #" & Trim(Str(Number)) & ": " & Description RaiseEvent BNETConnectionStatus(False) BNETUDP.Close BNETSock.Close BNLSSock.Close End Sub[/code] It doesn't raise the error. So I assume, as far as VB knows, it was successful (which is wrong, as WireShark shows no outgoing UDP packets). [Edit: broke up long line that was disrupting table layout.] | October 20, 2007, 4:13 PM |
devcode | [quote author=Don Cullen link=topic=17120.msg174036#msg174036 date=1192896834] [quote author=Kp link=topic=17120.msg174035#msg174035 date=1192895934] What does sendto return when you try to send the datagram? What is the value of the last error code? [/quote] Sendto? And how would I obtain the value of the last error code? Edit: The value of last error code is 0. As in zero. Using FormatMessage in conjunction with lastdllerror, it returns: The operation completed successfully. I'm not sure what you mean by 'sendto'... [/quote] sendto and recvfrom are the winsock api used for udp | October 20, 2007, 5:31 PM |
Ringo | Just at a glance of replys, I would guess the problem is your remote address (that is, if its bind'ing) afaik, you should resolve the host name to the ip address with the TCP socket, then use the result address to send UDP messages to. hope this helps | October 20, 2007, 9:59 PM |
LockesRabb | What the flaming hell? I opened VB 6 again, and ran the bot once again, knowing it'd have the same results. No modifications or anything. And what do you know? NOW it's receiving UDP packets. When I get home Sunday night, I'll test the bot again. If it stops working at home, then it's a network issue. Either that or I'm incredibly unlucky. | October 20, 2007, 10:18 PM |
UserLoser | [quote author=Don Cullen link=topic=17120.msg173990#msg173990 date=1192772561] [quote author=Banana fanna fo fanna link=topic=17120.msg173988#msg173988 date=1192771337] I feel like there's a NAT somewhere that you missed. Oftentimes when one sends a UDP packet on a certain post to a certain host, the NAT opens a hole in the firewall for packets coming from that host and that port. This is how two people behind NATs can play StarCraft. I'd suggest sending a dummy UDP packet to the host you're trying to reach (BNET) on the port you're trying to use (6112?) before trying to login. [/quote] 0x09 is sent prior to logon. No response is gotten. WireShark doesn't even catch the 0x09 outgoing udp packet. [quote author=UserLoser link=topic=17120.msg173989#msg173989 date=1192771787] what are you setting the local port to for the UDP socket ? [/quote] 6112. I uploaded the source if you'd like to see if the UDP works fine. If you do test it, basically, you should get a pop up msgbox saying "Got udp" when an udp packet comes in. For me, nothing pops up, but for the others who've tested it so far, it did pop up for them. http://www.bnetdocs.org/archives/SanityOCX.zip [/quote] Are you sure you're not setting the local port on your TCP sockets to 6112 also (not needed/doesn't matter)? | October 21, 2007, 9:16 AM |
LockesRabb | [quote author=UserLoser link=topic=17120.msg174049#msg174049 date=1192958202]Are you sure you're not setting the local port on your TCP sockets to 6112 also (not needed/doesn't matter)?[/quote] I'd presume no. [code]Call BNETSock.Connect(sBNETAddress, lBNETPort)[/code] | October 21, 2007, 3:23 PM |
bethra | [quote author=Leaky link=topic=17120.msg174007#msg174007 date=1192836242] i do ISP tech support so i can tell you that disabling the windows firewall doesn't always disable it.. that's like saying turning off automatic updates turns automatic updates off... i would still add your program to the exception list trust me i've seen that be the issue way to many times to ignore it [/quote]If you work for cox, remind me to smack all of you. That was kinda in jest... It makes me want to pull my hair out and gouge pencils in my ears whenever I have to call my ISP tech support, just to go through a large checklist of things I've already done every single time. | October 21, 2007, 6:36 PM |
Leaky | lol i don't work for cox and i do DSL tech support iuno what cox internet uses... basically my checklist goes like this unplug modem plug modem in go to google hang up | October 22, 2007, 1:11 PM |
DDA-TriCk-E | Haha, thats some helpful shit bro... 8) | October 22, 2007, 1:13 PM |
LockesRabb | Okay, I just got home. As all of you know, the UDP suddenly started working when I got to my girlfriends home and ran the bot while using her internet (AT&T DSL). So I was able to personally confirm it was fully functional. Then I got home today, and ran the bot again. Now there's no UDP. So my assumption is that it's the network. I have a SR-200 router, which is very similar to (actually, it *IS*) the DI-604 by D Link. The SR-200 is just an OEM corporate-labeled version of the DI-604. Same interior architecture, same model, same web interface (minus D Link logo, plus Sorenson logo). My laptop is directly connected to the router, which in turn is connected to the cable modem (Motorola SB5120 Surfboard modem). Ideas? | October 22, 2007, 5:58 PM |
herzog_zwei | Since the same code works for some but not others, it's likely routing/NAT/firewall issue. Disable any firewalls you have on your OS and connect your machine directly to the modem to avoid any problems that might be caused by the router. If that works, your network and/or your code might be NAT unfriendly. I believe most transparent NATP implementations open up a random port on the initial outbound UDP packet and incoming UDP must have a matching destination IP/port of what was opened on the router and a matching source IP/port of the initial UDP packet sent to. If this isn't the behavior you want, you'll need to do more sophisticated routing/port forwarding. You mentioned that sometimes you see UDP packets and sometimes you don't. UDP is unreliable so when resources are low, UDP packets have a higher chance of getting dropped compared to other types. You should run the code without any other heavily resource (CPU, network) intensive programs running to make sure this isn't the problem. | October 22, 2007, 6:31 PM |
LockesRabb | [quote author=herzog_zwei link=topic=17120.msg174093#msg174093 date=1193077875] Since the same code works for some but not others, it's likely routing/NAT/firewall issue. Disable any firewalls you have on your OS[/quote] I went one step further, I added the ports to the WinXP firewall (even though it was disabled), and also clicked advanced and added the ports to the services. No luck here. [quote]and connect your machine directly to the modem to avoid any problems that might be caused by the router. [/quote] That worked. [quote]If that works, your network and/or your code might be NAT unfriendly. I believe most transparent NATP implementations open up a random port on the initial outbound UDP packet and incoming UDP must have a matching destination IP/port of what was opened on the router and a matching source IP/port of the initial UDP packet sent to. [/quote] How would I best determine whether my code is NAT unfriendly? Also, how would I make my router be NAT friendly? | October 22, 2007, 11:25 PM |
Leaky | [quote author=Don Cullen link=topic=17120.msg174107#msg174107 date=1193095503] [quote author=herzog_zwei link=topic=17120.msg174093#msg174093 date=1193077875] Since the same code works for some but not others, it's likely routing/NAT/firewall issue. Disable any firewalls you have on your OS[/quote] I went one step further, I added the ports to the WinXP firewall (even though it was disabled), and also clicked advanced and added the ports to the services. No luck here. [quote]and connect your machine directly to the modem to avoid any problems that might be caused by the router. [/quote] That worked. [quote]If that works, your network and/or your code might be NAT unfriendly. I believe most transparent NATP implementations open up a random port on the initial outbound UDP packet and incoming UDP must have a matching destination IP/port of what was opened on the router and a matching source IP/port of the initial UDP packet sent to. [/quote] How would I best determine whether my code is NAT unfriendly? Also, how would I make my router be NAT friendly? [/quote] wait wait wait wait.. so connecting directly into the modem worked? so the issue is your router... and NAT... | October 23, 2007, 2:16 AM |
LockesRabb | [quote author=Leaky link=topic=17120.msg174125#msg174125 date=1193105816]wait wait wait wait.. so connecting directly into the modem worked? so the issue is your router... and NAT...[/quote] It would seem to be so. ;) If even with the assistance of the others I am unable to resolve the router/NAT issue, I'll probably just go ahead and replace the router. I tried replacing the firmware of the SR-200 with the DI-604 firmware so I could update it (Sorenson stopped bothering updating the firmware), but that was undoable. Googled various methodologies of hacking the firmware of the DI-604 and applied them on the SR-200, didn't work. Tried deliberately crashing the router's firmware so I could replace it, didn't work. In short, SR-200, for me at least, is uncrackable. So unless a solution to fix the NAT/router problem is found, the router may have to be replaced. :\ | October 23, 2007, 2:27 AM |
herzog_zwei | [quote author=Don Cullen link=topic=17120.msg174107#msg174107 date=1193095503] How would I best determine whether my code is NAT unfriendly? Also, how would I make my router be NAT friendly? [/quote] The key to designing a NATP friendly (as much as possible) UDP protocol has to do with: [quote]I believe most transparent NATP implementations open up a random port on the initial outbound UDP packet and incoming UDP must have a matching destination IP/port of what was opened on the router and a matching source IP/port of the initial UDP packet sent to. [/quote] Most UDP based games probably don't follow that rule so you have to use other routing tricks like port redirection and forwarding on the router. A simple test to make sure your code is NATP friendly (assuming you have a router that implements what I described) is to have one side of the network NATed (internal) and the other side normal (external). Have your program run on the NATed side (making sure the program initiates the connection to open up a random port on the router) and set up a data reflector/echoer on the other side to send back the data. If you receive the reflected data no matter what random port is opened on the router, it's as (transparent) NATP friendly as you're going to get. You should not have any code on the client that expects data to be received from any specific port nor embed local/internal IPs/ports to try to traverse the NATed network (some protocols do this and IMO is the wrong way to do it due to security issues and requiring proprietary routing code, not to mention it doesn't always work). Cheap routers generally don't give you much control over NAT so you'll need to play around with it to figure out how their NAT is implemented and work around it. Because most peer to peer UDP multiplayer (with more than 2 players) based games weren't designed with NAT in mind, you'll likely need to resort to port forwarding and/or redirection on the router. For a single player behind NAT using a game that locally binds to a static port A, you can use port forwarding of port A between the external and NATed side. For multiple players in a game that locally binds to static ports but the game server doesn't care about which port the datagram was sent on, you can redirect the ports and forward them based upon the redirected port on the external side and the internal IP on the NATed side. For games that aren't NAT friendly, dynamically bind, or expects data sent to the server came from a specific port, your only choice would be to use direct connection or DMZ for single player and multiple IP NAT/forwarding for multiple players. If your router supports UPnP, you can implement that to dynamically deal with port forwarding. If you have an old machine lying around with nothing to do, set up Linux/BSD on it to do the routing/firewalling. If you know what you're doing, you can fit everything you need onto a floppy disk (harder to do) or CD-ROM and not even have a HDD/monitor/keyboard/mouse installed. You will need two NICs though, one for each of the internal and external sides. | October 23, 2007, 5:00 AM |
MyStiCaL | login battle.net create game see if anyone can join. | October 23, 2007, 11:34 AM |
Leaky | [quote author=MyStiCaL link=topic=17120.msg174142#msg174142 date=1193139298] login battle.net create game see if anyone can join. [/quote] we've already established starcraft works perfectly fine.... and i've made various starcraft UDP related things and never had a nat or router issue... :P linksys i guess just magically works correctly | October 23, 2007, 12:50 PM |