110 likes | 145 Views
Introduction to Data Link Layer. Reading: Chapter 6. Network Layer. Network layer Protocol instances. Network devices. 2b. 802.1 Overview Architecture Management. 802.1 Locigal Link Control. 802.3 CSMA/CD. 802.5 Token Ring. 802.11 WirelessLAN. Drivers. 2a. Network adaptersr.
E N D
Introduction to Data Link Layer Reading: Chapter 6 FSU CIS 5930 Internet Protocols
Network Layer Network layer Protocol instances Network devices 2b 802.1 Overview Architecture Management 802.1 Locigal Link Control 802.3 CSMA/CD 802.5 Token Ring 802.11 WirelessLAN Drivers 2a Network adaptersr ... ... 1 IEEE 802 standard Linux network architecture Structure of Data Link Layer FSU CIS 5930 Internet Protocols
Application processes Layer 5 NET_RX_SOFTIRQ- Software-Interrupt System Calls * * Kernel activities(Interrupts, Tasklets, Timer-Handler etc.) Layer 1-4 eth1 eth0 CPU1 CPU2 Hardware-Interrupt System-calls NET_RX- Soft-IRQ NET_TX- Soft-IRQ Processes on Data Link Layer FSU CIS 5930 Internet Protocols
Path of a packet in data-link layer .. ... p8022_rcv arp_rcv ip_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 eth1 eth0 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 eth_type_trans() driver.c dev->qdisc->dequeue dev_alloc_skb() driver.c net_interrupt dev->hard_start_xmit 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 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() FSU CIS 5930 Internet Protocols
dev.c, net/sched/* dev_queue_xmit softirq.c, netdevice.h dev->qdisc->enqueue timer_handler netif_schedule Timer cpu_raise_softirq Scheduler NET_TX_SOFTIRQ qdisc_run do_softirq net_tx_action qdisc_restart dev->qdisc->dequeue driver.c dev->hard_start_xmit Transmitting a packet 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) FSU CIS 5930 Internet Protocols
packet_type 0 ptype_base[16] type: ETH_P_ARP dev: NULL arp_rcv() func data: 1 packet_type next packet_type 1 type: ETH_P_IP dev: NULL func ip_rcv() data: 1 next . . . 16 packet_type packet_type packet_type type: ETH_P_ALL ptype_all type: ETH_P_ALL dev dev func func data data next next Managing Layer-3 protocols 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) FSU CIS 5930 Internet Protocols