Skip to main content

Networking & Communication Overview

Build Information

Current documentation based on build version: 676042 Last updated: 2025-06-21

System Purpose

The Networking & Communication category provides the foundational infrastructure for multiplayer gameplay in Don't Starve Together. This comprehensive system encompasses network communication protocols, chat and command systems, and multiplayer-specific features that enable seamless collaborative gameplay across distributed clients and server clusters.

Key Responsibilities

  • Establish and maintain client-server network connections
  • Synchronize game state across all connected players
  • Provide chat messaging and command execution systems
  • Enable inter-shard communication for cluster management
  • Deliver multiplayer-specific content and UI synchronization
  • Manage server preferences and content filtering

System Scope

This category includes all network communication protocols, client-server synchronization, chat systems, command frameworks, and multiplayer UI management but excludes game-specific logic (handled by Game Mechanics) and core engine functionality (handled by System Core).

Architecture Overview

System Components

The networking and communication infrastructure is built on a multi-layered architecture that separates transport protocols, data synchronization, user interaction, and multiplayer features.

Communication Flow

Client Input → RPC Validation → Network Transport → Server Processing
↓ ↓ ↓ ↓
Chat Commands → Command Parser → Permission Check → Vote System
↓ ↓ ↓ ↓
UI Events → Popup Manager → Content Delivery → State Sync
↓ ↓ ↓ ↓
User Output ← NetVar Updates ← Response Messages ← Action Results

Data Synchronization Architecture

[Game State] → [NetVars] → [Network Layer] → [All Clients]
↓ ↓ ↓ ↓
[World Events] → [RPC Calls] → [Validation] → [State Updates]
↓ ↓ ↓ ↓
[Shard Sync] → [Cluster Mgmt] → [Portal System] → [Cross-Shard Travel]

Integration Points

  • System Core: Engine networking services and platform integration
  • World Systems: Entity synchronization and world state management
  • User Interface: Screen management and popup synchronization
  • Game Mechanics: Action validation and command execution

Recent Changes

BuildDateComponentChange TypeDescription
6760422025-06-21NetworkingstableCore network infrastructure
6760422025-06-21Chat CommandsstableChat and command systems
6760422025-06-21MultiplayerstableMultiplayer-specific features

Core System Categories

Networking

Core network communication infrastructure for client-server and cluster coordination.

ModuleStatusDescriptionKey Features
Core NetworkingstableServer management and connectionsClient handling, session management, RPC routing
Network Client RPCstableRemote procedure callsAction validation, movement, inventory sync
Network VariablesstableState synchronizationNetVar types, automatic sync, event handling
Shard NetworkingstableInter-shard communicationCluster coordination, portal travel, boss sync
Shard IndexstableCluster data managementSave persistence, world configuration

Chat Commands

Communication and command execution systems for player interaction and server administration.

ModuleStatusDescriptionKey Features
Chat HistorystableMessage storage and syncCircular buffer, filtering, listener system
User CommandsstableCommand execution frameworkPermission system, voting, rate limiting
Built-in CommandsstableStandard server commandsAdmin tools, player commands, voting integration
Vote UtilitiesstableVoting system implementationVote tallying, validation, result processing
Word FilterstableContent filtering systemHash-based filtering, pattern matching

Multiplayer

Multiplayer-specific systems for content delivery, UI synchronization, and player experience.

ModuleStatusDescriptionKey Features
MOTD ManagerstableContent delivery systemAnnouncements, patch notes, image caching
Popup ManagerstableUI popup synchronizationRPC communication, screen management
Server PreferencesstableClient preference managementServer filtering, profanity detection

Common Network Patterns

Client-Server Communication

-- Send action from client to server
SendRPCToServer(RPC.LeftClick, action_code, x, z, target)

-- Synchronize health across all clients
local health_netvar = net_float(inst.GUID, "health", "healthdirty")
health_netvar:set(current_health)

-- Handle RPC on server (automatic validation)
-- RPC_HANDLERS[RPC.LeftClick] processes the request

Chat and Command Integration

-- Register a command with voting
AddUserCommand("restart", {
params = {},
permission = COMMAND_PERMISSION.ADMIN,
vote = true,
votetimeout = 30,
voteresultfn = VoteUtil.YesNoMajorityVote,
serverfn = function(params, caller)
TheNet:SendWorldResetRequestToServer()
end
})

-- Send command response
ChatHistory:SendCommandResponse("Server restart initiated")

Multiplayer Content Management

-- Access MOTD content
if TheMotdManager:IsEnabled() then
local motd_info, sorted_keys = TheMotdManager:GetMotd()
for i, key in ipairs(sorted_keys) do
local content = motd_info[key]
if content.data.category == "patchnotes" then
DisplayPatchNotes(content)
end
end
end

-- Manage popup synchronization
POPUPS.COOKBOOK.fn(ThePlayer, true) -- Open cookbook with RPC sync

Cross-Shard Coordination

-- Check shard availability
if Shard_IsWorldAvailable("Caves") then
portal.components.worldmigrator:SetEnabled(true)
end

-- Synchronize events across shards
Shard_SyncBossDefeated("dragonfly", "Forest")

Network System Dependencies

Required Systems

Optional Systems

Performance Considerations

Network Optimization

  • NetVar types optimized for bandwidth efficiency (1-bit bools to 32-bit floats)
  • RPC rate limiting prevents client flooding (20 RPCs per tick base limit)
  • Chat history uses circular buffer to limit memory usage (100 messages max)
  • Content delivery employs progressive loading and caching strategies

Synchronization Efficiency

  • Dirty event system triggers updates only when values change
  • Command queue processing batches operations for network efficiency
  • Shard communication minimizes cross-shard traffic through selective synchronization
  • Vote state updates reduce bandwidth usage during active voting periods

Memory Management

  • Automatic cleanup of mod commands when mods are unloaded
  • NetVar listener management prevents memory leaks
  • Content cache management with automatic expiration
  • Command history and rate limiting counters cleared each update cycle

Development Guidelines

Best Practices

  • Always validate RPC parameters using provided check* functions
  • Use smallest appropriate NetVar type to minimize bandwidth usage
  • Implement proper permission checking for command systems
  • Handle network failures gracefully with retry mechanisms
  • Test all networking features in multiplayer environments

Common Pitfalls

  • Not validating RPC parameters can cause synchronization issues
  • Using expensive array NetVars for frequently changing data
  • Bypassing permission systems during development
  • Not handling network latency in client predictions
  • Creating commands without proper rate limiting considerations

Testing Strategies

  • Test RPC validation with various parameter combinations
  • Verify NetVar synchronization across multiple clients
  • Test command execution with different permission levels
  • Validate vote systems with varying player counts
  • Check network behavior during connection interruptions

Network Security Framework

RPC Security

  • All RPC parameters validated using type-safe validation functions
  • Position validation prevents teleportation and movement exploits
  • Rate limiting blocks RPC flooding attacks and prevents server overload
  • Server authority maintained for all critical game state decisions

Command Security

  • Multi-level permission system (User/Moderator/Admin)
  • Vote requirements for sensitive operations prevent unauthorized actions
  • Command cooldowns and rate limiting prevent abuse
  • Input sanitization protects against injection attacks

Content Security

  • Word filtering system blocks inappropriate content
  • Server preference system allows user-controlled content filtering
  • Profanity detection with hash-based and pattern-based filtering
  • Content validation ensures safe multiplayer environment

System Integration Patterns

With User Interface

Network systems drive UI presentations:

  • Chat messages populate interface elements with formatting
  • Command menus provide point-and-click access to slash commands
  • Vote dialogs display real-time voting progress and options
  • MOTD content appears in main menu announcement sections

With World Systems

Network integration affects world state:

  • Entity actions synchronized through RPC validation
  • World events trigger NetVar updates across all clients
  • Shard communication enables cross-world boss synchronization
  • Portal travel coordinates cluster-wide player movement

With Game Mechanics

Networking enables gameplay features:

  • Inventory actions validated and synchronized through RPCs
  • Crafting commands processed with server authority
  • Player interactions coordinated across multiple clients
  • Achievement and progression synchronized cluster-wide

Troubleshooting Network Issues

Common RPC Problems

IssueSymptomsSolution
RPC validation failuresActions not executingCheck parameter types and ranges
Rate limiting triggeredCommands being ignoredReduce command frequency
Position validation errorsMovement/action failuresVerify player position validity
Mod RPC conflictsCustom commands not workingCheck namespace conflicts

Common NetVar Problems

IssueSymptomsSolution
Synchronization failuresInconsistent client stateEnsure identical NetVar declarations
Performance degradationNetwork lagUse appropriate NetVar types
Memory leaksIncreasing memory usageProperly manage NetVar listeners
Update frequency issuesExcessive network trafficAvoid frequent array NetVar updates

Common Chat/Command Problems

IssueSymptomsSolution
Commands not executingNo response to slash commandsCheck command registration and permissions
Chat not syncingMissing messagesVerify network connectivity
Voting failuresVotes not completingCheck player count and requirements
Content filtering issuesValid content blockedReview filter patterns

Extension and Customization

Adding Custom Network Features

  • Use existing RPC patterns for new client-server communication
  • Follow established NetVar conventions for state synchronization
  • Leverage command framework for new administrative functionality
  • Implement proper validation and security measures

Network System Customization

  • Register custom RPC handlers using mod RPC system
  • Create specialized NetVar patterns for unique synchronization needs
  • Extend command system with mod-specific commands
  • Add custom content delivery through MOTD system extension

Performance Optimization

  • Profile network usage and optimize critical paths
  • Implement efficient caching strategies for frequently accessed data
  • Use compression techniques for large data transfers
  • Monitor and tune rate limiting parameters for specific use cases

Future Development Considerations

Scalability Design

  • Network architecture supports unlimited mod RPC registration
  • Command system accommodates arbitrary custom commands
  • Content delivery adapts to various platform requirements
  • Vote utilities handle diverse voting patterns and requirements

Integration Planning

  • New network features should leverage existing validation patterns
  • Communication systems should follow established RPC conventions
  • UI synchronization should use popup manager for consistency
  • Content delivery should integrate with established caching mechanisms
SystemRelationshipIntegration Points
System CorePlatform layerEngine services, platform networking
User InterfacePresentation layerScreen management, chat display
World SystemsGame logic layerEntity sync, world events
Game MechanicsGameplay layerAction validation, command execution

Contributing Guidelines

Adding Network Features

  1. Follow established RPC patterns for client-server communication
  2. Implement comprehensive parameter validation for security
  3. Use appropriate NetVar types for optimal bandwidth usage
  4. Consider cross-shard implications for cluster functionality
  5. Test thoroughly in multiplayer environments with network variations

Communication System Modifications

  1. Maintain backward compatibility with existing command interfaces
  2. Follow established patterns for permission and voting systems
  3. Consider performance impact of message processing changes
  4. Test synchronization behavior across multiple clients
  5. Document any new command types or communication patterns

Quality Standards

  • All network communication must include proper validation
  • RPC handlers must handle edge cases gracefully
  • NetVar usage must be optimized for bandwidth efficiency
  • Command systems must enforce appropriate security measures
  • Integration points must be documented and validated