54 IPX Backend
This tour covers DOOM’s IPX backend. We’ll explore ipx/DOOMNET.C (launching DOOM), ipx/IPXNET.C (driver interface), and ipx/IPXSETUP.C (node discovery).
This section examines the data structures and functions used by the IPX networking backend to handle multiplayer communication.
54.0.1 File: ipx/DOOMNET.C
- Line 65–68:
LaunchDOOMspawns and executes the DOOM executable after network initialization is complete.
54.0.2 File: ipx/IPXNET.C
- Line 94–99: Checks for IPX driver presence and creates a pointer to access its functions.
- Line 104–107: The socketid bytes are swapped and opened.
GetLocalAddressgets the local node address. - Line 113–119: Sets up receive buffers by configuring ECB packet structures.
- Line 127–136: Initializes packet 0’s ECB structure with socket and fragment configuration.
- Line 140–147: Stores local node address in
nodeadr[0]and sets all-0xFF broadcast address atnodeadr[MAXNETNODES]. - Line 39–46:
OpenSocketcreates a new IPX network socket with the specified number. - Line 51–56:
CloseSocketcloses an IPX socket. - Line 58–66:
ListenForPacketqueues a receive operation for an IPX packet. - Line 69–75:
GetLocalAddressretrieves the local node address. - Line 158–162:
ShutdownNetworkcloses the active IPX socket during program shutdown. - Line 178–186: The packet receives a timestamp and its destination addressing information before being sent.
- Line 187–196: Sets packet fragment sizes and sends the packet using IPX, checking for transmission errors.
- Line 199–204: Relinquishes CPU control while waiting for the send buffer to become available.
- Line 232–240:
GetPacketfinds the oldest unprocessed message in the receive buffer. - Line 249–254: Returns false if no valid packet is found in the queue.
- Line 267–275: Maps packet source address to a known DOOM node index.
- Line 285–291: Copy received data into
doomcombuffer and prepare for next packet. - Line 182–185: The
NetISRinterrupt handler coordinates network packet handling, whileLookForNodesmanages IPX node discovery during setup. - Line 199–203: The Interrupt Service Routine (ISR) handles network packet interrupts in the IPX implementation.
- Line 129–132: In
InitNetwork, the first entry of thepacketsarray (packet_t) is configured:ecb.ECBSocketis set tosocketid(line 129)FragmentCountto 2 (line 130)fAddress[0–1]point to the embeddedIPXPacketpayload viaFP_OFF/FP_SEG(lines 131–132)
54.0.3 File: ipx/IPXSETUP.C
- Line 85–95:
NetISRis installed at DOOM’s interrupt level. - Line 112–119:
LookForNodesmanages the node discovery process for networked DOOM games. - Line 217–224: During network setup, this code broadcasts the current node count to all potential peers every second.
54.0.4 File: ipx/IPXNET.H
- Line 31–40:
IPXPacketstruct defines the header format for IPX network packets. - Line 59–66:
ECBstruct tracks IPX packet transmission status and routing. - Line 82–90:
packet_tcombinesECB,IPXPacketheader, timestamp, anddoomdata_tfor packet tracking.
GetPacket selects the next packet to be processed from the received packet queue, which allows DOOM to handle incoming network messages in order.