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: LaunchDOOM spawns 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. GetLocalAddress gets 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 at nodeadr[MAXNETNODES].
  • Line 39–46: OpenSocket creates a new IPX network socket with the specified number.
  • Line 51–56: CloseSocket closes an IPX socket.
  • Line 58–66: ListenForPacket queues a receive operation for an IPX packet.
  • Line 69–75: GetLocalAddress retrieves the local node address.
  • Line 158–162: ShutdownNetwork closes 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: GetPacket finds 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 doomcom buffer and prepare for next packet.
  • Line 182–185: The NetISR interrupt handler coordinates network packet handling, while LookForNodes manages 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 the packets array (packet_t) is configured:
    • ecb.ECBSocket is set to socketid (line 129)
    • FragmentCount to 2 (line 130)
    • fAddress[0–1] point to the embedded IPXPacket payload via FP_OFF/FP_SEG (lines 131–132)

54.0.3 File: ipx/IPXSETUP.C

  • Line 85–95: NetISR is installed at DOOM’s interrupt level.
  • Line 112–119: LookForNodes manages 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: IPXPacket struct defines the header format for IPX network packets.
  • Line 59–66: ECB struct tracks IPX packet transmission status and routing.
  • Line 82–90: packet_t combines ECB, IPXPacket header, timestamp, and doomdata_t for 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.