mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-03-02 12:03:43 +00:00
Networking
The game uses a UDP-based protocol. Unlike TCP, UDP does not guarantee that packets arrive, or that they arrive in the correct order. For this reason, the game protocol implements those features using the following: * All packets have a sequence number that is utilized for reordering * Important packets are wrapped in a SlottedMetaPacket with a subslot number * RelatedA packets ae used to request lost packets using the subslot number * RelatedB packets are used to confirm received SlottedMetaPackets All of these go both ways, server <-> client. We used to only partially implement these features: Outgoing packet bundles used SMPs and could be resent, but not all packets were bundled and there was no logic for requesting lost packets from the client and there was no packet reordering, which resulted in dire consequences in the case of packet loss (zoning failures, crashes and many other odd bugs). This patch addresses all of these issues. * Packet bundling: Packets are now automatically bundled and sent as SlottedMetaPackets using a recurring timer. All manual bundling functionality was removed. * Packet reordering: Incoming packets, if received out of order, are stashed and reordered. The maximum wait time for reordering is 20ms. * Packet requesting: Missing SlottedMetaPackets are requested from the client. * PacketCoding refactor: Dropped confusing packet container types. Fixes #5. * Crypto rewrite: PSCrypto is based on a ancient buggy version of cryptopp. Updating to a current version was not possible because it removed the MD5-MAC algorithm. For more details, see Md5Mac.scala. This patch replaces PSCrypto with native Scala code. * Added two new actors: * SocketActor: A simple typed UDP socket actor * MiddlewareActor: The old session pipeline greatly simplified into a typed actor that does most of the things mentioned above. * Begun work on a headless client * Fixed anniversary gun breaking stamina regen * Resolved a few sentry errors
This commit is contained in:
parent
5827204b10
commit
407429ee21
232 changed files with 2906 additions and 4385 deletions
|
|
@ -1,57 +1,28 @@
|
|||
package net.psforever.pslogin
|
||||
/*
|
||||
|
||||
import actor.base.ActorTest
|
||||
import akka.actor.{ActorRef, Props}
|
||||
import akka.testkit.TestProbe
|
||||
import net.psforever.login.{HelloFriend, PacketCodingActor, RawPacket}
|
||||
import net.psforever.actors.net.MiddlewareActor
|
||||
import net.psforever.objects.avatar.Certification
|
||||
import net.psforever.packet.control.{ControlSync, MultiPacketBundle, SlottedMetaPacket}
|
||||
import net.psforever.packet.{ControlPacket, GamePacket, GamePacketOpcode, PacketCoding}
|
||||
import net.psforever.packet.control.{ControlSync, SlottedMetaPacket}
|
||||
import net.psforever.packet.{GamePacketOpcode, PacketCoding}
|
||||
import net.psforever.packet.game._
|
||||
import net.psforever.packet.game.objectcreate.ObjectClass
|
||||
import net.psforever.types._
|
||||
import scodec.bits._
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class PacketCodingActor1Test extends ActorTest {
|
||||
"PacketCodingActor" should {
|
||||
"construct" in {
|
||||
system.actorOf(Props[PacketCodingActor](), "pca")
|
||||
system.actorOf(Props[MiddlewareActor](), "pca")
|
||||
//just construct without failing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PacketCodingActor2Test extends ActorTest {
|
||||
"PacketCodingActor" should {
|
||||
"initialize (no r-neighbor)" in {
|
||||
val pca: ActorRef = system.actorOf(Props[PacketCodingActor](), "pca")
|
||||
within(200 millis) {
|
||||
pca ! HelloFriend(135, List.empty[ActorRef].iterator)
|
||||
expectNoMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PacketCodingActor3Test extends ActorTest {
|
||||
"PacketCodingActor" should {
|
||||
"initialize (an r-neighbor)" in {
|
||||
val probe1 = TestProbe()
|
||||
val probe2 = system.actorOf(Props(classOf[MDCTestProbe], probe1), "mdc-probe")
|
||||
val pca: ActorRef = system.actorOf(Props[PacketCodingActor](), "pca")
|
||||
val iter = List(probe2).iterator
|
||||
val msg = HelloFriend(135, iter)
|
||||
|
||||
assert(iter.hasNext)
|
||||
pca ! msg
|
||||
probe1.expectMsg(msg) //pca will pass message directly; a new HelloFriend would be an unequal different object
|
||||
assert(!iter.hasNext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PacketCodingActor4Test extends ActorTest {
|
||||
val string_hex = RawPacket(hex"2A 9F05 D405 86")
|
||||
val string_obj = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 6)
|
||||
|
|
@ -577,7 +548,7 @@ class PacketCodingActorITest extends ActorTest {
|
|||
probe1.receiveOne(300 milli) match {
|
||||
case RawPacket(data) =>
|
||||
assert(data == string_hex)
|
||||
PacketCoding.DecodePacket(data).require match {
|
||||
PacketCoding.decodePacket(data).require match {
|
||||
case _: SlottedMetaPacket =>
|
||||
assert(true)
|
||||
case _ =>
|
||||
|
|
@ -916,3 +887,5 @@ class PacketCodingActorLTest extends ActorTest {
|
|||
object PacketCodingActorTest {
|
||||
//decoy
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue