sudo ./snull_load Two interfaces created: sn0, sn1

Slides:



Advertisements
Similar presentations
Device Layer and Device Drivers
Advertisements

Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
CPSC Network Layer4-1 IP addresses: how to get one? Q: How does a host get IP address? r hard-coded by system admin in a file m Windows: control-panel->network->configuration-
The Journey of a Packet Through the Linux Network Stack
CS 457 – Lecture 16 Global Internet - BGP Spring 2012.
Internet Control Protocols Savera Tanwir. Internet Control Protocols ICMP ARP RARP DHCP.
Recitation 6 Midterm 1’s solution Project 2 IP Forwarding CIDR.
Week 5: Internet Protocol Continue to discuss Ethernet and ARP –MTU –Ethernet and ARP packet format IP: Internet Protocol –Datagram format –IPv4 addressing.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 TCP/IP Stack Introduction: Looking Under the Hood! Shiv Kalyanaraman Rensselaer Polytechnic Institute.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Network Devices COMS W6998 Spring 2010 Erich Nahum.
Chapter 5 The Network Layer.
Chapter 14 TCP/IP and Routing Part #1 Unix System Administration.
Cache Table. ARP Modules Output Module Sleep until IP packet is received from IP Software Check cache table for entry corresponding to the destination.
IXP2400 Protocol Offloading Yan Luo Chris Baron
Network Management And Debugging
1 Application Presentation Session Transport Network Datalink Physical OSI model Application IPv4, IPv6 Device Driver Hardware TCPUDP Internet.
1 IP Forwarding Relates to Lab 3. Covers the principles of end-to-end datagram delivery in IP networks.
Cisco Public © 2013 Cisco and/or its affiliates. All rights reserved. 1.
Linux Networking Commands
IST 228\Ch3\IP Addressing1 TCP/IP and DoD Model (TCP/IP Model)
Connecting Networks © 2004 Cisco Systems, Inc. All rights reserved. Defining the IP Packet Delivery Process INTRO v2.0—4-1.
Network Layer4-1 NAT: Network Address Translation local network (e.g., home network) /24 rest of.
ICMP (Internet Control Message Protocol) Computer Networks By: Saeedeh Zahmatkesh spring.
1 ECE453 – Introduction to Computer Networks Lecture 12 – Network Layer (IV)
ICMP : Internet Control Message Protocol. Introduction ICMP is often considered part of the IP layer. It communicates error messages and other conditions.
PA3: Router Junxian (Jim) Huang EECS 489 W11 /
1 IP Forwarding Relates to Lab 3. Covers the principles of end-to-end datagram delivery in IP networks.
Tools for Web Applications. Overview of TCP/IP Link Layer Network Layer Transport Layer Application Layer.
Fall 2004FSU CIS 5930 Internet Protocols1 Network Devices Reading: Chapter 5.
LWIP TCP/IP Stack 김백규.
IP Forwarding.
1 IP: putting it all together Part 1 G53ACC Chris Greenhalgh.
CMPT 471 Networking II Address Resolution IPv4 ARP RARP 1© Janice Regan, 2012.
CS 453 Computer Networks Lecture 21 Layer 3 Network Layer Network Layer of the Internet.
CDPA 網管訓練 駭客任務 2 Ethernet Switching ARP, IP, LAN, Subnet IP Header, Routing ICMP
Chapter 6-2 the TCP/IP Layers. The four layers of the TCP/IP model are listed in Table 6-2. The layers are The four layers of the TCP/IP model are listed.
Hyung-Min Lee ©Networking Lab., 2001 Chapter 8 ARP and RARP.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
1 Network Administration Module 3 ARP/RARP. 2 Address Resolution The problem Physical networks use physical addresses, not IP addresses Need the physical.
An initial study on Multi Path Routing Over Multiple Devices in Linux 2.4.x kernel Towards CS522 term project By Syama Sundar Kosuri.
Chapter 7 ARP and RARP.
IP network tools & troubleshooting AFCHIX 2010 Nairobi, Kenya October 2010.
1 Kyung Hee University Chapter 8 ARP(Address Resolution Protocol)
1 Requirements for Internet Routers (Gateways) and Hosts Relates to Lab 3. (Supplement) Covers the compliance requirements of Internet routers and hosts.
Linux Operations and Administration Chapter Eight Network Communications.
Review of IPv4 Routing Veena S, MCA Dept, PESIT Mar 09-10, 2013.
Fall 2004FSU CIS 5930 Internet Protocols1 Address Resolution Protocol (ARP) Reading: Chapter 15.
LonWorks Introduction Hwayoung Chae.
Chapter 4: server services. The Complete Guide to Linux System Administration2 Objectives Configure network interfaces using command- line and graphical.
Watching and Manipulating Your Network Traffic. tcpdump - your binoculars $ sudo tcpdump tcpdump: verbose output suppressed, use -v or -vv for full protocol.
Behrouz A. Forouzan TCP/IP Protocol Suite, 3rd Ed.
Chapter 9: Transport Layer
Instructor Materials Chapter 9: Transport Layer
Zero-copy Receive Path in Virtio
Building an Internet Router
Chapter 8 ARP(Address Resolution Protocol)
IP Forwarding Covers the principles of end-to-end datagram delivery in IP networks.
TCP/IP Transmission Control Protocol / Internet Protocol
Reference Router on NetFPGA 1G
IP network tools & troubleshooting
Net 323: NETWORK Protocols
IP Forwarding Relates to Lab 3.
TCP/IP Networking An Example
IP Forwarding Relates to Lab 3.
IP Forwarding Relates to Lab 3.
Chapter 7 ARP and RARP Prof. Choong Seon HONG.
Networking and Network Protocols (Part2)
IP Forwarding Relates to Lab 3.
Reference Router on NetFPGA 1G
Presentation transcript:

sudo ./snull_load Two interfaces created: sn0, sn1 Two networks created: (add to /etc/networks) peanut where sn0 will connect – 192.168.0.0 grape where sn1 will connect – 192.168.1.0 Two IP addresses in peanut: (add to /etc/hosts) butter-near - 192.168.0.1 butter-far - 192.168.0.2 Two IP addresses in grape: (add to /etc/hosts) jelly-near - 192.168.1.1 jelly-far - 192.168.1.2

butter-far peanut net sn0 butter-near sn1 jelly-near eth1 franco jelly-far grape net

route: ssh butter-far: ping jelly-near: sudo tcpdump -i sn0: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.52.240.1 0.0.0.0 UG 0 0 0 eth1 10.52.240.0 * 255.255.240.0 U 0 0 0 eth1 peanut * 255.255.255.0 U 0 0 0 sn0 grape * 255.255.255.0 U 0 0 0 sn1 ssh butter-far: Last login: Tue Dec 4 08:12:06 2012 from jelly-far You have no mail. -------------------------------------------------------------------------- 08:35:31 up 2:54, 8 users, load average: 0.39, 0.37, 0.30 [franco@franco ~]$ ping jelly-near: PING jelly-near (192.168.1.2) 56(84) bytes of data. 64 bytes from jelly-near (192.168.1.2): icmp_req=1 ttl=64 time=0.046 ms 64 bytes from jelly-near (192.168.1.2): icmp_req=2 ttl=64 time=0.051 ms sudo tcpdump -i sn0: tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on sn0, link-type EN10MB (Ethernet), capture size 65535 bytes 08:40:08.847331 IP butter-far > butter-near: ICMP echo request, id 10511, seq 1, length 64 08:40:08.847365 IP butter-near > butter-far: ICMP echo reply, id 10511, seq 1, length 64

Device Registration No major/minor numbers with network drivers Instead, driver adds a data structure for each detected interface into a global list of network devices Interfaces are described in: struct net_device (in linux/netdevice.h) Keep track of sn0 and sn1 with this: struct net_device *snull_devs[2]; which are allocated with this: snull_devs[0] = alloc_netdev(sz, “sn0”, init) where sz is the size of the driver's private data area and init is a function that initializes the net_device structure Registration of the devices happens with this: result = register_netdev(snull_devs[0])

Device Initialization Initialization must be complete before calling register_netdev Initalization is by snull_init uses ether_dev() to set some fields registers net_device_ops (open, release, etc.) registers header_ops (create, rebuild) sets flags (e.g. do not use ARP) private data is in: struct snull_priv (see snull.c) private data allocated and initialized with this: priv = netdev_priv(dev); memset(priv, 0, sizeof(struct snull_priv)); spin_lock_init(&priv->lock); snull_rx_ints(dev, 1); /* enable rcv interrupts */

Device Methods open: stop: hard_start_xmit: hard_header: Opens the interface when ifconfig activates it Registers system resource it needs (I/O ports, IRQ, DMA, etc.) Turns on the hardware Performs any other setup the device requires stop: Stops the interface when it is brought down Should reverse operations performed in open hard_start_xmit: transmission of packet contained in socket buffer (sk_buff) hard_header: builds the hardware header from src and dest hrdw addresses previously retrieved organizes info passed to it into device-specific hrdw header

Hardware Header

Device Methods rebuild_header: get_stats: set_mac_address: do_ioctl: Rebuilds hardware header after ARP resolution completes but before a packet is transmitted get_stats: Exec when ifconfig or netstat -i is run set_mac_address: Can be implemented if interface supports it do_ioctl: Performs interface-specific ioctl commands The corresponding field in struct net_device can be left as NULL if the interface doesn’t need any interface-specific commands.

unsigned long last_rx: int watchdog_timeo: Int xmit_lock_owner: Device Fields void *priv: Private data (see snull_priv) unsigned long last_rx: Time since last receive int watchdog_timeo: minimum time elapsed before deciding on a timeout Int xmit_lock_owner: Used to avoid multiple simultaneous calls to the driver’s hard_start_xmit function Is the number of the CPU that has obtained xmit_lock

Open Device snull_open: Assign the hardware address of the board: Use "\0SNUL\0" >> 00:53:4E:55:4C:00 the first byte of multicast addrs is odd so this is even. Start the interface's transmit queue allowing it to accept packets for transmission once it is ready to start sending data.

Close Device snull_release: Just stop the transmit queue

and is complete including transmission headers Packet Transmission int snull_tx: Call hard_start_xmit to put data in an outgoing queue Each packet is in a socket buffer structure (struct sk_buff) and is complete including transmission headers Actual transmission is hardware dependent Code for this is in snull_hw_tx packet is manipulated and finally enqueued with snull_enqueue_buf(dest, tx_buffer); which links the packet (tx_buffer) into the queue Scatter/Gather I/O: Packet data & headers may be copied from user space This may mean a lot of data copying May avoid this with scatter/gather I/O – send the pieces As one chunk

send to receive level with netif_rx packet data is copied with Packet Reception int snull_rx: Called on interrupt from snull_interrupt Allocate an sk_buff, fill with packet, write metadata, send to receive level with netif_rx packet data is copied with memcpy(skb_put(skb,pkt->len),pkt->data,pkt->len); The dev, protocol fields must be filled so network level can make sense of the packet Scatter/Gather I/O: Packet data & headers may be copied from user space This may mean a lot of data copying May avoid this with scatter/gather I/O – send the pieces As one chunk

int snull_regular_interrupt: Interrupt Handler int snull_regular_interrupt: Retrieve priv from netdev_priv(dev) Get statusword from priv If statusword is OK and interrupt is from receiver get packet from priv->rx_queue Dequeue packet with priv->rx_queue = pkt->next Send packet to network level with snull_rx(dev,pkt) level can make sense of the packet Otheriwise if statusword OK and interrupt is from Xmit free the sk_buff (transmission is over)

unsigned char *head, *tail, *end, *data: unsigned char ip_summed: Socket Buffer Fields struct net_device: The device sending or receiving data union {} h, nh, mac: Pointers to levels of headers contained within the packet h hosts pointers to transport layers nh includes network layer headers mac collects pointers to link-layer headers src and dest addresses are in skb->h.th unsigned char *head, *tail, *end, *data: Pointers to space in the packets unsigned char ip_summed: Checksum policy

struct sk_buf *alloc_skb(len, priority): void dev_kfree_skb(skb): Socket Buffer Functions struct sk_buf *alloc_skb(len, priority): Allocate the buffer void dev_kfree_skb(skb): Free a buffer unsigned char *skb_put(skb, len): Update the tail and len fields of the sk_buff structure Drivers use the return value to copy data with memcpy() unsigned char *skb_push: Decrement skb->data and increment skb->len Used to add a hardware header before transmitting a packet unsigned char *skb_pull: Removes data from the head of the packet