jelly-near jelly-far

Similar documents
Operating Systems. 17. Sockets. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

What is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers

Networking Subsystem in Linux. Manoj Naik IBM Almaden Research Center

Packet Header Formats

Introduction SNULL Kernel interface. Linux Device Drivers network driver

Exercise 1 INTERNET. x.x.x.254. net /24. net /24. x.x.x.33. x.x.x.254. x.x.x.52. x.x.x.254. x.x.x.254. x.x.x.

Addressing and Routing

Implementing the Wireless Token Ring Protocol As a Linux Kernel Module

Experimenting Internetworking using Linux Virtual Machines Part I

Linux IP Networking. Antonio Salueña

Communication Networks ( ) / Fall 2013 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner

IBA Software Architecture IP over IB Driver High Level Design. Draft 2

- Knowledge of basic computer architecture and organization, ECE 445

Emulation of a Space Based Internet Communication Link: Design and Implementation. Sandhya Rallapalli Gary Minden

Objectives. Chapter 10. Upon completion you will be able to:

Packet Capturing with TCPDUMP command in Linux

TCP/IP Network Essentials

CS244A Review Session

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

Lecture 8. Network Layer (cont d) Network Layer 1-1

Lab Exercise Sheet 2 (Sample Solution)

Detecting Sniffers on Your Network

FiberstoreOS IP Service Configuration Guide

A Client-Server Exchange

Networking Fundamentals

Sirindhorn International Institute of Technology Thammasat University

TCP/IP and the OSI Model

Vorlesung Kommunikationsnetze

Interconnecting Networks with TCP/IP. 2000, Cisco Systems, Inc. 8-1

Veryx ATTEST TM. Sample Test cases Overview. Conformance Test Suite. Internet Protocol version 4 (IPv4) Part Number: T / TCLS IPv /1.

Chapter 5 Network Layer

20-EECE-4029 Operating Systems Fall, 2015 John Franco

Material for the Networking lab in EITF25 & EITF45

IP Basics Unix/IP Preparation Course June 29, 2010 Pago Pago, American Samoa

Chapter 4: outline. 4.5 routing algorithms link state distance vector hierarchical routing. 4.6 routing in the Internet RIP OSPF BGP

Packet Sniffing and Spoofing

SpiNNaker Application Programming Interface (API)

The Internet Protocol. IP Addresses Address Resolution Protocol: IP datagram format and forwarding: IP fragmentation and reassembly

Lecture 3. The Network Layer (cont d) Network Layer 1-1

Adding a Second Ethernet Driver to NET+OS

History Page. Barracuda NextGen Firewall F

H

Network Security. Introduction to networks. Radboud University, The Netherlands. Autumn 2015

Internet Protocol. Outline Introduction to Internet Protocol Header and address formats ICMP Tools CS 640 1

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

Interconnecting Networks with TCP/IP

Inspection of Inter-Subnet traffic in AWS VPC using CloudGuard

Setting Up a Multihomed System

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

K2289: Using advanced tcpdump filters

lab rip experiences with RIPv2 distance vector protocol

Datagram. Source IP address. Destination IP address. Options. Data

SIMPLE ROUTER PROJECT 2

Internetworking - We are heterogeneity to our network (variable network technologies, bandwidth, MTU, latency, etc. etc.)

H

Module : ServerIron ADX Packet Capture

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

Building Ethernet Drivers on RTLinux-GPL 1

IP - The Internet Protocol. Based on the slides of Dr. Jorg Liebeherr, University of Virginia

Ethernet switch support in the Linux kernel

Network Layer: Router Architecture, IP Addressing

Network Layer. The Network Layer. Contents Connection-Oriented and Connectionless Service. Recall:

Network Layer. Recall: The network layer is responsible for the routing of packets The network layer is responsible for congestion control

CSCI-GA Operating Systems. Networking. Hubertus Franke

Chapter 10: I/O Subsystems (2)

Network Layer: Internet Protocol

Internet Tool Practice. 이지민 장동현

Our Small Quiz. Chapter 10: I/O Subsystems (2) Generic I/O functionality. The I/O subsystem. The I/O Subsystem. The I/O Subsystem

Our Small Quiz. Chapter 9: I/O Subsystems (2) Generic I/O functionality. The I/O subsystem. The I/O Subsystem.

CPSC 826 Internetworking. The Network Layer: Routing & Addressing Outline. The Network Layer

netkit lab IPv6 Neighbor Discovery (NDP)

IP : Internet Protocol

Lab Using Wireshark to Examine Ethernet Frames

An 8051 Based Web Server

CIS Test 1- Practice - Fall 2011

Sirindhorn International Institute of Technology Thammasat University

2 nd SEE 6DISS Workshop Plovdiv June Host Configuration (Windows XP) Athanassios Liakopoulos

ROUTING INTRODUCTION TO IP, IP ROUTING PROTOCOLS AND PROXY ARP

The Internet Protocol

The Linux Network Subsystem

CS 356: Computer Network Architectures. Lecture 10: IP Fragmentation, ARP, and ICMP. Xiaowei Yang

Central America Workshop - Guatemala City Guatemala 30 January - 1 February 07 Host Configuration (Linux)

Networks and Operating Systems ( ) Chapter 10: I/O Subsystems (2)

Different Layers Lecture 20

Network layer: Overview. Network layer functions IP Routing and forwarding NAT ARP IPv6 Routing

Chapter 10: I/O Subsystems (2)

ADRIAN PERRIG & TORSTEN HOEFLER ( ) 10: I/O

Transport Over IP. CSCI 690 Michael Hutt New York Institute of Technology

521262S Computer Networks 2 (fall 2007) Laboratory exercise #2: Internetworking

Network layer: Overview. Network Layer Functions

Lab Using Wireshark to Examine Ethernet Frames

2/22/2008. Outline Computer Networking Lecture 9 IP Protocol. Hop-by-Hop Packet Forwarding in the Internet. Internetworking.

CS 465 Networks. Disassembling Datagram Headers

Chapter 5: Trouble shooting of a network

internet technologies and standards

Chapter 7. ARP and RARP MGH T MGH C I 20

ET4254 Communications and Networking 1

libnetfilter_log Reference Manual

Lecture 16: Network Layer Overview, Internet Protocol

Transport Layer. The transport layer is responsible for the delivery of a message from one process to another. RSManiaol

Transcription:

sudo./run Two interfaces created: os0, os1 Two networks created: (add to /etc/networks) peanut where os0 will connect 192.168.0.0 grape where os1 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: jelly-near - 192.168.1.1 jelly-far - 192.168.1.2 (add to /etc/hosts)

butter-far peanut net eth1 franco os0 butter-near os1 jelly-near jelly-far grape net

route: 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 os0 grape * 255.255.255.0 U 0 0 0 os1 ssh butter-near: Last login: Tue Dec 4 08:12:06 2012 from jelly-near 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 os0: tcpdump: verbose output suppressed, use v or vv for full protocol decode listening on os0, 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 os0 and os1 with this: struct net_device *os0, *os1; which are allocated with this: os0=alloc_etherdev(struct sizeof(struct os_priv)); where struct os_priv { struct net_device_stats stats; struct os_packet *pkt; struct sk_buff *skb; /* Socket buffer */ struct net_device *dev; };

Device Initialization Initialization must be complete before calling register_netdev Initalization is in init_module: os0 >dev_addr[i] set MAC address octets os0 >broadcast[i] set broadcast octets os0 >netdv_ops = &os0_device_ops; os0 >header_ops = &os0_header_ops; mem_cpy(os0 >name, os0\0, 4) copies device name os0 >flags = IFF_NOARP; disable ARP priv = netdev_priv(os0); access private area priv >dev = os0; priv >pkt = kmalloc(sizeof(struct os_pkt)..); priv >pkt >dev = os0; register_netdev(os0); register device

Device Operations open: 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 Operations rebuild_header: 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.

Device Fields void *priv: Private data (see os_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 os_open: Assign the hardware address of the board: Use "\1\2\3\4\5\6" >> 01:02:03:04:05:06 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 os_release: Just stop the transmit queue

Packet Transmission int os_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 os_nqueue_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

Packet Reception int os_rx: Called on interrupt from os_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

Interrupt Handler int os_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 netif_rx(dev,pkt) level can make sense of the packet Otherwise if statusword OK and interrupt is from Xmit free the sk_buff (transmission is over)

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

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