[raknet] Implement RakPeer::SetMTUSize(...)

This commit is contained in:
RD42 2024-04-14 19:14:58 +08:00
parent 98dc42b0d7
commit ad8c70ee50
5 changed files with 64 additions and 6 deletions

View File

@ -36,5 +36,13 @@
#define DEFAULT_MTU_SIZE 576
#endif
/// The largest value for an UDP datagram
/// \sa RakPeer::SetMTUSize()
#ifdef SAMPCLI
#define MAXIMUM_MTU_SIZE 1492
#else
#define MAXIMUM_MTU_SIZE 576
#endif
#endif

View File

@ -346,9 +346,41 @@ void RakPeer::vftable_A4()
// TODO: RakPeer::vftable_A4() (saco W: 1003E520) (server W: 455810 L: 806DC70) (bot W: 4094C0 L: 8075056)
}
void RakPeer::vftable_A8()
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Description:
// Change the MTU size in order to improve performance when sending large packets
// This can only be called when not connected.
// A too high of value will cause packets not to arrive at worst and be fragmented at best.
// A too low of value will split packets unnecessarily.
//
// Parameters:
// size: Set according to the following table:
// 1500. The largest Ethernet packet size
// This is the typical setting for non-PPPoE, non-VPN connections. The default value for NETGEAR routers, adapters and switches.
// 1492. The size PPPoE prefers.
// 1472. Maximum size to use for pinging. (Bigger packets are fragmented.)
// 1468. The size DHCP prefers.
// 1460. Usable by AOL if you don't have large email attachments, etc.
// 1430. The size VPN and PPTP prefer.
// 1400. Maximum size for AOL DSL.
// 576. Typical value to connect to dial-up ISPs. (Default)
//
// Returns:
// False on failure (we are connected). True on success. Maximum allowed size is MAXIMUM_MTU_SIZE
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool RakPeer::SetMTUSize( int size )
{
// TODO: RakPeer::vftable_A8() (saco W: 10038860) (server W: 450360 L: 8070050) (bot W: 4042A0 L: 807514E)
if ( IsActive() )
return false;
if ( size < 512 )
size = 512;
else if ( size > MAXIMUM_MTU_SIZE )
size = MAXIMUM_MTU_SIZE;
MTUSize = size;
return true;
}
// --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -122,7 +122,16 @@ public:
void vftable_A0();
void vftable_A4();
void vftable_A8();
/// Set the MTU per datagram. It's important to set this correctly - otherwise packets will be needlessly split, decreasing performance and throughput.
/// Maximum allowed size is MAXIMUM_MTU_SIZE.
/// Too high of a value will cause packets not to arrive at worst and be fragmented at best.
/// Too low of a value will split packets unnecessarily.
/// Recommended size is 1500
/// sa MTUSize.h
/// \pre Can only be called when not connected.
/// \return false on failure (we are connected), else true
bool SetMTUSize( int size );
/// Returns the current MTU size
/// \return The current MTU size

View File

@ -118,7 +118,16 @@ public:
virtual void vftable_A0()=0;
virtual void vftable_A4()=0;
virtual void vftable_A8()=0;
/// Set the MTU per datagram. It's important to set this correctly - otherwise packets will be needlessly split, decreasing performance and throughput.
/// Maximum allowed size is MAXIMUM_MTU_SIZE.
/// Too high of a value will cause packets not to arrive at worst and be fragmented at best.
/// Too low of a value will split packets unnecessarily.
/// Recommended size is 1500
/// sa MTUSize.h
/// \pre Can only be called when not connected.
/// \return false on failure (we are connected), else true
virtual bool SetMTUSize( int size )=0;
/// Returns the current MTU size
/// \return The current MTU size

View File

@ -20,7 +20,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="d3d9\include\"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SACO_EXPORTS"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SACO_EXPORTS;SAMPCLI"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -72,7 +72,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="d3d9\include\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SACO_EXPORTS"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SACO_EXPORTS;SAMPCLI"
RuntimeLibrary="0"
StructMemberAlignment="1"
BufferSecurityCheck="FALSE"