Network Drivers O Reilly Media-Books Pdf

Network Drivers O Reilly Media
27 May 2020 | 31 views | 0 downloads | 49 Pages | 926.16 KB

Share Pdf : Network Drivers O Reilly Media

Download and Preview : Network Drivers O Reilly Media


Report CopyRight/DMCA Form For : Network Drivers O Reilly Media



Transcription

ch17 13860 Page 498 Friday January 21 2005 11 10 AM. The network subsystem of the Linux kernel is designed to be completely protocol. independent This applies to both networking protocols Internet protocol IP versus. IPX or other protocols and hardware protocols Ethernet versus token ring etc. Interaction between a network driver and the kernel properly deals with one network. packet at a time this allows protocol issues to be hidden neatly from the driver and. the physical transmission to be hidden from the protocol. This chapter describes how the network interfaces fit in with the rest of the Linux. kernel and provides examples in the form of a memory based modularized network. interface which is called you guessed it snull To simplify the discussion the inter. face uses the Ethernet hardware protocol and transmits IP packets The knowledge. you acquire from examining snull can be readily applied to protocols other than IP. and writing a non Ethernet driver is different only in tiny details related to the actual. network protocol, This chapter doesn t talk about IP numbering schemes network protocols or other. general networking concepts Such topics are not usually of concern to the driver. writer and it s impossible to offer a satisfactory overview of networking technology. in less than a few hundred pages The interested reader is urged to refer to other. books describing networking issues, One note on terminology is called for before getting into network devices The net. working world uses the term octet to refer to a group of eight bits which is generally. the smallest unit understood by networking devices and protocols The term byte is. almost never encountered in this context In keeping with standard usage we will. use octet when talking about networking devices, The term header also merits a quick mention A header is a set of bytes err octets. prepended to a packet as it is passed through the various layers of the networking. subsystem When an application sends a block of data through a TCP socket the. networking subsystem breaks that data up into packets and puts a TCP header. describing where each packet fits within the stream at the beginning The lower lev. els then put an IP header used to route the packet to its destination in front of the. TCP header If the packet moves over an Ethernet like medium an Ethernet header. interpreted by the hardware goes in front of the rest Network drivers need not con. cern themselves with higher level headers usually but they often must be involved. in the creation of the hardware level header,How snull Is Designed. This section discusses the design concepts that led to the snull network interface. Although this information might appear to be of marginal use failing to understand. it might lead to problems when you play with the sample code. The first and most important design decision was that the sample interfaces should. remain independent of real hardware just like most of the sample code used in this. 498 Chapter 17 Network Drivers,This is the Title of the Book eMatter Edition.
Copyright 2005 O Reilly Associates Inc All rights reserved. ch17 13860 Page 499 Friday January 21 2005 11 10 AM. book This constraint led to something that resembles the loopback interface snull is. not a loopback interface however it simulates conversations with real remote hosts. in order to better demonstrate the task of writing a network driver The Linux loop. back driver is actually quite simple it can be found in drivers net loopback c. Another feature of snull is that it supports only IP traffic This is a consequence of the. internal workings of the interface snull has to look inside and interpret the packets. to properly emulate a pair of hardware interfaces Real interfaces don t depend on. the protocol being transmitted and this limitation of snull doesn t affect the frag. ments of code shown in this chapter,Assigning IP Numbers. The snull module creates two interfaces These interfaces are different from a simple. loopback in that whatever you transmit through one of the interfaces loops back to. the other one not to itself It looks like you have two external links but actually. your computer is replying to itself, Unfortunately this effect can t be accomplished through IP number assignments. alone because the kernel wouldn t send out a packet through interface A that was. directed to its own interface B Instead it would use the loopback channel without. passing through snull To be able to establish a communication through the snull. interfaces the source and destination addresses need to be modified during data. transmission In other words packets sent through one of the interfaces should be. received by the other but the receiver of the outgoing packet shouldn t be recog. nized as the local host The same applies to the source address of received packets. To achieve this kind of hidden loopback the snull interface toggles the least signif. icant bit of the third octet of both the source and destination addresses that is it. changes both the network number and the host number of class C IP numbers The. net effect is that packets sent to network A connected to sn0 the first interface. appear on the sn1 interface as packets belonging to network B. To avoid dealing with too many numbers let s assign symbolic names to the IP num. bers involved, snullnet0 is the network that is connected to the sn0 interface Similarly. snullnet1 is the network connected to sn1 The addresses of these networks. should differ only in the least significant bit of the third octet These networks. must have 24 bit netmasks, local0 is the IP address assigned to the sn0 interface it belongs to snullnet0. The address associated with sn1 is local1 local0 and local1 must differ in the. least significant bit of their third octet and in the fourth octet. remote0 is a host in snullnet0 and its fourth octet is the same as that of local1. Any packet sent to remote0 reaches local1 after its network address has been. How snull Is Designed 499,This is the Title of the Book eMatter Edition.
Copyright 2005 O Reilly Associates Inc All rights reserved. ch17 13860 Page 500 Friday January 21 2005 11 10 AM. modified by the interface code The host remote1 belongs to snullnet1 and its. fourth octet is the same as that of local0, The operation of the snull interfaces is depicted in Figure 17 1 in which the host. name associated with each interface is printed near the interface name. localhost local0,morgana local1 snullnet1,Figure 17 1 How a host sees its interfaces. Here are possible values for the network numbers Once you put these lines in etc. networks you can call your networks by name The values were chosen from the. range of numbers reserved for private use,snullnet0 192 168 0 0. snullnet1 192 168 1 0, The following are possible host numbers to put into etc hosts. 192 168 0 1 local0,192 168 0 2 remote0,192 168 1 2 local1.
192 168 1 1 remote1, The important feature of these numbers is that the host portion of local0 is the same. as that of remote1 and the host portion of local1 is the same as that of remote0 You. can use completely different numbers as long as this relationship applies. Be careful however if your computer is already connected to a network The num. bers you choose might be real Internet or intranet numbers and assigning them to. your interfaces prevents communication with the real hosts For example although. 500 Chapter 17 Network Drivers,This is the Title of the Book eMatter Edition. Copyright 2005 O Reilly Associates Inc All rights reserved. ch17 13860 Page 501 Friday January 21 2005 11 10 AM. the numbers just shown are not routable Internet numbers they could already be. used by your private network, Whatever numbers you choose you can correctly set up the interfaces for operation. by issuing the following commands,ifconfig sn0 local0. ifconfig sn1 local1, You may need to add the netmask 255 255 255 0 parameter if the address range cho.
sen is not a class C range, At this point the remote end of the interface can be reached The following screen. dump shows how a host reaches remote0 and remote1 through the snull interface. morgana ping c 2 remote0, 64 bytes from 192 168 0 99 icmp seq 0 ttl 64 time 1 6 ms. 64 bytes from 192 168 0 99 icmp seq 1 ttl 64 time 0 9 ms. 2 packets transmitted 2 packets received 0 packet loss. morgana ping c 2 remote1, 64 bytes from 192 168 1 88 icmp seq 0 ttl 64 time 1 8 ms. 64 bytes from 192 168 1 88 icmp seq 1 ttl 64 time 0 9 ms. 2 packets transmitted 2 packets received 0 packet loss. Note that you won t be able to reach any other host belonging to the two net. works because the packets are discarded by your computer after the address has. been modified and the packet has been received For example a packet aimed at. 192 168 0 32 will leave through sn0 and reappear at sn1 with a destination address of. 192 168 1 32 which is not a local address for the host computer. The Physical Transport of Packets, As far as data transport is concerned the snull interfaces belong to the Ethernet class. snull emulates Ethernet because the vast majority of existing networks at least the. segments that a workstation connects to are based on Ethernet technology be it. 10base T 100base T or Gigabit Additionally the kernel offers some generalized. support for Ethernet devices and there s no reason not to use it The advantage of. being an Ethernet device is so strong that even the plip interface the interface that. uses the printer ports declares itself as an Ethernet device. The last advantage of using the Ethernet setup for snull is that you can run tcpdump. on the interface to see the packets go by Watching the interfaces with tcpdump can. be a useful way to see how the two interfaces work. As was mentioned previously snull works only with IP packets This limitation is a. result of the fact that snull snoops in the packets and even modifies them in order for. the code to work The code modifies the source destination and checksum in the IP. header of each packet without checking whether it actually conveys IP information. How snull Is Designed 501,This is the Title of the Book eMatter Edition.
Copyright 2005 O Reilly Associates Inc All rights reserved. ch17 13860 Page 502 Friday January 21 2005 11 10 AM. This quick and dirty data modification destroys non IP packets If you want to deliver. other protocols through snull you must modify the module s source code. Connecting to the Kernel, We start looking at the structure of network drivers by dissecting the snull source. Keeping the source code for several drivers handy might help you follow the discus. sion and to see how real world Linux network drivers operate As a place to start we. suggest loopback c plip c and e100 c in order of increasing complexity All these. files live in drivers net within the kernel source tree. Device Registration, When a driver module is loaded into a running kernel it requests resources and. offers facilities there s nothing new in that And there s also nothing new in the way. resources are requested The driver should probe for its device and its hardware loca. tion I O ports and IRQ line but not register them as described in Installing an. Interrupt Handler in Chapter 10 The way a network driver is registered by its mod. ule initialization function is different from char and block drivers Since there is no. equivalent of major and minor numbers for network interfaces a network driver. does not request such a number Instead the driver inserts a data structure for each. newly detected interface into a global list of network devices. Each interface is described by a struct net device item which is defined in linux. netdevice h The snull driver keeps pointers to two of these structures for sn0 and. sn1 in a simple array,struct net device snull devs 2. The net device structure like many other kernel structures contains a kobject and. is therefore reference counted and exported via sysfs As with other such struc. tures it must be allocated dynamically The kernel function provided to perform this. allocation is alloc netdev which has the following prototype. struct net device alloc netdev int sizeof priv,const char name. void setup struct net device, Here sizeof priv is the size of the driver s private data area with network devices.
that area is allocated along with the net device structure In fact the two are allo. cated together in one large chunk of memory but driver authors should pretend that. they don t know that name is the name of this interface as is seen by user space this. name can have a printf style d in it The kernel replaces the d with the next available. interface number Finally setup is a pointer to an initialization function that is called. to set up the rest of the net device structure We get to the initialization function. 502 Chapter 17 Network Drivers,This is the Title of the Book eMatter Edition. Copyright 2005 O Reilly Associates Inc All rights reserved. ch17 13860 Page 503 Friday January 21 2005 11 10 AM. shortly but for now suffice it to say that snull allocates its two device structures in. snull devs 0 alloc netdev sizeof struct snull priv sn d. snull init, snull devs 1 alloc netdev sizeof struct snull priv sn d. snull init,if snull devs 0 NULL snull devs 1 NULL,As always we must check the return value to ensu. Network Drivers Having discussed char and block drivers we are now ready to move on to the world of networking Network interfaces are the third standard class of Linux devices and this chapter describes how they interact with the rest of the kernel The role of a network interface within the system is similar to that of a mounted block device A block device registers its disks and methods

Related Books

REFERENCE PAYS TITRE JEU BOITE NOTICE AUTRES

REFERENCE PAYS TITRE JEU BOITE NOTICE AUTRES

REFERENCE PAYS TITRE JEU BOITE NOTICE AUTRES SCED01832 PAL Ridge Racer Hi Spec Demo SCES00001 E Ridge Racer Original amp Platinum SCES00002 E Battle Arena Toshinden Original amp Platinum

SCF356 Philips

SCF356 Philips

SCF356 ENGLISH 6 ESPA OL 18 FRAN AIS CANADA 30 PORTUGU S DO BRASIL 43 6 General description Fig 1 1 Baby bottle warmer 2 Progress indicator 3 Settings and on off knob 4 Defrost setting 5 Milk warming setting 1 6 Milk warming setting 2 7 Milk warming setting 3 8 Baby food warming setting 9 On off button IMPORTANT SAFEGUARDS To fully benefit from the support that Philips offers

Models and Methods of Actuarial Mathematics

Models and Methods of Actuarial Mathematics

UNESCO EOLSS SAMPLE CHAPTERS MATHEMATICAL MODELS OF LIFE SUPPORT SYSTEMS Vol II Models and Methods of Actuarial Mathematics V I Arkin and S Ya Shorgin Encyclopedia of Life Support Systems EOLSS premiums ruin probability distribution of surplus and total amount of claims

Seven Introductory Lectures on Actuarial Mathematics

Seven Introductory Lectures on Actuarial Mathematics

s t 1 b s c s vs t 2 Summing from time t 1 for calculation of V means that we mean future payments in a strict sense such that the present payment of c t b t is not taken into account in the present value at time t This does not conform with the previously introduced V where the present value at time

Curso de Matem ticas Actuariales del INTRODUCCI N Seguro

Curso de Matem ticas Actuariales del INTRODUCCI N Seguro

correspondiente es el libro Actuarial Mathematics Bowers ACTEX Para el desarrollo del curso que compete al enfoque discreto se han preparado estas notas de clase en formato PDF con el contenido de todo lo que se ver en el semestre la finalidad de estas notas es que el alumno no anote ni tome apuntes en clase simplemente pondr atenci n a la clase y si cree conveniente anotar algo lo

Lecture Notes MTH5124 Actuarial Mathematics I

Lecture Notes MTH5124 Actuarial Mathematics I

N L Bowers H U Gerber J C Hickman D A Jones and C J Nesbitt Actuarial Mathe matics Society of Actuaries cited in these notes as BGH 97 0 6 Acknowledgements These notes have been produced by Jim Webber from notes for the predecessor module MTH6100 Actuarial Mathematics a module which covered a very similar syllabus Great credit and thanks to Dr Rosemary Harris for her

Fundamentals of Actuarial Mathematics Actuar a amp Finanzas

Fundamentals of Actuarial Mathematics Actuar a amp Finanzas

Fundamentals of Actuarial Mathematics Third Edition S David Promislow JWST504 fm JWST504 Promislow Printer YettoCome Trim 244mm 170mm October13 2014 7 17 ii JWST504 fm JWST504 Promislow Printer YettoCome Trim 244mm 170mm October13 2014 7 17 Fundamentalsof ActuarialMathematics i JWST504 fm JWST504 Promislow Printer YettoCome Trim 244mm 170mm October13 2014 7 17 ii JWST504 fm JWST504

ANNALS of Faculty Engineering Hunedoara International

ANNALS of Faculty Engineering Hunedoara International

ANNALS of Faculty Engineering Hunedoara International Journal of Engineering 83 Fascicule 2 Tome XIII 2015 Fascicule 2 May ISSN 1584 2665 print ISSN 1584 2673 online a free access multidisciplinary publication of the Faculty of Engineering Hunedoara 1 L szl KOV CS 2 Szil rd SZAB IMPROVING THE POWER CHARACTERISTICS OF AN INTERNAL COMBUSTION ENGINE WITH THE HELP OF

0 D75PAL E cover 11 06 03 18 48 Page 1 Digital Video

0 D75PAL E cover 11 06 03 18 48 Page 1 Digital Video

Instruction Manual English PAL CANON INC Canon Europa N V P O Box 2262 1180 EG Amstelveen the Netherlands Canon UK Ltd CCI Service Centre Unit 130 Centennial Park Borehamwood Hertfordshire WD6 3SE England Telephone 0870 241 2161 Canon Australia Pty Ltd 1 Thomas Holt Drive North Ryde N S W 2113 Australia Telephone 805 2000 Fax 887 4484 Canon New Zealand Ltd Akoranga Business

Canon Log Instruction Manual Canon Global

Canon Log Instruction Manual Canon Global

Canon Log Instruction Manual This manual assumes that the EOS 5D Mark IV s firmware has been upgraded for compatibility with Canon Log This manual explains only the features relevant to Canon Log For other features refer to the EOS 5D Mark IV Instruction Manual When using an HDMI cable sold separately using a cable protector is recommended E CPX E504 000 INSTRUCTION MANUAL Setting

Digital Video Camcorder Instruction Manual English

Digital Video Camcorder Instruction Manual English

Instruction Manual English PAL CANON INC Canon Europa N V P O Box 2262 1180 EG Amstelveen the Netherlands Canon UK Ltd CCI Service Centre Unit 130 Centennial Park Borehamwood Hertfordshire WD6 3SE England Telephone 0870 241 2161 Canon Australia Pty Ltd Info Line 131383 www canon com au Canon New Zealand Ltd Customer Care 09 489 0470 www canon co nz Canon Singapore Pte Ltd 1