Valhalla Legends Forums Archive | Battle.net Bot Development | Clumped packets not parsing correctly (VB)

AuthorMessageTime
FuzZ
Well, I'm guessing it's all clumped packets together but I could be mistaken.

I'm mainly having trouble joining a channel with 20 people or more.

This is what happens.
http://www.bloodynub.com/files/bots/owns/DebugLog.txt
http://www.bloodynub.com/files/bots/owns/OwNs.jpg

If you look at the debug log you'll see that my userlist (which is a listview) is missing quite a few people, along with the user messages.

It seems to me it's something to do with the massive clumped packets.
99% of the time I don't receive any info messages logging on "Welcome to battle.net", "This server is hosted by", ect.


If anyone can help me troubleshoot this I would be most grateful.
I've been trying to figure this out for a few days.

Any information that I'm lacking in this message that might help just ask.

Crap, I thought I put that in, sorry.
here it is:
[code]
Private Sub sckBNet_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim strBuffer As String, TempRecv As String, lngLen As Long
Dim recv As New RecvBuffer
frmMain.sckBNet.GetData TempRecv, vbString
DebugOutput TempRecv, "recv"
strBuffer = strBuffer & TempRecv
While Len(strBuffer) > 4
lngLen = Val("&H" & StrToHex(StrReverse(Mid$(strBuffer, 3, 2))))
If Len(strBuffer) < lngLen Then: Exit Sub
recv.OnRecieve Left$(strBuffer, lngLen), frmMain.sckBNet
strBuffer = Mid$(strBuffer, lngLen + 1)
Wend
End Sub
[/code]

It's that I'm not recieving clumped packets well at all. generally like it shows in my DebugLog where it lists the users where it comes in 2 big clumped packets.
March 16, 2004, 8:44 PM
ChR0NiC
Before I attempt to help you.....lemme get this straight...
You are not receiving ID_INFO [&H12] correctly? Or is it...
you are not receiving ID_USER [&H1] correctly?
March 16, 2004, 8:53 PM
iago
Your problem is that you have to use the length of the packet to complete it. So if you see this:
FF 0F 00 10 00 00 00 00
You know that you HAVE to wait for the next next 8 bytes (no more, no less) to arrive, then process them and wait for the next packet. If it's already there, even better.
March 16, 2004, 8:55 PM
Telos
He is saying that his packet receiving function is not parsing out multiple packets correctly and therefore he frequently loses data. Post your oh this is sad I dont even remember the VB socket receive event but post that thing where you copy the received data into a buffer and parse it.
March 16, 2004, 8:56 PM
FuzZ
not sure if you would be able to tell i edited this from the botdev index, so check my edit. I'll reply from now on.
March 16, 2004, 9:21 PM
LoRd
Might also wanna format your milisecond timestamps to the hundred form to make your bot text aligned and purty.
March 17, 2004, 6:43 PM
Lenny
You're strBuffer should be a static variable or else you wont be able to parse any packets that come in pieces rather than whole...

[code]
Dim strBuffer As String
[/code]
should be
[code]
Static strBuffer as String
[/code]
March 17, 2004, 7:49 PM
FuzZ
Yeah, LoRd that has been pissin me off, just to worried about other stuff to fix it.
Lenny, i bet you're absolutely right, let me go try that.
Success! Thank you Lenny.. I figured it was probably something stupid like that I wouldn't notice.
As I'm sure you can probably tell I'm just a beginner (newb) when it comes to programming.. Thanks so much :)
March 17, 2004, 8:21 PM
DarkMinion
You need to store the number of bytes that your socket actually received, and also store the asserted packet length that is found within the packet. When your parsing function begins to check a packet, if the asserted length is less than what you actually received, you must store the incomplete data and wait for more data to come in via your socket.

It's not as hard as it sounds, just have to do it right...my parsing function will return 0 if the buffer holds nothing but complete packets, and then the buffer will be cleared, if it returns > 0, the buffer will not be cleared, and the bot will wait for more data.
March 17, 2004, 9:06 PM
UserLoser.
Shouldn't do > 4, some packets like SID_NULL may only be 4 bytes long and shouldn't be ignored
March 18, 2004, 12:39 AM
iago
Actually, SID_NULL should be ignored :P
March 18, 2004, 12:55 AM
UserLoser.
[quote author=iago link=board=17;threadid=5832;start=0#msg50171 date=1079571340]
Actually, SID_NULL should be ignored :P
[/quote]

Why?

I try to be like the real game client as much as possible, in my opinion, so should other bots. I believe it's best to support every message that you can and handle them properly

Edit:

Ok, better example: 0x59
March 18, 2004, 1:00 AM
o.OV
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50166 date=1079570382]
Shouldn't do > 4, some packets like SID_NULL may only be 4 bytes long and shouldn't be ignored
[/quote]

I wouldn't use such a check either.
However.. It isn't really ignored.
It will get "processed" as soon as another packet arrives.

Add-On:

That is.. if you don't clear the buffer
like in the example given by uh.. whats his name..
March 18, 2004, 1:14 AM
UserLoser.
[quote author=o.OV link=board=17;threadid=5832;start=0#msg50178 date=1079572491]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50166 date=1079570382]
Shouldn't do > 4, some packets like SID_NULL may only be 4 bytes long and shouldn't be ignored
[/quote]

I wouldn't use such a check either.
However.. It isn't really ignored.
It will get "processed" as soon as another packet arrives.
[/quote]

But then wouldn't the following packet not be processed?

I'd then be something below be parsed?:

FF 00 04 00 <other packet>
March 18, 2004, 1:21 AM
o.OV
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50179 date=1079572902]
[quote author=o.OV link=board=17;threadid=5832;start=0#msg50178 date=1079572491]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50166 date=1079570382]
Shouldn't do > 4, some packets like SID_NULL may only be 4 bytes long and shouldn't be ignored
[/quote]

I wouldn't use such a check either.
However.. It isn't really ignored.
It will get "processed" as soon as another packet arrives.
[/quote]

But then wouldn't the following packet not be processed?

I'd then be something below be parsed?:

FF 00 04 00 <other packet>
[/quote]

huh? what are you talking about.
In the example by fuzz
it allows the null packet to sit in the buffer
without actually entering the loop
until another packet arrives which
adds to the length of the buffer so len(buffer) > 4
then it starts to process.
March 18, 2004, 1:26 AM
LoRd
[quote author=o.OV link=board=17;threadid=5832;start=0#msg50180 date=1079573217]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50179 date=1079572902]
[quote author=o.OV link=board=17;threadid=5832;start=0#msg50178 date=1079572491]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50166 date=1079570382]
Shouldn't do > 4, some packets like SID_NULL may only be 4 bytes long and shouldn't be ignored
[/quote]

I wouldn't use such a check either.
However.. It isn't really ignored.
It will get "processed" as soon as another packet arrives.
[/quote]

But then wouldn't the following packet not be processed?

I'd then be something below be parsed?:

FF 00 04 00 <other packet>
[/quote]

huh? what are you talking about.
In the example by fuzz
it allows the null packet to sit in the buffer
without actually entering the loop
until another packet arrives which
adds to the length of the buffer so len(buffer) > 4
then it starts to process.
[/quote]
The buffer would be redimmed as soon as a packet was received, unless you were to declare it as a static variable.
March 18, 2004, 4:00 AM
FuzZ
I've noticed sometimes that I recieve SID_NULL if I've been sittin in a channel for a while when I enter any kind of chat. (I have a notice to see when it was requested) for example
[pre]
[0:57:44:125] <AoD-Ekion@Azeroth Blizzsource Radio Will Be Down Today For Awhile Due To Maintance And Other Stuff Thanks>
[1:1:22:953] Keep Alive.
[1:1:42:578] Keep Alive.
[1:1:42:593] To your friends: do do do do do do do do do do do do od od do do do do do dod od od od do do dod od od od do do d
[/pre]

I'm not really sure, but I dont think I recieved anything in between those. although when I sent that /f m I did recieve one as soon as i hit enter.

Edit-> I just noticed that it was probably processed because of another SID_NULL that was recieved, which was then stuck in the buffer. Perhaps, I should change it from Len(strBuffer) > 4 to Len(strBuffer) >= 4 ??
March 18, 2004, 6:32 AM
o.OV
[quote author=LoRd[nK] link=board=17;threadid=5832;start=15#msg50211 date=1079582430]
[quote author=o.OV link=board=17;threadid=5832;start=0#msg50180 date=1079573217]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50179 date=1079572902]
[quote author=o.OV link=board=17;threadid=5832;start=0#msg50178 date=1079572491]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50166 date=1079570382]
Shouldn't do > 4, some packets like SID_NULL may only be 4 bytes long and shouldn't be ignored
[/quote]

I wouldn't use such a check either.
However.. It isn't really ignored.
It will get "processed" as soon as another packet arrives.
[/quote]

But then wouldn't the following packet not be processed?

I'd then be something below be parsed?:

FF 00 04 00 <other packet>
[/quote]

huh? what are you talking about.
In the example by fuzz
it allows the null packet to sit in the buffer
without actually entering the loop
until another packet arrives which
adds to the length of the buffer so len(buffer) > 4
then it starts to process.
[/quote]
The buffer would be redimmed as soon as a packet was received, unless you were to declare it as a static variable.
[/quote]

Eh? Here are some quotes for you, Lord[nK].

[quote author=Lenny link=board=17;threadid=5832;start=0#msg50079 date=1079552988]
You're strBuffer should be a static variable or else you wont be able to parse any packets that come in pieces rather than whole...

[code]
Dim strBuffer As String
[/code]
should be
[code]
Static strBuffer as String
[/code]
[/quote]

[quote author=FuzZ link=board=17;threadid=5832;start=0#msg50091 date=1079554890]
Yeah, LoRd that has been pissin me off, just to worried about other stuff to fix it.
Lenny, i bet you're absolutely right, let me go try that.
Success! Thank you Lenny.. I figured it was probably something stupid like that I wouldn't notice.
As I'm sure you can probably tell I'm just a beginner (newb) when it comes to programming.. Thanks so much :)
[/quote]
March 18, 2004, 7:03 AM
Skywing
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50175 date=1079571646]
[quote author=iago link=board=17;threadid=5832;start=0#msg50171 date=1079571340]
Actually, SID_NULL should be ignored :P
[/quote]

Why?

I try to be like the real game client as much as possible, in my opinion, so should other bots. I believe it's best to support every message that you can and handle them properly

Edit:

Ok, better example: 0x59
[/quote]
The official client has discarded messages with ID < 0x05 for a long, long time now.
March 18, 2004, 7:11 AM
iago
[quote author=Skywing link=board=17;threadid=5832;start=15#msg50225 date=1079593896]
[quote author=UserLoser. link=board=17;threadid=5832;start=0#msg50175 date=1079571646]
[quote author=iago link=board=17;threadid=5832;start=0#msg50171 date=1079571340]
Actually, SID_NULL should be ignored :P
[/quote]

Why?

I try to be like the real game client as much as possible, in my opinion, so should other bots. I believe it's best to support every message that you can and handle them properly

Edit:

Ok, better example: 0x59
[/quote]
The official client has discarded messages with ID < 0x05 for a long, long time now.
[/quote]

Oh yeah, before the switch it subtracts 4 from the code. I had completely forgotten about that :)
March 19, 2004, 12:14 AM

Search