Author | Message | Time |
---|---|---|
Loud | I've checked BNETDocs, and Developement resources already... I just have a basic lame question, because nobody I know can tell me ANYTHING about packets (all my programmer friends are on vacation). Should 0x01 contain more than one user per packet? I got the impression from BNETDocs that it shouldn't but it does... Uhhh, thanks in advance. | July 20, 2005, 12:11 AM |
Quarantine | It doesn't send them all together but it will send that packet continuously per user. | July 20, 2005, 12:20 AM |
Loud | Hmm, that's odd... [code]..<.........^...............CLaN-SoF10]SoF.3RAW 1R3W 0 dRoW...4.........................o4]SoF[.3RAW 1R3W 0 FoS...4.........^...............o1]SoF[.3RAW 1R3W 0 FoS...U.........^...............JaCKeD@USWest.NB2W 7190 116 12931 0 0 7304 1448 426 NB2W...F.........}...............Gangster@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W...F.........m...............Suspense@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W...J.........................HotCrossBuns@USWest.PXES 0 0 3 0 0 0 0 0 PXES...F.........................DNX]SoF[@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W...:.........m...............imaloser]sof[.3RAW 1R3W 0 FoS...=.........N...............RuM_N_CoKe]SoF[.3RAW 1R3W 1 dRoW...5.........?...............RuM_BoT]SoF[.3RAW 1R3W 0...4.........?...............o6]SoF[.3RAW 1R3W 0 FoS...I.........................I-DNX]SoF[@USWest.NB2W 0 0 40 0 0 0 0 0 NB2W...G.........................Loud]SoF[@USWest.RATS 0 0 0 0 0 0 0 0 RATS...4.........^...............o2]SoF[.3RAW 1R3W 0 FoS...4.........^...............o3]SoF[.3RAW 1R3W 0 FoS...;.........^...............ClaNSoF)1]SoF[.3RAW 1R3W 0 FoS...B.........................Loud@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W.[/code] That is the text from the right (I am pretty newb at programming at the moment), and my logger claims it is all one packet. On EID 0x01 my bot SHOULD add the user enclosed in 0x01... But with shit like this, it just doesn't do it. Any idea what's wrong? I am using BNCSUtility if that is of any use... | July 20, 2005, 12:28 AM |
HdxBmx27 | Give us a format output of it, including the hex value of it. What i think is happening is that you are simply get all those packets at once, and you need to seperate them out. ~-~(HDX)~-~ Edit, It seems that you are reciving these 18 packets: [code]..<.........^...............CLaN-SoF10]SoF.3RAW 1R3W 0 dRoW. ..4.........................o4]SoF[.3RAW 1R3W 0 FoS. ..4.........^...............o1]SoF[.3RAW 1R3W 0 FoS. ..U.........^...............JaCKeD@USWest.NB2W 7190 116 12931 0 0 7304 1448 426 NB2W. ..F.........}...............Gangster@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W. ..F.........m...............Suspense@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W. ..J.........................HotCrossBuns@USWest.PXES 0 0 3 0 0 0 0 0 PXES. ..F.........................DNX]SoF[@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W. ..:.........m...............imaloser]sof[.3RAW 1R3W 0 FoS. ..=.........N...............RuM_N_CoKe]SoF[.3RAW 1R3W 1 dRoW. ..5.........?...............RuM_BoT]SoF[.3RAW 1R3W 0. ..4.........?...............o6]SoF[.3RAW 1R3W 0 FoS. ..I.........................I-DNX]SoF[@USWest.NB2W 0 0 40 0 0 0 0 0 NB2W. ..G.........................Loud]SoF[@USWest.RATS 0 0 0 0 0 0 0 0 RATS. ..4.........^...............o2]SoF[.3RAW 1R3W 0 FoS. ..4.........^...............o3]SoF[.3RAW 1R3W 0 FoS. ..;.........^...............ClaNSoF)1]SoF[.3RAW 1R3W 0 FoS. ..B.........................Loud@USWest.NB2W 0 0 0 0 0 0 0 0 NB2W.[/code] So Like I said, you need to split them up. ~-~(HDX)~-~ | July 20, 2005, 12:30 AM |
Loud | I am not very apt at Visual Basic 6 right now, can you point me in the direction as to which I need to go to separate the recieved packets? I am not 100% sure what means you can do it by. Sorry to be so needy, but I want my bot not to crash when a users leaves because they aren't found on the user list. | July 20, 2005, 12:38 AM |
HdxBmx27 | http://bnetdocs.valhallalegends.com/content.php?Section=d&id=6 Check out the BNCS headers. Notice that it has a 'Length' section? Thats how you tell how to split it up. Just throw everything you recive into a incoming buffer (a string vareable) after you get it out of the winsock. Then while Len(Buffer) >=4 then 'get the lengeth and parse it. If the Lengeth in the header is longer then the current buffer, then wait for more to come. It's not hard. As for crashing cusz it's not found in the userlist... thats jsut bad coding :/ ~-~(HDX)~-~ | July 20, 2005, 1:01 AM |
Loud | Lol, your solution sounds like it will work. Thanks for the commentary about my code to, that helps a lot... =/ | July 20, 2005, 1:20 AM |
LoRd | TCP/IP is a streaming protocol--data is sent and received in chunks. This presents a problem: If data is being sent and received in chunks, how will you know when one message ends and another begins? The answer to that question is an application-defined packet header which generally contains the length of the packet, and in some cases, additional information as well. Battle.net's packet header is 4 bytes long and consists of the header ID (0xFF), the packet ID and the length of the packet. You'll need to seperate each individual packet based on it's length before processing it. Due to the fact that data is received in chunks, you may not always receive all of a packet at once, so you'll need to buffer the incoming data and wait for the rest of the packet to be received. You may also encounter times where you receive multiple packets at once, as you have here. | July 20, 2005, 1:33 AM |
Loud | I can't figure out how to throw all my data recieved into a string... (Yes, I suck at coding.) Also, HDX, for your statement, where did you pull 4 from? Is that so that it checks the BNCS header...? | July 20, 2005, 2:06 AM |
R.a.B.B.i.T | socket.GetData BufferString, vbString I suggest you learn to program (that's VB6, btw). | July 20, 2005, 2:11 AM |
Tontow | (BYTE) Always 0xFF - 1 byte (BYTE) Message ID - 1 byte (WORD) Message length, including this header - 2 bytes = 4 bytes | July 20, 2005, 2:14 AM |
Loud | Yes, I'm back for more abuse (Thanks Rabbit I <3 you)... Anyways, let me lay out this concept as I am percieving it, because I don't know if I am interpreting this correctly! You are bascially saying, find out the length of the individual packet (That has been mashed wish several of the same type), extract that individual part, parse it, then continue on to the next part in the packet, until you have run out. Errr, is this correct? If so, how do I dispose of the part(s) that I have dealt with? I am newb, but I am thinking I should use something like this... [code] 'Let's say, PacketToParse is what I am parsing... PacketToParse = Mid(AllPacketText, PStart, PLength) [/code] That is probably the completely incorrect way to do this, but it is all I can think up (Tired)... This method kind of screws me, because I don't know how to dispose of PacketToParse that has been parsed, because it will just continually parse the same part... Uhhh, any suggestions, other than rabbit's "Learn to program"... | July 20, 2005, 3:05 AM |
Arta | When you have parsed the the packet -- which, by the way, should correctly be named a message -- you move the rest of the buffer back according to the length of the message you parsed. For example, if you parse a message 20 bytes long, you would move all of the data in the buffer backwards by 20 bytes. I'm not a VB programmer, so this will not be written correctly, but the concept is what's important: [code] ' extract a message for parsing PacketToParse = Mid(AllPacketText, PStart, PLength) ' reset the buffer AllPacketText = Mid(AllPacketText, PLength, Length(AllPacketText) - PLength) [/code] | July 20, 2005, 3:11 AM |
Loud | [code] ' reset the buffer AllPacketText = Mid(AllPacketText, PLength, Length(AllPacketText) - PLength)[/code] Subtracting PLength from Len(AllPacketText), I am unsure about that... Wouldn't it remove from the (for lack of a better term) bottom of the packet...? I know you aren't a VB programmer, but maybe somebody that is can clarify that. | July 20, 2005, 3:47 AM |
Tontow | Maby these could be of some help: https://davnit.net/bnet/vL/phpbbs/index.php?topic=12149.0 https://davnit.net/bnet/vL/phpbbs/index.php?topic=12218.0 | July 20, 2005, 4:18 AM |
HdxBmx27 | [quote author=Arta[vL] link=topic=12276.msg121317#msg121317 date=1121829090] [code] ' extract a message for parsing PacketToParse = Left(AllPacketText, PStart, PLength) ' reset the buffer AllPacketText = Mid(AllPacketText, PLength, Length(AllPacketText) - PLength) [/code] [/quote] Should be this: [code] ' extract a message for parsing PacketToParse = Mid(AllPacketText, PStart, PLength) ' reset the buffer AllPacketText = Mid(AllPacketText, PLength + 1) [/code] Simpe as that. Considering We are coming at it from the bigining of the string, PStart is always 1, Or you could sjut use Left() Insted of Mid() for the 1st part. PLength Would be simple. PLengeth = Val("&H" & Hex(ASC(Mid(AllPacketText, 4, 1)) & Hex(ASC(Mid(AllPacketText, 4, 1))) It'd be much better if you use a spacific function to convert a word from it's ASCII state to it's integer equivalent.. But w/e that works. So let me Pull this all together for you: [code]Sub Winsock.DataArival() Static AllPacketText as string Dim PLengeth as Integer, tmpInfo as string, PacketToParse as String Winsock.GetData tmpInfo, vbString AllPacketText = AllPacketText & tmpInfo Do While Len(AllPacketText) >= 4 PLengeth = Val("&H" & Hex(ASC(Mid(AllPacketText, 4, 1)) & Hex(ASC(Mid(AllPacketText, 4, 1))) If Len(AllPacketText) < PLengeth then Exit Sub 'We don't have all the info, wait for more PacketToParse = Left(AllPacketText, PLength) AllPacketText = Mid(AllPacketText, PLength + 1) 'Whoot this si where you parse the packets!!!!! Loop End Sub[/code] Note, Just wrote that, it's untested ~-~(HDX)~-~ | July 20, 2005, 7:39 AM |
Kp | Alternately, if you were using a language that actually supported indexing operations well, you'd just step the iterator forward by 20 bytes. :) | July 22, 2005, 2:17 AM |
Loud | Kp pwns me and my Visual Basic... I see the error in my ways, and promise to only program in C from this day on... As soon as I can cough up X amount of money for Visual C++...? Uhh, maybe later. | July 22, 2005, 2:54 AM |
LoRd | Note that it would also be a good idea to have a sanity check to ensure that the packet is not of some obsurd length, one which could possibly overflow your buffer. [code]Public Type BNCSPKT bytPktHdr As Byte bytPktID As Byte intPktLen As Integer strPktData As String End Type[/code] [code]' Removes individual packets from the incoming TCP/IP stream and passes them to parsing function Public Sub PreParse(ByRef strData As String, ByVal lngLen As Long) Dim pkt As modBNCS.BNCSPKT lngLstBeat = GetTickCount() bMsdBeats = 0 ' Store incoming data stream in buffer With PktInBuf .InsertRAW strData ' Check for buffer errors If (.LastErr() > 0) Then .ClearBuf Exit Sub End If ' Remove packet(s) from buffer While (.BufSize() >= 4) If (.PeekBYTE() <> &HFF) Then ' Packet has an invalid header .ClearBuf Exit Sub End If pkt.intPktLen = .PeekWORD(3) If (pkt.intPktLen > .BufSize()) Then ' Incomplete packet Exit Sub End If Call CopyMemory(pkt, ByVal .GetRAW(4), 4) pkt.strPktData = .GetRAW((pkt.intPktLen - 4)) Call ParsePkt(pkt) Wend End With End Sub[/code] | July 22, 2005, 3:01 AM |
Kp | [quote author=Loud link=topic=12276.msg121632#msg121632 date=1122000879]Kp pwns me and my Visual Basic... I see the error in my ways, and promise to only program in C from this day on... As soon as I can cough up X amount of money for Visual C++...? Uhh, maybe later.[/quote] Or you could get a free C++ compiler? :P | July 22, 2005, 4:58 AM |