Most uses of this function are a single message.
This removes the overhead of GroupBy() and ToList() for every call at the expense of retaking the lock in cases where multiple messages of the same group are sent.
fix possible problem with a C2S packet sequence received that is previous to the current position.
NAK packets aren't re-transmitted in AC protocol, don't store them in S2C cache
* Fartwhifs "Removing unused pattern from CryptoSystem for slightly better performance." PR
* PacketHeader Improved Efficiency
* Improve ClientPacket.ParsePacketData() efficiency
* Packet.Data does not need to be disposed()
See here: ac99a1b716/src/Common/src/CoreLib/System/IO/MemoryStream.cs (L124)
Disposing simply sets _isOpen, _writable, _expandable to false. It doesn't even release the reference to the buffer passed in to the ctor.
* WIP
* revert the RangeAdvance stuff
* More improvements
* More improvements
* More naming improvements
* Updated database instructions in README.md to prevent an error
The instructions in README.md now ask the reader to set up `ace_world`
with WorldBase.sql before applying incremental updates. This prevents more
recent `ace_shard` updates from producing an error due to a failed join.
* BuildPacketString() now pays heed to the startPosition and bytesToOutput arguments
* Packing debugging output no longer overflows the segment of the buffer pool allocated to the packet
This is a simple patch to help CE mem usage. The proper fix is to funnel NetworkSession work through Session, so that Session can manage it's state directly.
What is happening now, and can/will happen in the future, is that Player references are being held, and thus, their Session and NetworkSession objects aren't being released.
Even after a Session drops, work can still be enqueued onto NetworkSession through ActionChains and other means. This PR will now ignore that work. Currently, in master, that work is received and held indefinitely (until Player/Session are released)
This also fixes the case where NetworkSession work was being enqueued after a session dropped, but before the Player was fully logged out of the world. Now, that work will be ignored.
* Network Stability Improvements
It was possible for packetQueue to get corrupt when clients request packet retransmits. At that point, multiple threads could be enqueing work.
This adds slight overhead by converting it to a ConcurrentQueue, but, should also (hopefully) fix the "corrupt sessions" issue people were seeing.
This should also fix the exception that was reported in NetowrkSession.FlushPackets()
* improve comment
improved session termination and logging
improved command parameter parsing
session termination due to network problems should not be sending anything
refactor session termination terminology
moved textual session termination reasons to the same file as the termination reasons enum
added optional reason to boot command
boot axe man, char, griefing and spamming chat
boot 0x5000000C, iid
boot 1342177292, iid
* MemoryStream.ToArray() -> GetBuffer()
This is the partial implementation of the previous PR.
There is still one more MemoryStream.ToArray() in the code, but, the usage of MemoryStream in that area is a bit complex and will take some further work to get away from ToArray()
* This should fix the CreateReadyToSendPacket exception on retransmit
* fixed bug causing disconnects due to NAK requests being dropped.
added asynchronous verification of encrypted CRCs
added checksum caching to ClientPacket
removed "generational ISAAC" debugging tools
fixed a bug causing session to enter an unspecified state when the connect request packet sent to the client was corrupted in transit
added handling of trusted packet with ClientSentNetErrorDisconnect flag
fixed bug during handshake causing defunct session to linger
fixed AccountSelectCallback was being called in both the try and catch sections of a try/catch block leading to crashes whenever a bad handshake occurs
implemented parsing of optional "flow" header data
added more network logging
* added packetLog to WorldManager
removed pre-processor definition NETDIAG and directives
* Remove RunActions() from IActor interface
* make Landblock an IActor
* Make WorldManager an IActor
* Remove AgressiveInlinding from ActionQueue.RunActions (Helps break up profiling results)
* Fix WorldManager EnqueueAction
* Split WorldObject ActionQueues into Landblock and Player
* Switch Landblock from o(n) to o(1)
* Loop in reverse order, no need to create a new list using FindAll.
* use an ArrayPool<byte> to conserve resources and improve performance
* cosmetic
* Update/Tick Age every 7 seconds for Players (Before, this was consuming 1% CPU)
* More packet transmission improvements
* Add thread safety to ObjectMaint.ServerObjects
WorldObjects can be created by any thread, and, they update this collection
* Remove "tried to appraise object, couldn't find it" warning.
* Check for null landblock before trying to remove on logoff
* Cleanup more session edge cases
* Cleanup SocketManager
No need to use a list. It's a fixed array.
* Vector3 is a struct. It doesn't need to be member copied like a class.
* .NET core has native Vector3.Normalize that is 3x as fast
b90c49ce3c/src/System.Numerics.Vectors/src/System/Numerics/Vector3.cs (L204)
* Vector3.LengthSquared2D improvement
It's 3x faster just to perform the low level operation than to instantiate a new Vector2 and call that objects method.
b90c49ce3c/src/System.Numerics.Vectors/src/System/Numerics/Vector2.cs (L124)
* Vector3 IsEqual extension removed. Using == is 4x faster
* Vector3 IsMoved extension replaced with != (it's 4x faster)
* InterpolationManager PositionQueue should be a LinkedList
* Change a couple enum .HasFlag to & != 0 in performance critical areas
This just improves performance in debug mode when the optimize flag isn't checked.
* Use LinkedList.First != null instead of .Count > 0
* Revert "Use LinkedList.First != null instead of .Count > 0"
This reverts commit c643b73910.
Because of this bug, ACE has been sending packets with no size limit. While this works well on a local network, it could have had reliablity issues over a WAN.
ServerPacket has a MaxPacketSize of 464. This stems from the original days of ACE.
I suspect this is the maximum size of AC related data we can stuff into a UDP packet (before overhead is added) to keep the UDP packet sent over the WAN in a single fragment.
If we increase this value, it could reduce some server load and byte overhead, but, if a single fragment of the UDP is lost, all fragments will be lost and have to be resent.
* it allows clients to connect from behind a specific rare firewall configuration
not sure which of these hacks is/are needed
* fixed a connection issue for some client firewalls guarding clients connecting over WAN by changing port strategy from two unidirectional ports to a single bidirectional port with the exception of the connect response packet
bolstered security by using random initialization vectors for the CRC stream ciphers instead of a constant and known IV
changed to using a random cookie for the three-way handshake, this adds a certain effectiveness of DoS attack, but is needed for the single bidirectional port strategy
* test for correct listener
* revert some minor changes
documentation changes
* check for same IP Address
* removed dependency of Physics.Common.Random from network code
using bare System.Random constructor without locking since the network processor is single threaded
documentation
* moved CICMDCommand conditional to listener 1 path
documentation
* use sessionLock for iteration of sessionMap
consolidate ban TO-DO comments
* minor log change
* curate usings
documentation
* adding @netstats admin command
* trying to figure out the issue
* fixing bug causing AcknowledgeSequence packets to increment the lastReceivedFragmentSequence variable, causing the Sequence to break and never recover for that session
fixing bug causing RequestTransmit packets to be ignored
fixing bug causing the server to crash when a C2S packet is corrupt or malformed
changing the C2S RequestForTransmit packet count to be per request packet instead of per requested sequence
adding Developer commands junk, junk_s2c, junk_c2s, trash_s2c, and trash_c2s to simulate bad connections and manually corrupt packets
* updating changelog.md
* Update changelog.md
fixed incorrect variable name referred to in change log
* Update changelog.md
fix formatting
* adding preprocessor definition NETDIAG and directives to ACE.Common and ACE.Server to help development by preserving troubleshooting tools without interference with the optimal solution
* Apply suggestions from code review
set accessor only needed for NETDIAG functionality
minor change log addition
* reverting some unnecessary source syntax and formatting changes.
removing an unused exception variable
* reverting some unnecessary source syntax and formatting changes
* minor optimization of a duplicate prevention check
* Fixing jump in multiplayer, refactoring movement and animation systems for network and game layers
* Fixing stamina dropping to 0 while running
* Fixing some monsters getting stuck if they wakeup during idle emote
* Reverting position
* Fixing magic aftercast speed
* RateMonitor created
* NetworkSession Update foreach change to help profiling
This just removes the lambda pattern for the foreach so profilers can monitor each line individually.
Functionality is unchanged.
* Reduce Landblock ctor async work to a single thread
This helps reduce ACE thread starvation
* NetworkSession cosmetic
* NetworkSession cosmetic
* NetworkSession currentBundles ConcurrentDictionary to Array
This significantly improves the performance of NetworkSession.
Arrays are faster than Dictionaries, and we manage concurrency to the elements via currentBundleLocks.
We're also able to get away with using an array because the number of elements is only 12.
Accessing the indexes of currentBundles should be atomic as it's an array of reference values, compiled as 64 bit.
* Add InParallel to database functions that do their underlying work in parallel
* DoSessionWork tick outbound messages in series, not in parallel.
* NetworkSession should not be interfacing with ActionChains
* Don't load landblock ctor resources in parallel
Save the threads in the pool for more important work
* LandblockManager removed check/recheck
This is legacy code from a pattern no longer used. It is no longer required.
* Cosmetic
* Move DoSessionWork to follow the order in which it's called (last)
* We don't need to set player.Teleporting here. It's set in the Player.Teleport function
* Reduce Portal debug messages to a single line
* NetworkSession time comparisons should be >=
* NetworkSession removed outdated comment
* Removed LandBlockStatus. It was undeveloped
Furthermore, I believe we would be using different status values for the current state of ACE
* Removed Landblock IsActive. It was always true (never used)
* EmoteManager player is null check (fixes crash)
* Offload Landblock ctor work into separate tasks.
This makes portaling around the world onto new landblocks much more responsive.
* cosmetic ocd
* Fix Appraise Object warning
* Reimplementation of Timers class.
This centralizes all the timers in ACE to ACE.Server.Entity.Timers.
* Session Tick comment cleanup
* Sessions no longer maintain their own ServerTime
WorldManager.UpdateWorld was sending each ticks ElapsedTime to sessions. Sessions would add this to their own ServerTime value.
This is not needed. The only time Sessions reference this value is from within their TickInParallel functions, which are called from WorldManager.Update.
For now, we just point the existing variable that was being used (SessionConnectionData.ServerTime) to Timers.PortalYearTicks.
I suspect we thought this value might need thread safety at some point which is why we might have had each session maintain their own value.
* DerethDateTime UTCNowToLoreTime to UtcNowToLoreTime
The info log level shouldn't be too verbose. Info sould just have 1 record for a connect and disconnect.
The other debugging messages have been moved to the Debug log level.