1 / 49

CS518 Packet Handling in Linux --Gaurav Dawra

CS518 Packet Handling in Linux --Gaurav Dawra. 0. 0. Overview. Internetworking: Past and Present Overview TCP/IP and OSI Model Sockets Overview Internetworking: Past and Present Overview IP solutions: Routing Packet Forwarding Routing Vs Forwarding Address resolution Protocol (ARP)

orly
Download Presentation

CS518 Packet Handling in Linux --Gaurav Dawra

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS518 Packet Handling in Linux--Gaurav Dawra 0

  2. 0 Overview • Internetworking: Past and Present Overview • TCP/IP and OSI Model • Sockets Overview • Internetworking: Past and Present Overview • IP solutions: • Routing • Packet Forwarding • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking : Brief Overview

  3. The Problem 0 • Before Internet: different packet-switching networks (e.g., ARPANET) • only nodes on the same network could communicate * source: RPI Institute , internet protocol

  4. The Internetworking Problem 0 • Two nodes communicating across a “network of networks”… • How to sendpackets through this strange medium ? A B Medium Medium * source: RPI Institute , internet protocol

  5. Solution 0 Network Layer Routers * source: RPI Institute , internet protocol

  6. The IP Solution … 0 • IP layer routers & global addresses –right!! IP IP IP IP * source: RPI Institute , internet protocol

  7. HTTP Packet radio Before IP 0 (FTP – File Transfer Protocol, NFS – Network File Transfer, HTTP – World Wide Web protocol) • No network level abstraction: each new application has to be re-implemented for every new network technology! FTP NFS Telnet Application Coaxial cable Fiber optic Transmission Media * source: RPI Institute , internet protocol

  8. HTTP Packet radio IP 0 • Key ideas: • Abstraction: better than anyany translation. Fewer, simpler mappings. • Network-layer: efficient implementation, global addressing FTP NFS Telnet Application Intermediate Layer (IP) Coaxial cable Fiber optic Transmission Media * source: RPI Institute , internet protocol

  9. Where are we? 0 • Internetworking: Past and Present Overview • TCP/IP and OSI Model • Sockets Overview • Internetworking: Past and Present Overview • IP solutions: • Routing • Packet Forwarding • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking : Brief Overview

  10. 0 TCP/IP (Transport Layer) Functions of Transport Layer -- Establishing End to End Connections -- Ensuring Data Reliability -- Providing Flow Control

  11. TCP/IP (Network Layer) 0 Internet layer -- Send packets from a network node and have them arrive at the destination node independent of the path taken.

  12. Application Layer Application Layer HTTP FTP Transport Layer Transport Layer TCP UDP Internet Layer Internet Layer IP ICMP IGMP ARP Network Interface Layer Network Interface Layer ATM Ethernet TCP/IP Layer 0

  13. Application Layer Presentation Layer Session Layer Transport Layer Network Layer Data Link Layer Physical Layer OSI Model 0

  14. Comparing the OSI Model and TCP/IP Model 0

  15. Where are we? 0 • Internetworking: Past and Present Overview • TCP/IP and OSI Model • Sockets Overview • IP solutions: • Routing • Packet Forwarding • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking: Brief Overview

  16. Overall Picture (One View) 0 ROUTING

  17. Where are we Now? 0 • Internetworking: Past and Present Overview • TCP/IP and OSI Model • IP addressing • Sockets Overview • IP solutions: • IP Packet Forwarding • Routing • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking : Brief Overview

  18. Router Bridge/Switch Repeater/Hub TCP/IP Model 0 Application Application Transport Transport Network Network Datalink Datalink Broadcast Domain

  19. Routing vs. Forwarding 0 • Forwarding: select an output port based on destination address and routing table • Routing: process by which routing table is built.. • … so that the series of local forwarding decisions takes the packet to the destination with very high probability • … the path chosen/allotted to the packet is efficient in some sense… Filtering of packets

  20. IP Forwarding 0 Direct Connectivity Indirect Connectivity --Not on the Same Network -- Same Network * source: RPI Institute , internet protocol

  21. IP Forwarding(direct connectivity) 0 • Source & Destination in same network (direct connectivity) • Recognize that destination IP address is on same network. • Find the destination LAN address. • Send IP packet encapsulated in LAN frame directly to the destination LAN address • IP in MAC/LAN FRAME: Encapsulation => source/destination IP addresses don’t change

  22. IP Forwarding (indirect connectivity) 0 • B) Source & Destination in different networks (indirect connectivity) • Recognize that destination IP address is NOT on same network. • Look updestination IP address in a (forwarding) table to find a match, called the next hop router IP address. • Send packet encapsulated in a LAN frame to the LAN address corresponding to the IP address of the next-hop router.

  23. Forwarding Table 0 Command:‘route’ • Kernel IP routing table • Destination Gateway Genmask Flags Metric Ref Use Iface • 153.90.192.0 * 255.255.248.0 U 0 0 0 eth0 • 5.0.0.0 * 255.0.0.0 U 0 0 0 srcr • 6.0.0.0 * 255.0.0.0 U 0 0 0 wlan0 • 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0 • 127.0.0.0 * 255.0.0.0 U 0 0 0 lo • default epgwy192.msu.mo 0.0.0.0 UG 0 0 0 eth0

  24. Addressing 0 • [1] How to find if destination is in the same network ? • IP address = network ID + host ID. -- If the Source and Destination ID’s Match (Same Network) --If not, We need Router Network Host Boundary 192.168.0.10 Netmask255.255.255.0 10.1.2.1 Netmask 255.0.0.0

  25. Address Resolution 0 • How to find the LAN address corresponding to an IP address ? • Address Resolution Problem. • Solution: ARP, RARP (I will come back to this)

  26. IP datagram: 223.1.1.1 223.1.2.1 E A B 223.1.1.2 source IP addr 223.1.2.9 misc fields dest IP addr 223.1.1.4 data 223.1.2.2 223.1.3.27 223.1.1.3 223.1.3.2 223.1.3.1 Dest. Net. next router Nhops 223.1.1 1 223.1.2 223.1.1.4 2 223.1.3 223.1.1.4 2 IP Forwarding: Example Scenario 0 routing table in A datagram remains unchanged, as it travels source to destination addr fields of interest here * source: RPI Institute , internet protocol

  27. 223.1.1.1 223.1.2.1 B E A 223.1.1.2 223.1.2.9 223.1.1.4 223.1.2.2 223.1.3.27 223.1.1.3 223.1.3.2 223.1.3.1 Dest. Net. next router Nhops 223.1.1 1 223.1.2 223.1.1.4 2 223.1.3 223.1.1.4 2 IP Forwarding (Direct) 0 misc fields data 223.1.1.1 223.1.1.3 • Starting at A, given IP datagram addressed to B: • look up net. address of B • find B is on same net. as A • link layer will send datagram directly to B inside link-layer frame • B and A are directly connected * source: RPI Institute , internet protocol

  28. 223.1.1.1 223.1.2.1 B E A 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.3.27 223.1.1.3 223.1.3.2 223.1.3.1 Dest. Net. next router Nhops 223.1.1 1 223.1.2 223.1.1.4 2 223.1.3 223.1.1.4 2 IP Forwarding (Indirect): Step 1 0 misc fields data 223.1.1.1 223.1.2.2 • Starting at A, dest. E: • look up network address of E • E on different network • A, E not directly attached • routing table: next hop router to E is 223.1.1.4 • link layer sends datagram to router 223.1.1.4 inside link-layer frame • datagram arrives at 223.1.1.4 • continued….. * source: RPI Institute , internet protocol

  29. Host, router network layer functions: • ICMP protocol • error reporting • router “signaling” • IP protocol • addressing conventions • datagram format • packet handling conventions routing table The Internet Network layer 0 Transport layer: TCP, UDP Network layer Link layer physical layer * source: RPI Institute , internet protocol

  30. Peek into source Code(Sending Out) 0

  31. Peek into source Codeipv4/net/ip_output.c 0 ip_finish_output() ip_finish_output2() Call hh or dst output routine ip_output() Checks for NAT Network Address Translation Drop On Wire --Builds and Send -- Checks the route -- IP Checksum -- IP Header IP_LOCAL_OUT

  32. Peek into source Code: ( Packet Receiving: ip_input.c) 0 TCP IP ROUTING Checks for Protocol

  33. Peek into source Code: ( Packet Receiving: ip_input.c) 0 Bingo!!Drop On Wire Input Queue DROP Other Host ip_forward() ip_forward.c -- Check TTL -- Flag Check ip_rcv() ARP IP header Check Sum IP_PREROUTING Local delivery Bingo!! Its mine icmp.c (Error) ip_rcv_finish () : ipv4/ip_input.c -- Calls ip_route_input() to route -- Calls ip_forward()

  34. Where are we? 0 • Internetworking: Past and Present Overview • TCP/IP and OSI Model • IP addressing • Sockets Overview • Internetworking: Past and Present Overview • IP solutions: • IP Packet Forwarding • Routing • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking: Brief Overview

  35. Question: Why ARP? 0 • Do Binding: --Association between a IP address and a hardware address (one for every device) is called a binding.

  36. ARP Techniques 0 Table Lookup Dynamic Binding :ARP Pictorial View of ARP * source: RPI Institute , internet protocol

  37. ARP techniques (cont.) 0 • 1: Table Lookup:Searching or indexing to get MAC addresses • Similar to lookup in /etc/hosts for names • Problem: change Ethernet card => change table IP Address MAC Address 192.168.0.1 0A:4B:00:00:07:08 192.168.0.2 0B:4B:00:00:07:00 192.168.0.3 0A:5B:00:01:01:03

  38. ARP techniques (Continued) 0 • 2.Dynamic Binding: ARP • The host broadcasts a request: “What is the MAC address of 127.123.115.08?” • The host whose IP address is 127.123.115.08 replies back: “The MAC address for 127.123.115.08 is 8A-5F-3C-23-45-5616” • ARP responses cached; LRU + Entry Timeout • These two methods are allowed in TCP/IP networks.

  39. Source code 0 Queue arp_send(): arp.c -- Check Device Supports ARP -- Allocate Buffer -- fills Header/ARP Information -- calls dev_queue_xmit() to send ARP

  40. How Does all of this Fit together? 0 Physical Medium Input Queue ip_finish_output() ip_rcv() ARP ip_forward() IP_PREROUTING ip_output() ip_rcv_finish () IP_LOCAL_OUT icmp.c (Error) Local Delivery Build IP Packet Local IP Services

  41. 0 Where are we? • Internetworking: Past and Present Overview • TCP/IP and OSI Model • IP addressing • Sockets Overview • Internetworking: Past and Present Overview • IP solutions: • Routing • Packet Forwarding • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking: Brief Overview

  42. Wireless Networks 0 -- The use of infra-red or radio frequency signals to share information and resources between devices Wireless State of Art • IEEE 802.16a • WiMaX • 30 Mbps • 30 Miles • IEEE 802.11b • (wi-fi) • 2.4GHz • 11mbps • IEEE 802.11g • 2.4GHz • 54mbps • Compatible with • 802.11b • IEEE 802.11a • 5GHz • 54mbps

  43. Types of WLAN(Wireless LAN) 0 Infrastructure mode * Source British Educational Communications and technology agency

  44. Ad-hoc Mode 0 Each NODE is HOST and ROUTER We Set up a FIVE NODE Multi Hop Ad-Hoc Network Wireless Card is configured using -- HostAP driver and pcmcia-cs package Linux 2.4.20 HOST, ROUTER, NAT DHCP Server.

  45. What is ‘Software Router’--Each Node in our Network is: 0 • -- A Router in a Computer (Our Case : Linux 2.4.20 and 2.4.26 Machines ) • -- Program that receives, processes and forwards packets to the next node • -- We are using CLICK MODULAR ROUTER • (developed at MIT) • -- Features of Click: • High level programming interface to the developer • Hides Kernel Complexities • Easily installed and configured • Provide flexibility to writes own Elements and eventually Combines these elements to write any Ad Hoc Routing Protocol

  46. Pictorial View of Each Click Router Node 0 5.0.0.0 srcr Interface 6.0.0.0 wlan0 Interface Private LAN attached to HOST Eth0 Interface: 192.168.0.1 153.90.196.95

  47. Click.config File Example 0 FromDevice(eth0) -> Print -> ToDevice(wlan0); 1. FromDevice(eth0): Get a packet from eth0 interface 2. Print: Print the packet ( can see using ‘dmesg’) 3. ToDevice(wlan0): Send the packet to eth1 interface ========================================= Start CLICK by loading Click.config file to /click/config Command: dawra@roofnet$insmodclick.o(Kernel Side Module made for Click) dawra@roofnet$ cp click.config /click/config Check out: http://www.pdos.lcs.mit.edu/click Demonstration

  48. 0 Summary • Internetworking: Past and Present Overview • TCP/IP and OSI Model • Sockets Overview • Internetworking: Past and Present Overview • IP solutions: • Routing • Packet Forwarding • Routing Vs Forwarding • Address resolution Protocol (ARP) • Wireless Networking : An Overview

  49. What are the Resources? • MIT Click Modular Router : http://www.pdos.lcs.mit.edu/click • Roofnet MIT testbed: http://www.pdos.lcs.mit.edu/roofnet/design • Computer Networking: Andrew S. Tanenbaum • Internet Protocols Coursework : RPI institute • Linux Source Code : http://lxr.linux.no/source/ • Linux Networking Documentation : http://www.kernelnewbies.org/ • Linux Documentation Project : http://www.tldp.org/ • Linux Kernel : www.kernel.org

More Related