Introduction to Data Link Layer Reading: Chapter 6 Fall 2004 FSU CIS 5930 Internet Protocols
Structure of Data Link Layer 802.1 Overview Architecture Management 802.1 Locigal Link Control 802.3 CSMA/CD 802.5 Token Ring 802.11 WirelessLAN ... Network Layer 2b 2a 1 IEEE 802 standard Network adaptersr devices Network layer Protocol instances Linux network architecture Drivers Fall 2004 FSU CIS 5930 Internet Protocols
Processes on Data Link Layer System Calls NET_RX_SOFTIRQ- Software-Interrupt CPU1 CPU2 Layer 1-4 eth0 eth1 Layer 5 Application processes * * Kernel activities (Interrupts, Tasklets, Timer-Handler etc.) Hardware-Interrupt NET_RX- Soft-IRQ System- calls NET_TX- Fall 2004 FSU CIS 5930 Internet Protocols
Path of a packet in data-link layer .. ... arp_rcv ip_rcv p8022_rcv arp_send ip_queue_xmit Layer 3 ETH_P_802_2 dev.c br_input.c dev.c net_rx_action handle_bridge ... dev_queue_xmit CONFIG_BRIDGE dev->qdisc-> enqueue do_softirq Scheduler eth0 eth1 CPU1 CPU2 dev.c net_tx_action qdisc_run softnet_data[cpun].input_pkt_queue Data-link layer (OSI-Layer 1+2) dev.c netif_rx qdisc_restart Scheduler driver.c eth_type_trans() dev_alloc_skb() dev->qdisc->dequeue net_interrupt driver.c dev->hard_start_xmit Fall 2004 FSU CIS 5930 Internet Protocols
FSU CIS 5930 Internet Protocols Receiving a packet Adapter triggers interrupt, which is handled by the driver (e.g., net_interrupt) net_rx if receiving a packet dev_alloc_skb() into socket buffer Identifying data type in payload (e.g., eth_type_trans()) netif_rx completes interrupt handling Enqueueing the buffer (softnet_data[cpu].input_pkt_queue) Registering soft interrupt __cpu_raise_softirq(cpu, NET_RX_SOFTIRQ) CPU resumes the previous activity Fall 2004 FSU CIS 5930 Internet Protocols
Receiving packet (Cont’d) CPU finishes the current activity Schedule a new activity (schedule) Check soft interrupt queue first using do_softirq NET_RX_SOFTIRQ >net_rx_action() net_rx_action() Dequeue packet Handled by different protocol instance based on protocol’s func() Here for IP, it is ip_rcv() Fall 2004 FSU CIS 5930 Internet Protocols
Transmitting a packet Fall 2004 FSU CIS 5930 Internet Protocols dev.c, net/sched/* softirq.c, netdevice.h dev->qdisc->enqueue driver.c dev->hard_start_xmit qdisc_run qdisc_restart dev->qdisc->dequeue Scheduler net_tx_action dev_queue_xmit timer_handler netif_schedule Timer cpu_raise_softirq do_softirq NET_TX_SOFTIRQ Fall 2004 FSU CIS 5930 Internet Protocols
Transmitting packets (Cont’s) dev_queue_xmit() (net/core/dev.c) qdisc_run() (include/net/pkt_sched.h) qdisc_restart() (net/sched/sch_generic.c) Fall 2004 FSU CIS 5930 Internet Protocols
Managing Layer-3 protocols type: ETH_P_ARP dev: NULL func data: 1 packet_type next arp_rcv() ptype_base[16] 1 type: ETH_P_IP 16 ip_rcv() ptype_all type: ETH_P_ALL dev data . . . Fall 2004 FSU CIS 5930 Internet Protocols
Managing Layer-3 Protocols (Cont’d) dev_add_pack() (net/core/dev.c) dev_remove_pack() (net/core/dev.c) Fall 2004 FSU CIS 5930 Internet Protocols