LP(4)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1

πŸ’… LP(4) β€” like, the printer port Internet Protocol driver, bestie

okay so real talk: this is the manual page for lp, the printer port Internet Protocol driver, from the Kernel Interfaces Manual. yes, that manual. grab a strawberry πŸ“ and let's go.


✨ NAME ✨

lp β€” the printer port Internet Protocol driver. that's it, that's the whole vibe. it turns your humble parallel port into a whole network interface. iconic behavior tbh πŸ‘‘


🌸 SYNOPSIS 🌸

ifconfig plip0 myaddress hisaddress [-link0]

device ppbus
device plip
device ppc

like, that's the whole summoning ritual. no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the lp driver lets a PC parallel printer port be used as a point-to-point network interface between two similarly configured systems. yes, the printer port. the beige one. it's giving main character energy 🌈

data gets transferred 4 bits at a time, using the printer status lines for input β€” so you literally do not need special bidirectional hardware, and any standard AT-compatible printer port with working interrupts may be used. lowkey genius.

during the boot process, for each plip device which is probed and has an interrupt assigned, a corresponding network device is created. cute, automatic, slay ✨

configuring an lp device with ifconfig(8) causes the corresponding parallel port bus to be reserved for PLIP until the network interface is configured 'down'. so like... it's holding the port, respectfully 🫢

the communication protocol is selected by the link0 flag:

  • -link0 β€” the default. use FreeBSD mode (LPIP). this is the simpler of the two modes and therefore slightly more efficient. the low-effort queen we respect πŸ’…
  • link0 β€” use Crynwr/Linux compatible mode (CLPIP). this mode has a simulated Ethernet packet header, and is easier to interface to other types of equipment. gateway-friendly fr fr.

the interface MTU defaults to 1500, but may be set to any value. both ends of the link must be configured with the same MTU β€” like, matching outfits or it doesn't work πŸ™ˆ


πŸŽ€ Cable Connections πŸŽ€

the cable connecting the two parallel ports should be wired as follows:

        Pin     Pin     Description
        2       15      Data0 -> ERROR*
        3       13      Data1 -> SLCT
        4       12      Data2 -> PE
        5       10      Data3 -> ACK*
        6       11      Data4 -> BUSY
        15      2       ERROR* -> Data0
        13      3       SLCT   -> Data1
        12      4       PE     -> Data2
        10      5       ACK*   -> Data3
        11      6       BUSY   -> Data4
        18-25   18-25   Ground

cables with this wiring are widely available as 'Laplink' cables, and are often coloured yellow. yes bestie, the yellow one. you know the one πŸ’›

the connections are symmetric, and provide 5 lines in each direction (four data plus one handshake). the two modes use the same wiring, but make a different choice of which line to use as handshake. same cable, different personality ✨


🧚 FreeBSD LPIP mode 🧚

the signal lines are used as follows:

  • Data0 (Pin 2) β€” Data out, bit 0.
  • Data1 (Pin 3) β€” Data out, bit 1.
  • Data2 (Pin 4) β€” Data out, bit 2.
  • Data3 (Pin 5) β€” Handshake out.
  • Data4 (Pin 6) β€” Data out, bit 3.
  • ERROR* (pin 15) β€” Data in, bit 0.
  • SLCT (pin 13) β€” Data in, bit 1.
  • PE (pin 12) β€” Data in, bit 2.
  • BUSY (pin 11) β€” Data in, bit 3.
  • ACK* (pin 10) β€” Handshake in.

when idle, all data lines are at zero. each byte is signalled in four steps, and honestly the choreography is kind of a serve:

  1. sender writes the 4 most significant bits and raises the handshake line
  2. receiver reads the 4 bits and raises its handshake to acknowledge
  3. sender places the 4 least significant bits on the data lines and lowers the handshake
  4. receiver reads the data and lowers its handshake

periodt. that's the whole dance πŸ’ƒ

the packet format has a two-byte header, comprising the fixed values 0x08, 0x00, immediately followed by the IP header and data.

the start of a packet is indicated by simply signalling the first byte of the header. the end of the packet is indicated by inverting the data lines (i.e., writing the ones-complement of the previous nibble to be transmitted) without changing the state of the handshake. sneaky little end marker, we love her 🌸

note that the end-of-packet marker assumes that the handshake signal and the data-out bits can be written in a single instruction β€” otherwise certain byte values in the packet data would falsely be interpreted as end-of-packet. not a problem for the PC printer port, but requires care when implementing this protocol on other equipment. so like, be careful out there 😭

🐚 Crynwr/Linux CLPIP mode 🐚

the signal lines are used as follows:

  • Data0 (Pin 2) β€” Data out, bit 0.
  • Data1 (Pin 3) β€” Data out, bit 1.
  • Data2 (Pin 4) β€” Data out, bit 2.
  • Data3 (Pin 5) β€” Data out, bit 3.
  • Data4 (Pin 6) β€” Handshake out.
  • ERROR* (pin 15) β€” Data in, bit 0.
  • SLCT (pin 13) β€” Data in, bit 1.
  • PE (pin 12) β€” Data in, bit 2.
  • ACK* (pin 10) β€” Data in, bit 3.
  • BUSY (pin 11) β€” Handshake in.

when idle, all data lines are at zero. each byte is signalled in four steps β€” and watch out, the nibble order flips:

  1. sender writes the 4 least significant bits and raises the handshake line
  2. receiver reads the 4 bits and raises its handshake to acknowledge
  3. sender places the 4 most significant bits on the data lines and lowers the handshake
  4. receiver reads the data and lowers its handshake
[Note that this is the opposite nibble order to LPIP mode]. yes, opposite. don't mix them up bestie πŸ’€

Packet format is:

Length (least significant byte)
Length (most significant byte)
12 bytes of supposed MAC addresses (ignored by FreeBSD).
Fixed byte 0x08
Fixed byte 0x00
<IP datagram>
Checksum byte.

the length includes the 14 header bytes, but not the length bytes themselves nor the checksum byte.

the checksum is a simple arithmetic sum of all the bytes (again, including the header but not checksum or length bytes). FreeBSD calculates outgoing checksums, but does not validate incoming ones. trust but verify? no. just trust 🫢

the start of packet has to be signalled specially, since the line chosen for handshake-in cannot be used to generate an interrupt. so the sender writes the value 0x08 to the data lines, and waits for the receiver to respond by writing 0x01 to its data lines. the sender then starts signalling the first byte of the packet (the length byte). it's a little secret handshake, iykyk 🀝

end of packet is deduced from the packet length and is not signalled specially (although the data lines are restored to the zero, idle state to avoid spuriously indicating the start of the next packet). tidy little queen ✨


πŸ‘€ SEE ALSO πŸ‘€

go read them, they're all connected, it's a whole lore drop πŸ“š


πŸ’€ BUGS πŸ’€

okay so, the messy parts, and we're gonna be honest about them:

  • Busy-waiting loops are used while handshaking bytes, (and worse still when waiting for the receiving system to respond to an interrupt for the start of a packet). hence a fast system talking to a slow one will consume excessive amounts of CPU. 😭 this is unavoidable in the case of CLPIP mode due to the choice of handshake lines; it could theoretically be improved in the case of LPIP mode. so like... theoretically. not today though.
  • Polling timeouts are controlled by counting loop iterations rather than timers, and so are dependent on CPU speed. this is somewhat stabilised by the need to perform (slow) ISA bus cycles to actually read the port. so the slowness kind of cancels out?? generous of it honestly πŸ™ˆ

and that's the page, bestie πŸ’– this one's dated March 4, 1996, coming at you from Debian β€” yes, 1996, the parallel port's peak era, we stan a vintage icon. mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from