Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CHAPTER 2 THEORITICAL FOUNDATION Theoretical Foundation 2.1 Network A computer network is composed of multiple connected computers that communicate over a wired or wireless medium to share data and other resources. For instance, a home computer network may consist of two or more computers that share files and a printer using the network. The size and scalability of any computer network are determined both by the physical medium of communication and by the software controlling the communication 2.1.1 Types of Networks Below is a list of the most common types of computer networks in order of scale. Personal Area Network (PAN) A personal area network (PAN) is a computer network used for communication among computer devices. The reach of a PAN is typically a few meters. Personal area networks may be wired with computer buses such as USB and FireWire. A wireless personal area network (WPAN) can also be made possible with network technologies such as IrDA and Bluetooth. 5 6 Local Area Network (LAN) A network covering a small geographic area, like a home, office, or building. Current LANs are most likely to be based on Ethernet technology. Hosts can be made part of a specific LAN can be defined by setting their address to one within the address range of the LAN subnet This can be done by manual configuration, or by configuring DHCP (Dynamic Host Configuration Protocol) auto-configuration to give the host an address in the appropriate range.Currently standardized LAN technologies operate at speeds up to 10 Gbit/s. IEEE has projects investigating the standardization of 100 Gbit/s, and possibly 40 Gbit/s. Campus Area Network (CAN) A network that connects two or more LANs but that is limited to a specific and contiguous geographical area such as a college campus, industrial complex, or a military base. Today, a campus may use a mixture of routing and bridging. The network elements used, called "campus switches", tend to be optimized to have many Ethernet interfaces rather than an arbitrary mixture of Ethernet and WAN interfaces. Wide Area Network (WAN) A WAN is a data communications network that covers a relatively broad geographic area (i.e. one country to another and one continent to another 7 continent) and that often uses transmission facilities provided by common carriers, such as telephone companies. Global Area Network (GAN) In general, however, a GAN is a model for supporting mobile communications across an arbitrary number of wireless LANs, satellite coverage areas, etc. The key challenge in mobile communications is "handing off" the user communications from one local coverage area to the next. Internetwork Two or more networks or network segments connected using devices that operate at layer 3 (the 'network' layer) of the OSI Basic Reference Model, such as a router. Any interconnection among or between p ublic, private, commercial, industrial, or governmental networks may also be defined as an internetwork.In modern practice, the interconnected networks use the Internet Protocol. There are at least three variants of internetwork, depending on who administers and who participates in them: Intranet An intranet is a set of interconnected networks, using the Internet Protocol and uses IP-based tools such as web browsers, that is under the control of a single administrative entity. That administrative entity closes the intranet to the rest of 8 the world, and allows only specific users. Most commonly, an intranet is the internal network of a company or other enterprise. Extranet A extranet is network or internetwork that is limited in scope to a single organization or entity but which also has limited connections to the networks of one or more other usually, but not necessarily, trusted organizations or entities (e.g., a company's customers may be provided access to some part of its intranet thusly creating an ext ranet while at the same time the customers may not be considered 'trusted' from a security standpoint). "The" Internet A specific internetwork, consisting of a worldwide interconnection of governmental, academic, public, and private networks based upon the Advanced Research Projects Agency Network (ARPANET) developed by ARPA of the U.S. Department of Defense – also home to the World Wide Web (WWW) and referred to as the 'Internet' with a capital 'I' to distinguish it from other generic internetworks. Participants in the Internet, or their service providers, use IP Addresses obtained from address registries that control assignments. Service providers and large enterprises also exchange information on the reachability of their address ranges through the Border Gateway Protocol. 9 2.1.2 Basic Hardware Components All networks are made up of basic hardware building blocks to interconnect network nodes, such as Network Interface Cards (NICs), Bridges, Hubs, Switches, and Routers. In addition, some method of connecting these building blocks is required, usually in the form of galvanic cable (most commonly Category 5 cable). Less common are microwave links (as in IEEE 802.11) or optical cable ("optical fiber"). Network Interface Cards A network card, network adapter or NIC (network interface card) is a piece of computer hardware designed to allow computers to communicate over a computer network. It provides physical access to a networking medium and provides a low- level addressing system through the use of MAC addresses. It allows users to connect to each other either by using cables or wirelessly. Repeaters A repeater is an electronic device that receives a signal and retransmits it at a higher level or higher power, or onto the other side of an obstruction, so that the signal can cover longer distances without degradation. Because repeaters work with the actual physical signal, and do not attempt to interpret the data being transmitted, they operate on the Physical layer, the first layer of the OSI model. 10 Hubs A hub contains multiple ports. When a packet arrives at one port, it is copied the packets to all the ports of the hub. When the packets are copied, the destination address in the frame does not change to a broadcast address. It does this in a rudimentary way; it simply copies the data to all of the Nodes connected to the hub. Bridges A bridge always connects two parts of the same type of network channel – just as a physical transport bridge always connects a road to a road and railway to a railway. Bridges amplify the signal like a repeater, but they also have packet filtering capabilities – only packets that have business on the other side of the bridge (i.e. are addressed to a system that exists there) are passed over and amplified. Switches Switches are a marketing term that encompasses routers and bridges, as well as devices that may distribute traffic on load or by application content (e.g., a Web URL identifier). Switches may operate at one or more OSI layers, including physical, data link, network, or transport (i.e., end-to-end). 11 Routers Routers connect different LANs together to form an intranet or connect a LAN to a WAN, such as the internet. A router has network layer functionality that enables it to read the network address of the packets it receives. Only packets for nodes on its network segment are passed on. Routers do not forward broadcast messages. Unlike a bridge, a router can link different types of network such as Ethernet and Token Ring. 2.2 WI-FI The Wi-Fi wireless network is based on the IEEE 802.11 standard, and includes 802.11b (an 11 Mbps technology, currently the most popular form of Wi-Fi), 802.11a (a 54 Mbps technology, a newer and emerging favorite), and 802.11g (55 Mbps). The Wi-Fi Alliance is the body responsible for promoting the term and its association with various wireless technology standards. Typical implementations for 802.11 wireless networking include connecting laptops to corporate networks, and allowing home networking users to connect PCs together without introducing new wiring. With a transmission distance of around 300 feet and a throughput rate that tops out at 55 Mbps, Wi-Fi provides ample throughput for most wireless applications. Wireless Access Points The most common form of wireless Access Point (AP) is a transceiver connected to a wired LAN component such as a PC or a router. The AP provides a gateway between a wired network such as a broadband cable Internet service 12 and wireless enabled devices. Any device with a compatible transceiver can communicate with the access point if it is in range – typically 30 m in a normal building, further if in direct line of sight. Wireless APs act like servers (of fixed network services) to Mobile Terminals (MTs). 2.3 RADIUS Remote Authentication Dial In User Service (RADIUS) is an AAA (authentication, authorization and accounting) protocol for applications such as network access or IP mobility. It is intended to work in both local and roaming situatio ns. Many networks services (including corporate networks and public ISPs using modem, DSL, or wireless 802.11 technologies) require you to present security credentials (such as a username and password or security certificate) in order to connect on to the network. Before access to the network is granted, this information is passed to a Network Access Server (NAS) device over the link- layer protocol (for example, Point-to-Point Protocol (PPP) in the case of many dialup or DSL providers), then to a RADIUS server over the RADIUS protocol. The RADIUS server checks that the information is correct using authentication schemes like PAP, CHAP or EAP. If accepted, the server will then indicate to the NAS that you are authorized to access the network. RADIUS also allows the authentication server to supply the NAS with additional parameters, such as The specific IP address to be assigned to the user The address pool from which the user's IP should be chosen 13 The maximum length that the user may remain connected An access list, priority queue or other restrictions on a user's access L2TP parameters RADIUS is also commonly used for accounting purposes. The NAS can use RADIUS accounting packets to notify the RADIUS server of events such as The user's session start The user's session end Total packets transferred during the session Volume of data transferred during the session Reason for session ending Radius is a common authentication protocol utilized by the 802.1X security standard (often used in wireless networks). Although RADIUS was not initially intended to be a wireless security authentication method, it improves the WEP encryption key standard, in conjunction with other security methods such as EAP-PEAP. 2.4 Internet Protocols In this context, there are three layers of protocols: At the lower level (OSI layer 3) is IP (Internet Protocol), which defines the datagram or packets that carry blocks of data from one node to another. The vast majority of today's Internet uses version four of the IP protocol (i.e. IPv4, and 14 although IPv6 is standardized, it exists only as "islands" of connectivity, and there are many ISPs without any IPv6 connectivity. [1]. ICMP (Internet Control Message Protocol) also exists at this level. ICMP is connectionless; it is used for control, signaling, and error reporting purposes. TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) exist at the next layer up (OSI layer 4); these are the protocols by which data is transmitted. TCP makes a virtual 'connection', which gives some level of guarantee of reliability. UDP is a best-effort, connectionless transport, in which data packets that are lost in transit will not be re-sent. The application protocols sit on top of TCP and UDP and occupy layers 5, 6, and 7 of the OSI model. These define the specific messages and data formats sent and understood by the applications running at each end of the communication. Examples of these protocols are HTTP, FTP, and SMTP. 2.4.1 Internet Protocol Suite The Internet protocol suite is the set of communications protocols that implement the protocol stack on which the Internet and most commercial networks run. It has also been referred to as the TCP/IP protocol suite, which is named after two of the most important protocols in it: the Transmission Control Protocol (TCP) and the Internet Protocol (IP), which were also the first two networking protocols defined. 15 The Internet Protocol suite—like many protocol suites—can be viewed as a set of layers. Each layer solves a set of problems involving the transmission of data, and provides a well-defined service to the upper layer protocols based on using services from some lower layers. Upper layers are logically closer to the user and deal with more abstract data, relying on lower layer protocols to translate data into forms that can eventually be physically transmitted. The TCP/IP reference model consists of four layers. 2.4.2 Layers in the Internet Protocol suite The IP suite uses encaps ulation to provide abstraction of protocols and services. Generally a protocol at a higher level uses a protocol at a lower level to help accomplish its aims. DNS, TFTP, TLS/SSL, FTP, Gopher, HTTP, IMAP, IRC, NNTP, POP3, SIP, SMTP, SNMP, SSH, TELNET, ECHO, BitTorrent, RTP, PNRP, rlogin, ENRP 4. Application Routing protocols like BGP, which for a variety of reasons run over TCP, may also be considered part of the application or network layer. 3. Transport TCP, UDP, DCCP, SCTP, IL, RUDP 2. Internet Routing protocols like OSPF, which run over IP, are also to be considered part of the network layer, as they provide path selection. ICMP and IGMP run over IP and are considered part 16 of the network layer, as they provide control information. IP (IPv4, IPv6) ARP and RARP operate underneath IP but above the link layer so they belong somewhere in between. Ethernet, Wi-Fi, token ring, PPP, SLIP, FDDI, ATM, Frame 1. Network access Relay, SMDS 2.5 Internet Printing Protocol Since 1996, industrial leading software and printer vendors started to form a work group. The primary objective of this workgroup is to define a protocol which can cover the most common situations for printing on the Internet regardless the operating environments. The first proposed solution is Internet Printing Protocol (IPP), released during 1999. Internet Printing Protocol (IPP) means a mechanism to print documents over Internet. It creates an association between a printer and a web URL address. With IPP, documents from client machines can be readily submitted print jobs to server machine or printers via Internet using HTTP (standard web protocol). Also, the user can inquire about the capabilities of a printer, inquire about the status of a print job, and cancel a job via standard web browser. 17 This mechanism facilitates greater printing flexibility, like remote printing. Also, adopting IPP can ease the problem of integrating different printing mechanisms implemented on different operating systems. The design goals of IPP are: for a user to find out about a printer's capabilities for a user to submit print jobs to a printer for a user to find out the status of a printer or a print job for a user to cancel a previously submitted job 2.5.1 Current Implementation A list of current implementations of IPP (both clients and serves) can be found in IPP Work Group. Two major implementation may worth mentioning here: Microsoft Windows 2000 Print Server The Windows 2000 printing architecture has incorporated with IPP. With help of Microsoft Internet Information Server (IIS), users can readily print documents to Windows 2000 print server via Internet. Features provided by Windows 2000 include: Printing documents from Windows 2000 Professional or Windows XP clients to Windows 2000 print servers using a Uniform Resource Locator (URL). Using Internet Explorer to manage printers, control print jobs, and view the printer and print job's status. 18 Connecting to printers on corporate network and install printer driver via Internet Explorer. Common Unix Printing System The Common UNIX Printing System (CUPS) is designed to be a crossplatform printing solution for all UNIX environments. It's design and implementation is based on IPP. The latest implementation supports IPP/1.1 and provides a complete, modern printing system for UNIX. It can be extended to support new printers, devices, and protocols while providing compatibility with existing UNIX applications. RedHat Linux, starting from 7.3, has adopted CUPS as its native printing system that replaces LPRng. 2.5.2 How will IPP Benefits The immediate benefit of adopting Internet Printing in campus may be: Network Printing Service Enhanced for notebook users W2K/WXP users no longer need to join to domain before they can access and print to campus network printers. (This is particularly useful to notebook users since they can just go online, connect to campus network printer via IPP and then print the documents). 19 2.6 Photocopier A photocopier is a machine which makes paper copies of documents and other visual images quickly and cheaply. Most current photocopiers use a technology called xerography, a dry process using heat. (Copiers can also use other output technologies such as ink jet, but xerography is standard for office copying.) Xerographic office photocopying was introduced by Xerox in the 1960s, and over the following 20 years it gradually replaced copies made by Verifax, Photostat, carbon paper, mimeograph machines, and other duplicating machines. The prevalence of its use is one of the factors that prevented the development of the paperless office heralded early in the digital revolution. 2.7 Printer A computer printer, or more commonly a printer, produces a hard copy (permanent human-readable text and/or graphics) of documents stored in electronic form, usually on physical print media such as paper transparencies. Many printers are primarily used as computer peripherals, and are attached by a printer cable to a computer which serves as a document source. Other printers, commonly known as network printers, have built- in network interfaces (typically wireless or Ethernet), and can serve as a hardcopy device for any user on the network. Printers are designed for low-volume, short-turnaround print jobs; requiring virtually no setup time to achieve a hard copy of a given document. However, printers are 20 generally slow devices (30 pages per minute is considered fast; and many consumer printers are far slower than that), and the cost-per-page is relatively high. 2.7.1 Modern Printing Technology The following printing technologies are routinely found in modern printers, as of April 2006: Toner-based printers The most common type of toner-based printer is the laser printer, which uses precision lasers to cause adherence. Laser printers are known for high quality prints, good print speed, and a low (Black and White) cost-per-copy; they are the most common printer for many general-purpose office applications. They are far less commonly used as consumer printers due to a high initial cost. Liquid inkjet printers Inkjet printers consist of nozzles that produce very small ink bubbles that turn into tiny droplets of ink. The dots formed are the size of tiny pixels. Ink-jet printers can print high quality text and graphics. They are also almost silent in operation. Inkjet printers have a much lower initial cost than do laser printers, but have a much higher cost-per-copy, as the ink needs to be frequently replaced. Solid ink printers Solid ink printers are most commonly used as color office printers, and are excellent at printing on transparencies and other non-porous media. Solid ink 21 printers can produce excellent results. Acquisition and operating costs are similar to laser printers. Drawbacks of the technology include high power consumption and long warm-up times from a cold state. Dye-sublimation printers Dye-sub printers are intended primarily for high-quality color applications, including color photography; and are less well-suited for text. While once the province of high-end print shops, dye-sublimation printers are now increasingly used as dedicated consumer photo printers. 22 Theoretical Framework The Printing Architecture is one of the major components from Windows architecture. It consists of a print spooler and a set of printer drivers. The applications can create print jobs and send them to the printers by calling device- independent Win32 printing and GDI functions. Printer drivers include a user interface component that allows users to control a printer's selectable options (Paper Size, Number of copies, Coloration, Pages per sheet etc.). An application's calls to Win32 GDI functions are passed to the GDI graphics engine, which either spools the drawing instructions as an enhanced metafile (EMF) file or, in conjunction with a printer driver, renders a printable image that can be sent to the spooler. Spooler components interpret EMF files, and they can insert page layout information and job control instructions into the data stream. The spooler then sends the data stream to the serial, parallel, or network port driver associated with the target printer's I/O port. Spooler and driver components are designed to be replaceable. Support for a new printer usually requires only the creation of new data files for use with one of the Microsoft-supplied printer drivers. Most of the device drivers work at kernel mode. Some of the device drivers or part of the device drivers work at user mode and kernel mode. Printer drivers work at both modes. 23 2.1 Printing Process: The printing process is divided into three groups of steps: Client processes Spooler processes Printer processes Each process performs some operations and passes the print job to another process. For e.g., user fires a print document from an application, the client process starts the creation of print job by calling the GDI, and after completing the creation of print job, it sends to the spooler. The spooler will perform some operations on that print job and sends to the printer process. The printer processes receive the print job from the spooler process and translate the print language into a bitmap, and then it prints. 2.1.1 Client Processes A user sends a print job from an application. The application calls the Graphics Device Interface (GDI). If print output is produced in RAW format, the GDI is not used. The GDI calls the printer driver for information, which the GDI uses to create a job in printer language. The GDI delivers the job to the spooler. 2.1.2 Spooler Processes The client side of the spooler (Winspool.drv) makes an RPC call to the server side spooler (Spoolsv.exe ). Spoolsv.exe calls the print router (Spoolss.dll). 24 The router (Spoolsv.dll) sends the print job to the Local Print Provider (LPP) or remote print server if the job is being sent to a network printer. The LPP polls print processors to find one that can handle the data type of the job. The LPP sends the job to the print processor, which modifies the job as required to make it print properly. The print processor sends the job to the page separator. A separator page is added, as required. The job is sent to the appropriate port print monitor. If print is bidirectional, the job is first sent to the language monitor such as the Printer Job Language (PJL) monitor, and then sent on to the port monitor. If the job is unidirectional, the job is sent directly to the port monitor. 2.1.3 Printer Processes The printer receives the print job from the print spooler. The printer translates the print language into a bitmap, which it then prints. 2.2 Print Spooler Architecture Print spooling is configured by users. Jobs can be sent to the spooler, or sent directly to the printer. If jobs are sent to the spooler, they can be configured to start printing as soon as possible or after the final page in a job has been sent to the spooler. When you send a print job directly to the printer, your computer renders the entire job and then transfers it directly to the printer. When you send a print job to a spooler, your computer creates the job, including meta- information about how the job must be 25 processed, and then sends the job to the spooler. The spooler then renders the job and sends it to the printer. Sending a print job directly to the printer is good because you remove a potential point of failure in printing documents, and all print job rendering is done on your computer, affording you more control, and you don’t have to wait for other jobs to complete, as you might if you were printing to a queue on a print server that was being used by many users. Conversely, rendering a print job on your computer consumes computing resources, so you might experience reduced performance or have to wait until the print job has completed before doing anything. Sending a print job to a spooler is good because your computer does not have to render the print job, meaning your computer’s resources are more completely and immediately available. Conversely, sending a print job to a spooler fails if the print server with the spooler is unavailable, and you might have to wait for other jobs to finish spooling before your job is processed. The primary component of the printing interface is the print spooler. The print spooler is an executable file that manages the printing process. Management of printing involves retrieving the location of the correct printer driver, loading that driver, spooling high- level function calls into a print job, scheduling the print job for printing, and so on. The spooler is loaded at system startup and continues to run until the operating system is shut down. Applications that print create a printer device context (DC). When an application creates a printer DC, the spooler performs necessary tasks such as 26 determining the location of the required printer driver and then loading the appropriate printer driver. It also determines the data type used to record the print job. The supported data types include enhanced metafiles (EMF), ASCII text, and raw data (all printer specific data types such as PostScript and PCL). Custom data types can be added to the spooler when additional printer drivers and print processors are installed. A print job is a document stored internally (by using one of the supported data types) that may contain one or more pages of output. It may consist of multiple forms; for example, a job may consist of one envelope and three pages of A4 paper. A print job is defined (or bracketed) by the StartDoc and EndDoc functions. The default data type for a print job is the enhanced metafile. An EMF record is a compact structure used to store text output commands, raster graphics commands, and so on. When an application calls StartDoc, the spooler creates a spool file and a data file and begins storing EMF records in the spool file. The spool and data files are created in an operating system directory. The spooler uses the spool file to store EMF records, and uses the data file to record the type of form, the data type for the print job, the target printer, and so on. The spooler deletes these files when the job has successfully printed. The Microsoft Windows print spooler is made up of a set of Microsoft-supplied and optional vendor-supplied components, with responsibilities that include: Determining whether a print job should be handled locally or across a network. Accepting a data stream created by GDI, in conjunction with a printer driver, for output on a particular type of printer. 27 Spooling the data to a file (if spooling is enabled). Selecting the first available physical printer in a logical printer queue. Converting a data stream from a spooled format (such as enhanced metafile (EMF)) to a format that can be sent to printer hardware (such as printer control language (PCL)). Sending a data stream to printer hardware. Maintaining a registry-based database for spooler components and printer forms. Windows print spooler support for Directory Services consists of: Publishing print queues. Maintaining three registry keys. Allowing access to spooler- maintained registry keys. Returning a print queue's publication state. 2.3 Spooler Components The primary components of the Microsoft Windows print spooler are illustrated in the following diagram. The print spooler consists of a group of components that include the print router, the local and remote print provider, the print processor, and the language and port monitors. Application: The print application creates a print job by calling GDI functions. 28 GDI: The Graphics Device Interface (GDI) includes both user-mode and kernelmode components. The user- mode component, Win32 GDI, is used by Win32 applications that require graphics support. The kernel- mode component, the graphics engine (or graphics rendering engine), exports services and functions that graphics device drivers can use. Winspool.drv : Winspool.drv is the client interface into the spooler. It exports the functions that make up the spooler's Win32 API, and provides RPC stubs for accessing the server. (GDI is the primary client, but applications also call some of its Win32 functions.) Spoolsv.exe : Spoolsv.exe is the spooler's API server. It is implemented as a Windows 2000 (or later) service that is started when the operating system is started. This module exports an RPC interface to the server side of the spooler's Win32 API. Clients of spoolsv.exe include winspool.drv (locally) and Win32spl.dll (remotely). The module implements some API functions, but most function calls are passed to a print provider by means of the router (spoolss.dll). Router: The router, spoolss.dll, determines which print provider to call, based on a printer name or handle supplied with each function call, and passes the function call to the correct provider. Print Provider: The print provider that supports the specified print device. Print Monitor: Windows XP supports two types of print monitors: language monitors, and port monitors. If printer hardware is local to the system on which the application is running, the "client" and "server" are the same system (although this is not evident in the diagram). 29 2.4 Print Providers Print providers are responsible for directing print jobs to local or remote print devices. They are also responsible for print queue management operations, such as starting, stopping, and enumerating a server's print queues. Print providers define a highlevel, machine- independent, Operating System- independent view of a print server. All print providers implement a common set of print provider capabilities. These capabilities are defined by a set of API functions, which are called by the spooler's router (spoolss.dll). 2.4.1 Print Provider Flow Paths When viewing the diagram, you should consider the following points: If the printer is managed by the client system, the print job is handled by the local print provider (localspl.dll). Printers managed by localspl.dll do not have to be physically local to the client; they can be directly connected to network cards. If the printer is located on a NT-based-operating system server, the network provider (win32spl.dll) uses RPC to redirect calls from the client's router to the server's spoolsv.exe process. Because the printer is local to the server, the server's local print provider will handle the print job. If the printer is located on some other type of server, it can be accessed by either the local print provider or by a network print provider that supports that server type, using data formats and network protocols supported by the server. For the local print provider to access a remote printer, it must contain a port monitor that can use network protocols recognized by the remote printer or server. 30 2.4.2 Print Provider Capabilities By supporting predefined sets of API functions, Windows print providers can supply the following capabilities: Print Queue Manageme nt: Adding, deleting, opening, closing, enumerating, and setting parameters for print queues. Also, providing notification of changes to a print queue's state. Printer Driver Management : Adding, deleting, enumerating, and specifying a directory for printer drivers. Print Job Creation: Starting and ending a document, starting and ending a document page, writing the job's data stream to a port, reading printer status information. Print Job Scheduling : Scheduling, enumerating, and setting parameters for a print job. Forms Management: Adding, deleting, enumerating, and setting parameters for print forms. Print Processor Management : Adding, deleting, enumerating, specifying a directory for and the data types supported by print processors. Print Monitor Management : Adding, deleting, and enumerating print monitors. Port Management: Adding, deleting, configuring, enumerating, and setting parameters for printer ports. Registry Management: Creating, deleting, and enumerating registry keys and values associated with a print provider. 31 Other Capabilities: Displaying a message box, shutting down the print provider, reading a memory mapped spool file, providing a communication path between port monitor UI DLLs and port monitor server DLLs. These capabilities are implemented as a set of functions defined by print providers. There are many functions supported to define a print provider. Functions are divided into the following groups: Initialization Functions Print Queue Management Functions Printer Driver Management Functions Print Job Creation Functions Print Job Scheduling Functions Forms Management Functions Print Processor Management Functions Print Monitor Management Functions Port Management Functions Registry Management Functions Other Functions 2.4.3 Local Print Provider The local print provider for Windows provides job control and printer management capabilities for all printers that are accessed through the local print provider's port monitors. (A client administrator sets up access to such printers by 32 selecting the Local Printer option when using the Add Printer Wizard.) Such printers include those connected to the local system's serial and parallel ports. They can also include devices connected to other I/O channels, such as SCSI ports, along with printers connected to remote non-NT-based-operating system servers. Control Flow in Local Printer Provider As the diagram shows, an application creates a print job by calling the Graphics Driver Interface (GDI). Regardless of whether the print job's initial output format is EMF, the local print provider's job creation API creates a spool file. Later, when the job is scheduled, the spool file is read and, if the format is EMF, the EMF print processor sends the job back to GDI for conversion to RAW format, with the help of a printer graphics DLL. The converted data stream can then be sent back through the local print provider to the printer (without being re-spooled). 2.5 Printer Driver Printer drivers contain information that is specific to the printer that is used. Printer drivers reside on user’s computers and are used by the GDI to render print jobs. A printer driver is a software program that understands how to communicate with printers and plotters. Printer drivers translate the information a user sends from the computer into commands that the printer understands. Various drivers must be installed on the print server to support different hardware and operating systems. For example, an administrator running Windows 2000 Server who shares a printer with clients running 33 Windows 95 and Windows 98 might want to install the appropriate drivers so the users won't be prompted to install the missing drivers. The printer driver sends the printersetting information, including the specifications needed to produce each character of the document, to the GDI. It also transmits helper services or utilities required to make the output print correctly. Printer drivers are composed of three separate files: 1. A printer graphics driver (for example, PSCRIPT.DLL, RASDD.DLL, or PLOTTER.DLL). Graphics drivers are responsible for print rendering (converting GDI commands from the graphics engine into printer commands that a printer can understand). Each graphics driver handles different printer languages. For example: o PSCRIPT.DLL: deals with the PostScript printer language. o PLOTTER.DLL: deals with the HPGL/2 language used by many plotters. o RASDD.DLL: deals with printer languages based on raster (bitmap) images, including PCL and most dot matrix printer languages. 2. A printer interface driver (for example, PSCRPTUI.DLL, RASDDUI.DLL, or PLOTUI.DLL). This dynamic- link library (DLL) includes the user interface you see when you configure a printer in Print Manager. It is called by the client side of the router (WINSPOOL.DRV). 3. Characterization files: Characterization data files provide model-specific information about print devices. 34 2.5.1 Printer Driver Components All Windows printer drivers consist of the following components: A printer graphics DLL that assists GDI in rendering a print job, and sends the rendered data stream to the print spooler. A printer interface DLL that provides both a user interface to the driver's configuration parameters, and an interface the spooler can call to notify the driver of print-related system events. 2.6 Print Processors The print processor is a dynamic- link library (DLL) which calls the printer driver. An application has tried to use a print processor which has not been installed on your computer. The spooler monitors the current print jobs and the target printer to determine an appropriate time to print a job. Once the spooler determines that a job should be printed, it calls the print processor. The print processor works together with the printer driver to move the spooled print jobs from the hard disk. Print processors are user- mode DLLs that are responsible for converting a print job's spooled data into a format that can be sent to a print monitor. They are also responsible for handling application requests to pause, resume and cancel print jobs. 35 The print job's spooled data is contained in a spool file. The print processor reads the file, performs conversion operations on the data stream, and writes the converted data to the spooler. The spooler then sends the data stream to the appropriate print monitor. Microsoft Windows 2000 and later includes the print processors listed in the following table. Print Processor Input Data Types Output Data Types EMF localspl.dll * RAW RAW TEXT sfmpsprt.dll PSCRIPT1 RAW * Beginning with Windows 2000, localmon.dll and winprint.dll are included in localspl.dll. For information about the data types, see the following topics: EMF Data Type RAW Data Type TEXT Data Type PSCRIPT1 Data Type You can create a customized print processor to support a data type that is not supported by Windows 2000 or later operating system versions. You can also provide a customized print processor that supports one or more of the supported data types, thus 36 allowing you to modify the capabilities provided by the supplied print processors. Print processors are associated with printer drivers during driver installation, so multiple print processors supporting the same data type can coexist. Difference Between EMF and RAW Data Formats? RAW is data formatted exactly how the print er needs it. Depending on the printer concerned, it could be fully rendered to a dot-by-dot page image or, on more sophisticated printers, incorporate vector elements. A PostScript printer, for example, expects a page to be described by a set of PostScript commands. This is essentially a vector format and that's what the RAW data would contain. EMF (Enhanced Metafile) describes the page in a vector format specific to Windows. EMF is actually a capture of the GDI (Graphics Device Interface) commands that programs use to tell Windows how to draw what you see on the output device, normally the screen. Because EMF is Windows' native image description language, capturing the commands into a spool file is a relatively quick and simple process. Immediately converting data to RAW format involves more processing and may produce a larger quantity of data than the equivalent EMF. Therefore, when printing from an application, EMF gets the immediate business of generating the print job over as soon as possible before returning control to the user. When the print spooler is ready to send a buffered page to the printer, RAW data can be passed straight through whereas EMF commands must first be rendered into RAW format. This is done as a background process which means you can continue working. On a well-specified PC and/or printer, the effect on overall performance of this background processing may not be noticeable. 37 That's the theory, but it doesn't always hold true. And you would think print quality should be the same in either case, but I have avoided describing a lot of behindthe-scenes complications. Odd problems can sometimes be solved by switching from EMF to RAW, or occasionally vice-versa. In fact, RAW is the manufacturer's preferred format for some printers. There isn't much you can do about the speed, but make sure the computer has enough memory to avoid excessive use of the swap file and ensure the disk is defragmented. You might also try the spool setting 'Print directly to the printer'. This is not an option when a printer is shared over a network. Your application will take longer to return control to you, but printing time may be reduced, because the job is not being spooled to disk. 2.7 Processing a Print Job When the spooler is ready to send a print job to a print processor, it calls the print processor's activities OpenPrintProcessor and returns a PrintDocumentOnPrintProcessor , function. handle. This The function spooler performs can initialization then call which is the print processor function that converts the data stream from the input format to the output format and returns the converted stream to the spooler. If the input format is NT-based-operating system EMF, the PrintDocumentOnPrintProcessor function can control the playback of the EMF records by using the functions listed in Using GDI Functions in Print Processors. These functions provide an interface between the print processor and the printer driver. This interface allows print processors to control the physical layout of printer pages, and thus 38 facilitates implementing such features as printing multiple document pages per physical page ("N - up" printing), printing pages in reverse order, and printing multiple copies of each page. A print processor's output data stream must be returned to the spooler. Typically, if the data conversion requires interaction with the printer driver's printer graphics DLL (as is the case for EMF input data), the graphics DLL returns the stream to the spooler by calling EngWritePrinter. On the other hand, if the conversion does not call the printer graphics DLL (as is the case for RAW input data), then the print processor calls WritePrinter. The PrintDocumentOnPrintProcessor function can be interrupted by asynchronous calls from the spooler to the print processor's ControlPrintProcessor function. This function implements an application's ability to pause, resume, or cancel a print job. After PrintDocumentOnPrintProcessor finishes converting the data stream and returns, the spooler calls the print processor's ClosePrintProcessor function. 2.8 Installing a Print Processor To install a print processor, an installation application must call the spooler's AddPrintProcessor function. To associate a print processor with a print queue, list its file name in an INF file in a PrintProcessor entry. This entry must be included for every print queue to which the print processor is to be associated. For more information, see Printer INF Files. When an installation application calls the spooler's AddPrinter 39 function, using a PRINTER_INFO_2 structure as an input argument, it specifies the print processor name (obtained from the INF file) as a structure member. Associating a Print Processor with a PnP-installed Print Queue If the PnP manager detects and installs a print queue on a system running either Windows 2000 or Windows XP, and if the INF file used to install the print queue contains a WinPrint, PrintProcessor entry other than the default Windows print processor, the print processor will not be associated with the print queue. However, the print processor will be installed. (Note that if you install the print queue using the Add Printer wizard, the print processor is correctly associated with the print queue. Note also that the PnP manager in Microsoft Windows Server™ 2003 and later correctly associates a print processor with the print queue.) To associate the print processor with the print queue for Plug and Play installations on Windows 2000 PRINTER_EVENT_INITIALIZE and Windows XP, case in the printer interface DLL's include a DrvPrinterEvent function. For Microsoft Windows Server™ 2003 and later, it is not necessary to add a PRINTER_EVENT_INITIALIZE case in the DrvPrinterEvent function. 2.9 Print Monitor Print monitors are responsible for directing a print data stream from the print spooler to an appropriate port driver. Two types of print monitors are defined — language monitors and port monitors. 40 2.10 Language Monitors Language monitors are user- mode DLLs that serve two purposes: They provide a full duplex communications path between the print spooler and bidirectional printers that are capable of providing software-accessible status information. They add printer control information, such as commands defined by a printer job language, to the data stream. Microsoft provides a language monitor, pjlmon.dll, which supports printer job language (PJL), and provides bidirectional communication for PJL printers. This monitor is included in the DDK as the sample language monitor. Customized language monitors can be written to support other job control languages, for unidirectional or bidirectional printers. Language monitors are optional and only associated with a particular printer type if included in the printer's INF file, as described in Installing a Print Monitor. If a language monitor is associated with a printer, the language monitor receives the printer's data stream from the print processor, modifies it, and passes it to the printer's port monitor. 41 2.11 Port Monitors Port monitors consist of user-mode DLLs. They are responsible for providing a communications path between the user- mode print spooler and the kernel- mode port drivers that access I/O port hardware. A port monitor typically uses the WriteFile, ReadFile, and DeviceIOControl CreateFile, functions, described in the Platform SDK documentation, to communicate with kernel- mode port drivers. Port monitors are also responsible for management and configuration of a server's printer ports, as described in Managing a Port. An NT-based-operating system user's view of a "printer" is really a print queue, to which one or more physical printer devices can be connected. A port is the physical connection between the print queue and a single printer device. Each port monitor supports one or more instances of one or more types of ports. For example, localmon.dll, the sample port monitor, can support all of a server's local COM and LPT ports. (The print folder assigns ports to port monitors by calling the Platform SDK documentation's AddPrinter function.) For print queues representing multiple printer devices (through multiple ports), the spooler sends each print job to the first available port. If the port monitor indicates that a specified port is busy or has encountered an error, the spooler resubmits the job to the queue, specifying another port supported by the port monitor. Besides localmon.dll, Windows 2000 and later operating system versions provide several additional port monitors. The Windows 2000 Server Resource Kit describes each 42 of these port monitors. Customized port monitors can be written to support additional types of I/O port hardware. For Windows 2000 and later, each port monitor is divided into two DLLs: Port Monitor UI DLL: A port monitor's user interface DLL contains user interface functionality and executes on print client systems. This DLL must reside in the client system's System32 subdirectory. Port Monitor Server DLL: A port monitor's server DLL contains port communications functionality and executes on print servers. It must not display a user interface. 2.12 Initializing a Print Monitor When the spooler calls immediately calls the DLL's entry point function to call LoadLibrary DllEntryPoint to load a print monitor DLL, the system function. It is generally a good idea for the DisableThreadLibraryCalls , described in the Platform SDK documentation, so the DLL is not unnecessarily notified when threads are created and deleted. Each DLL exports an initialization function, which the spooler calls after calling LoadLibrary. Language monitor DLLs and port monitor server DLLs export an InitializePrintMonitor2 InitializePrintMonitorUI function. function. Port monitor UI DLLs export an 43 These two initialization functions are responsible for returning pointers to the rest of the functions defined by print monitors, so the spooler can call them. The initialization functions can also perform load-time initialization InitializePrintMonitor2 operations. The monitor's function returns a monitor instance handle. The monitor should allocate local memory to store instance-specific information, and use the monitor handle as an identifier for the allocated memory. When the spooler is first started, it loads all of the monitor DLLs that have been installed. After calling all monitor initialization functions, the spooler calls each port monitor's EnumPorts function, which enumerates the ports supported by the monitor. (A monitor supports a port if the port has been added to the monitor's database, as described in Adding a Port.) Each suppor ted port is then opened, as described in Opening and Closing a Port. 2.13 Opening and Closing a Port After a port has been added, as described in Adding a Port, the spooler can open it by calling the appropriate language monitor's OpenPortEx function. The language monitor uses the OpenPortEx function to create and return a port handle. Typically, a language monitor calls its associated port monitor's OpenPort function, and the language monitor just returns the handle obtained from the port monitor's OpenPort. 44 If a language monitor is not associated with a port, the spooler calls the port monitor's OpenPort function directly. The spooler does not allow more than one path to a port to be enabled at one time. Thus, after it has called OpenPortEx (or OpenPort) in a particular monitor, it does not attempt to open the same port again before closing it. After a port has been opened, the spooler can call additional functions to print a job, as described in Printing a Print Job, using the port handle as an input argument. A monitor should be written so that, after a port has been opened, the spooler can send multiple print jobs before closing the port. The spooler closes a port if a job must be sent through a different language monitor, if no print queues are associated with a port, or when the system shuts down. To close a port, the spooler calls a language monitor's ClosePort function. The function invalidates the handle that was created when the port was opened. A language monitor typically calls the ClosePort function defined by its associated port monitor. If a language monitor is not associated with a port, the spooler calls the port monitor's ClosePort function directly. 2.14 Printing a Print Job After a port has been opened, as described in Opening and Closing a Port, the spooler can send print jobs to the port. 45 Each print job is delimited by spooler calls to a language or port monitor's StartDocPort and EndDocPort processor calls the spooler's functions. The spooler calls these functions when a print StartDocPrinter and EndDocPrinter functions, which are described in the Platform SDK documentation. Within the scope of a set of StartDocPort and EndDocPort WritePort, ReadPort, functions, unlimited spooler calls to a monitor's and GetPrinterDataFromPort functions can occur. Each of these functions requires the port handle returned by OpenPort) OpenPortEx (or to be specified as an input argument. Typically, a language monitor implements each of the functions by calling the like- named function in its associated port monitor. When the spooler calls a language monitor's WritePort function to send a data stream to the port, the function generally adds language-specific information, such as PJL commands, to the received data stream before passing it to the associated port monitor's WritePort The function. ReadPort function is used for obtaining status information from bidirectional printer hardware, which a language monitor might send to the spooler by calling SetPort, described in the Platform SDK documentation. The spooler does not call the ReadPort function. If printing hardware is bidirectional, both its language monitor and its port monitor should support a GetPrinterDataFromPort GetPrinterDataFromPort function. A language monitor's function should accept a registry value name as input, obtain 46 a value for that name (generally by calling associated port monitor's ReadPort WritePort and functions), and return the value to the caller. A port monitor's GetPrinterDataFromPort DeviceIoControl function should accept an I/O control code as input, call (described in the Platform SDK documentation) to pass the control code to the port driver, and return the result.