Interfaces : Ethernet - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Interfaces : Ethernet

Description:

Interfaces : Ethernet 2005. 5. 23( ) icebyung_at_hufs.ac.kr – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 19
Provided by: JinP150
Category:

less

Transcript and Presenter's Notes

Title: Interfaces : Ethernet


1
Interfaces Ethernet
  • 2005. 5. 23(?)
  • ? ? ?
  • icebyung_at_hufs.ac.kr

2
Introduction
  • how the Ethernet device driver operates
  • Network device drivers are accessed through the
    seven function pointers in ifnet structure

ifnet Ethernet Description
if_init if_output if_start if_done if_ioctl if_reset if_watchdog leinit ether_output lestart leioctl lereset hardware initialization accept and queue frame for transmission begin transmission of frame output complete(unused) handle ioctl commands from a process reset the device to a known state watch the device for failures r collect statistics
3
Ethernet Interface
  • Net/3 Ethernet device drivers all follow the same
    general design
  • This is common for most Unix device drivers
  • We will refer to the LANCE driver to illustrate
    the design

4
Ethernet encapsulation of an IP packet
source address
destination address
type
data
CRC
6 bytes
2
6 bytes
46 1500 bytes
4 bytes
type 0800
IP packet
46 1500 bytes
  • Ethernet frame consist of 48-bit destination and
    source address
  • 16-bit type field identifies the format of the
    data carried by the frame
  • Type field for IP packet is 0x0800
  • Frame is terminated with a 32-bit CRC

5
Ethernet device driver
6
leintr Function
  • leintr is called when the interface generates an
    interrupt
  • call leread to transfer the frame from the
    interface to a chain of mbufs
  • mbuf chain doesnt include the Ethernet header
  • Ethernet header is passed as a separate argument
    to ether_input
  • Ethernet CRC is not generally available
  • computed and checked by the interface hardware

struct ether_header u_char ether_dhost6 u_
char ether_shost6 u_short ether_type
7
leread Function
  • leread function
  • start with a contiguous buffer of memory passed
    to by leintr
  • construct an ether_header structure
  • construct a chain of mbufs
  • use three arguments leread(unit, buf, len)
  • unit identifies the particular interface card
    that received a frame
  • buf points to the received frame
  • len the number of bytes in the frame

8
leread Function
  • constructs the ether_header by pointing et to
    the front of the buf
  • converting the ethernet value to host byte order
  • destination address is examined to determine

9
leread Function
  • If the interface is tapped by BPF,
  • the frame is passed directly to BPF
  • copies the data from the buffer passed to leread
    to an mbuf chain

10
ether_input Function
  • ether_input function
  • examines the ether_header structure to determine
    the type of data has been received
  • queues the received packet for processing
  • arguments to ether_input
  • ether_input(ifp, eh, m)
  • ifp pointer to the receiveing interfaces ifnet
    structure
  • eh pointer to the Ethernet header of the
    received packet
  • m pointer to the received packet (excluding the
    Ethernet header)

11
ether_input Function
  • broadcast and multicast recognition
  • Link-Level demultiplexing
  • determine the type of data
  • the packet is placed on the selected queue
  • if queue is full, packet is discarded

12
ether_input Function
  • Link-Level demultiplexing
  • ether_input jumps according to the Ethernet type
    field
  • For an IP packet,schednetisr schedules an IP
    software interrupt and the IP input queue,
    ipintrq, is selected
  • For an ARP packet,the ARP software interrupt is
    scheduled and arpintrq is selected
  • The default case processes unrecognized Ethernet
    types or packets that are encapsulated according
    to the 802.3 standard

13
ether_output Function
  • ether_output function
  • if_output function for all Ethernet is
    ether_output
  • ether_output takes the data portion of an
    Ethernet frame and places it on the interfaces
    send queue
  • describe in four parts
  • verification
  • protocol-specific processing
  • frame construction
  • interface queueing
  • arguments to ether_output
  • ether_output(ifp, m0, dst, rt0)
  • ifp points to the outgoing interfaces ifnet
    structure
  • m0 the packet to send
  • dst the destination address of the packet
  • rt0 routing information

14
ether_output Function
  • Host route
  • Gateway route
  • discard packets when the destination is not
    responding to ARP request

15
ether_output Function
  • ether_output jumps according to sa_family in the
    destination address
  • check the ARP cache to determine the Ethernet
    Addr corresponding IP Addr

/ OSI Code/
  • It isnt necessary to call arpresolve
  • Ethernet destination address has been provided
  • explicilty by the caller
  • unrecognized address families

16
ether_output Function
  • At this point, the mbuf contains a complete
    Ethernet frame except for 32-bit CRC
  • If output queue is full ether_output discards the
    frame

17
lestart Function
  • lestart function dequeues frames from the
    interface output queue
  • Arranges for them to be transmitted by the LANCE
    Ethernet card
  • Interface must be initialized
  • Dequeue frame from output queue
  • Repeat if device is ready for more frames

18
lestart Function
  • If the interface is not initialized.
  • lestart returns immediately

/ device-specific code /
/ device-specific code /
/ device-specific code /
Write a Comment
User Comments (0)
About PowerShow.com