The Design and Implementation of the FreeBSD Operating System

   

10.9. Other Line Disciplines

We have examined the operation of the terminal I/O system using the standard terminal-oriented line-discipline routines. For completeness, we will briefly describe the other class of line disciplines in the system used to connect serial lines to the network.

The point-to-point protocol (PPP), point-to-point line discipline is used by networking software to encapsulate and transfer Internet Protocol (IP) datagrams over asynchronous serial lines [Simpson, 1994]. (See Chapter 13 for information about IP.) The PPP line discipline allows moderate-speed network connections from a machine lacking high-speed network hardware.

The ppp program opens a serial line, sets the line's speed, and enters the PPP line discipline. The PPP line discipline's open routine associates the terminal line with a preconfigured network interface and prepares to send and receive network packets. Once the interface's network address is set with the ifconflg program, the network will route packets through the PPP line to the system to which it connects.

The output path is started every time a packet is output to the PPP interface. Packets are enqueued on one of two queues: one for interactive traffic and one for other traffic. Interactive traffic takes precedence over other traffic. The PPP discipline places the framing characters and the data of the next packet onto the output queue of the tty, sometimes compressing packet headers. It then starts transmission by calling ttstart(), which in turn calls the device's start routine referenced in the tty t_oproc field. It may place multiple packets onto the output queue before returning, as long as the system is not running short of C-list blocks. However, it stops moving packets into the tty output queue when the character count has reached a low limit (60 bytes) so that future interactive traffic is not blocked by noninteractive traffic already in the output queue. When transmission completes, the device driver calls the PPP start routine, which continues to place data onto the output queue until all packets have been sent or the queue hits the limit again.

When characters are received on a line that is using the PPP discipline, the data characters are placed into a network buffer. When a framing character ends the packet, the packet header is uncompressed if necessary, the packet is presented to the network protocol, and the buffer is reinitialized.


   
 

Категории