PowerPoint Presentation


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PowerPoint Presentation

  1. 1. Networking in Linux Aditya Dev Nayar Avanish Kushal Mayank Kukreja Ravi Gupta
  2. 2. Definitions TCP/IP : The set of all the protocols used to transfer data from one computer to the other. TCP/IP stack : The function layers (stacked on top of each other) used to categorize the functions performed by the communication protocols.
  3. 3. DOD reference model
  4. 4. TCP/IP Stack <ul><li>Process of data transfer </li></ul><ul><li>Every protocol communicates with its peer </li></ul><ul><li>Headers and trailers </li></ul>
  5. 5. Structure of packet Note : Data structure for the layers are compatible for the sake of efficiency and avoid copying.
  6. 6. Network Access Layer <ul><li>Transmission of a frame(packet) </li></ul><ul><li>Details of underlying physical network </li></ul><ul><li>Adds the suitable header and trailer </li></ul>
  7. 7. Internetwork layer <ul><li>Send the data across different networks </li></ul><ul><li>Adds the suitable header and the trailer </li></ul><ul><li>No or minimal checks for errors and retransmits </li></ul>
  8. 8. Host to host transport layer <ul><li>Formation of a connection is possible </li></ul><ul><li>Checks for errors can be done </li></ul><ul><li>The delivery of the data packet can be </li></ul><ul><li>ensured </li></ul>
  9. 9. Application Layer <ul><li>Interacts with the users </li></ul><ul><li>Implements the encryption and decryption techniques for data </li></ul>
  10. 10. OSI model
  11. 11. IP protocol <ul><li>Protocol at internetwork layer </li></ul><ul><li>Define the datagram, which is the basic of transmission in the Internet. </li></ul><ul><li>Define the Internet addressing scheme </li></ul><ul><li>Move data between the Network Access Layer and the Host-to-Host Transport Layer. </li></ul><ul><li>Route datagrams to remote hosts </li></ul><ul><li>Fragment and reassemble datagrams </li></ul>
  12. 12. TCP and UDP protocols <ul><li>TCP: </li></ul><ul><li>Reliable and full-duplex connections </li></ul><ul><li>Reliable service </li></ul><ul><li>UDP: </li></ul><ul><li>Stateless transmission </li></ul><ul><li>Minimum protocol overhead </li></ul><ul><li>High speed </li></ul>
  13. 13. SOCKETS <ul><li>Definition: A socket is a software construction representing a single connection between two networking applications. </li></ul><ul><li>IP information at connection time : ip_route_connect() </li></ul><ul><li>Adv : No need to do continuous routing table look-ups </li></ul>
  14. 14.   Socket Structures <ul><li>There are two main socket structures in Linux: general BSD sockets and IP specific INET sockets </li></ul><ul><li>BSD SOCKETS </li></ul><ul><ul><ul><ul><ul><li>struct sock *sk </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>struct proto_ops *ops </li></ul></ul></ul></ul></ul><ul><ul><ul><li>INET SOCKETS </li></ul></ul></ul><ul><ul><ul><ul><ul><li>struct sk_buff_head (receive/write)_queue </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>__u32 saddr </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>struct proto *prot </li></ul></ul></ul></ul></ul>
  15. 15. Establishing Connections <ul><li>Server = gethostbyname(SERVER_NAME) </li></ul><ul><li>sockfd = socket(AF_INET,SOCK_STREAM, 0); </li></ul><ul><li>connect(sockfd, &address,sizeof(address)); </li></ul>
  16. 16.   Socket Call Walk-Through <ul><li>Check for errors in call </li></ul><ul><li>Create (allocate memory for) socket object </li></ul><ul><li>Put socket into INODE list </li></ul><ul><li>Establish pointers to protocol functions (INET) </li></ul><ul><li>Store values for socket type and protocol family </li></ul><ul><li>Set socket state to closed </li></ul><ul><li>Initialize packet queues </li></ul>
  17. 17. Connect Call Walk-Through <ul><li>Check for errors </li></ul><ul><li>Determine route to destination: </li></ul><ul><li>Store pointer to routing entry in socket </li></ul><ul><li>Call protocol specific connection function (e.g., send a TCP connection packet) </li></ul><ul><li>Set socket state to established </li></ul>
  18. 18.   Close Walk-Through <ul><li>Check for errors </li></ul><ul><li>Change the socket state to disconnecting </li></ul><ul><li>Do any protocol closing actions </li></ul><ul><li>Free memory for socket data structures (TCP/UDP and INET) </li></ul><ul><li>Remove socket from INODE list </li></ul>
  19. 19. Sending Messages
  20. 20. Receiving Message
  21. 21. Address Resolution Protocol <ul><li>Problem: Given an IP address find the MAC address </li></ul><ul><li>Solution 1. Table Lookup: </li></ul><ul><li>Searching or indexing to get MAC address. </li></ul>
  22. 22. ARP (contd.) <ul><li>2. Closed-Form Computation: Using local IEEE 802 </li></ul><ul><ul><li>addresses, e.g., Hardware Address = (IP_address & 0xFF) !40:00:00:00:00:00 </li></ul></ul><ul><li>3. Message Exchange: ARP </li></ul><ul><ul><li>The host broadcasts a request: “What is the MAC address of” </li></ul></ul><ul><ul><li>The host whose IP address is </li></ul></ul><ul><ul><li>replies back: “The MAC address for </li></ul></ul><ul><ul><li> “ is 8A-5F-3C-23-45-5616” </li></ul></ul><ul><li>All three methods are allowed in TCP/IP networks. </li></ul>
  23. 23. Message format
  24. 24. Caching <ul><li>ARP responses are cached. </li></ul><ul><li>Entry replaced when </li></ul><ul><ul><ul><li>Cache table fills up (oldest removed) </li></ul></ul></ul><ul><ul><ul><li>After some time, e.g., 20 minutes </li></ul></ul></ul><ul><li>Sender’s address binding is stored in the cache of the target </li></ul>
  25. 25. Proxy & Reverse ARP <ul><li>Proxy ARP: A router may act as a proxy for many IP addresses </li></ul><ul><li>Reverse ARP : What is the IP address of a given hardware address? </li></ul><ul><li>Used by diskless systems for their IP </li></ul><ul><li>Need RARP server to respond. </li></ul>
  26. 26. Routing <ul><li>Routing :The process of choosing a path over which to send packets. </li></ul><ul><ul><li>Routing occurs at a TCP/IP host when it sends IP packets, and occurs again at an IP router. </li></ul></ul><ul><li>Router : A device that forwards the packets from one physical network to another. </li></ul><ul><ul><li>Routers are commonly referred to as gateways . </li></ul></ul>
  27. 27. A Walk Through <ul><li>When a host attempts communication with another host, IP first determines whether the destination host is local or on a remote network </li></ul><ul><li>If the destination host is remote, IP then checks the routing table for a route to the remote host or remote network. </li></ul><ul><li>If no explicit route is found, IP uses its default gateway address to deliver the packet to a router </li></ul><ul><li>At the router, the routing table is again consulted for a path to the remote host or network. If a path is not found, the packet is sent to the router's default gateway address </li></ul>
  28. 28. The Details <ul><li>Linux maintains 3 sets of Routing Data </li></ul><ul><li>Neighbour Table – Directly connected computers. </li></ul><ul><li>FIB Table – All other networks/computers. </li></ul><ul><li>Routing Cache – Cache for FIB. </li></ul>
  29. 29. Neighbour Table
  30. 30. <ul><li>struct neigh_table : Contains common neighbour information.All computers connected by same type of connection are in same table. </li></ul><ul><li>struct neighbour : specific info about a neighbour like device which is connected to the neighbour, various flags regarding connection . </li></ul><ul><li>struct neigh_parms : contains message travel time, queue length and other statistical information. </li></ul>
  31. 31. Forwarding Information Base (FIB) <ul><li>FIB is a structure containing routing information for any valid IP address. </li></ul><ul><li>An exhaustive list of known IP destinations and their best routes. </li></ul><ul><li>Complex Data structure. </li></ul><ul><li>Slow access. </li></ul>
  32. 32. Forwarding Information Base (FIB)
  33. 33. <ul><li>Each IP subnet is represented by a fib_zone data structure </li></ul><ul><li>All of these are pointed at from the fib_zones hash table. The hash index is derived from the IP subnet mask. </li></ul><ul><li>Routes to the same subnet described by pairs of fib_node and fib_info data </li></ul>
  34. 34. Route Cache <ul><li>Keeps every route that is currently in use or has been used recently in a hash table. </li></ul><ul><li>The index into the route table is a hash function based on the least significant two bytes of the IP address. </li></ul><ul><li>If route not in cache, FIB looked up and a new entry made in route cache. </li></ul><ul><li>Routes chained in order of most frequently used first. Removed when old. </li></ul>
  35. 35. Routing Cache… conceptual organization
  36. 36. Routing Information Protocol (RIP) <ul><li>RIP : Protocol for routers to track distance to different networks and to share this information among themselves. </li></ul>
  37. 37. RIP contd.. <ul><li>At startup, information from all neighbouring routers is requested. </li></ul><ul><li>A received packet can be a 'response' or a 'request'. </li></ul><ul><li>A response is sent to all neighbours every 30 sec. </li></ul><ul><li>Listens on UDP socket 520 for incoming packets. </li></ul>
  38. 38. CSMA/CD Technology
  39. 39. Requirement <ul><li>Ethernet network provides shared access to a group of attached nodes </li></ul><ul><li>Each node has a NIC (Network Interface Card) </li></ul><ul><li>The shared cable allows any NIC to send whenever it wishes </li></ul><ul><li>But if two NICs happen to transmit at the same time, a collision will occur, resulting in the data being corrupted </li></ul>
  40. 40. <ul><li>Source NIC dispatches frame </li></ul><ul><li>Frame transmits in both directions </li></ul><ul><li>Every NIC receives the frame; do MAC address matching </li></ul><ul><li>Intended NIC picks up the frame; rest drop it </li></ul>
  41. 41. CSMA/CD Algorithm <ul><li>Sense for carrier. </li></ul><ul><li>If carrier present, wait until carrier ends. </li></ul><ul><ul><li>Sending would force a collision and waste time </li></ul></ul><ul><li>Send packet and sense for collision. </li></ul><ul><li>If no collision detected, consider packet delivered. </li></ul>
  42. 42. CSMA/CD Algorithm <ul><li>Otherwise if collision detected </li></ul><ul><li>Send Jam Signal </li></ul><ul><li>Abort immediately </li></ul><ul><li>Perform “exponential back off” and send packet again. </li></ul><ul><ul><li>Start to send at a random time picked from an interval </li></ul></ul><ul><ul><li>Length of the interval increases with every retransmission </li></ul></ul>
  43. 43. Collision Detection Time A B C
  44. 44. Collision Detection: Implications <ul><li>All nodes must be able to detect the collision. </li></ul><ul><ul><li>Any node can be sender </li></ul></ul><ul><li>The implication is that either we must have a short wires, or long packets. </li></ul><ul><ul><li>Or a combination of both </li></ul></ul><ul><li>Can calculate length/distance based on transmission rate and propagation speed. </li></ul><ul><ul><li>Minimum packet size is 64 bytes </li></ul></ul><ul><ul><ul><li>Cable length ~256 bit times </li></ul></ul></ul><ul><ul><li>Example: maximum coax cable length is 2.5 km </li></ul></ul>A B C
  45. 45. CSMA/CD: Some Details <ul><li>When a sender detects a collision, it sends a “jam signal”. </li></ul><ul><ul><li>Make sure that all nodes are aware of the collision </li></ul></ul><ul><ul><li>Length of the jam signal is 32 bit times </li></ul></ul><ul><li>Exponential backoff operates in multiples of 512 bit times. </li></ul><ul><ul><li>Longer than a roundtrip time </li></ul></ul><ul><ul><li>Guarantees that nodes that back off longer will notice the earlier retransmission before starting to send </li></ul></ul>
  46. 46. Ethernet Frame Format <ul><li>Preamble marks the beginning of the frame. </li></ul><ul><ul><li>Also provides clock synchronization </li></ul></ul><ul><li>Source and destination are 48 bit IEEE MAC addresses. </li></ul><ul><ul><li>Flat address space </li></ul></ul><ul><ul><li>Hardwired into the network interface </li></ul></ul><ul><li>Type field is a demultiplexing field. </li></ul><ul><ul><li>What network layer (layer 3) should receive this packet? </li></ul></ul><ul><ul><li>Is actually a length field in the 802.3 standard </li></ul></ul><ul><li>CRC for error checking. </li></ul>Preamble Type Pad Dest Source Data CRC 8 6 6 2 4
  47. 47. Minimum Packet Size <ul><li>Why put a minimum packet size? </li></ul><ul><li>Give a host enough time to detect collisions </li></ul><ul><li>In Ethernet, minimum packet size = 64 bytes (two 6-byte addresses, 2-byte type, 4-byte CRC, and 46 bytes of data) </li></ul><ul><li>If host has less than 46 bytes to send, the adaptor pads (adds) bytes to make it 46 bytes </li></ul>
  48. 48. Limited cable length <ul><li>Limitation: Before the transmitted packet is completely dispatched from the sender, all other nodes on the local network must at least start receiving it. This assumption is required for the “jam signal” protocol to work. </li></ul>
  49. 49. Drawbacks of CSMA/CD <ul><li>Ethernet Capture </li></ul><ul><li>A has to send bigger file than B </li></ul><ul><li>A transmits first. </li></ul><ul><li>A and B then both simultaneously try to transmit. B picks a larger retransmission interval than A and defers. </li></ul><ul><li>A sends, then sends again. </li></ul><ul><li>Both A and B attempt to resume transmission </li></ul>
  50. 50. Drawbacks of CSMA/CD <ul><li>A and B both back-off, however, since B was already in back-off (it failed to retransmit), it chooses from a larger range of back-off times (using the exponential back-off algorithm). </li></ul><ul><li>A is therefore more likely to succeed, which it does in the example. The next pause in transmission, A and B both attempt to send, however, since this fails in this case, B further increases its back-off and is now unable to fairly compete with A. </li></ul>
  51. 51. Performance of CSMA/CD <ul><li>Only one transmitter </li></ul><ul><ul><li>Near 100% utilisation of network </li></ul></ul><ul><ul><li>Possible to completely use 10Mbps </li></ul></ul><ul><li>Many transmitting NICs </li></ul><ul><ul><li>Some bandwidth wasted in collision detection </li></ul></ul><ul><ul><li>Typical busy network gives 2-4 Mbps </li></ul></ul>
  52. 52. References <ul><li>http://en.wikipedia.org </li></ul><ul><li>http://www.erg.abdn.ac.uk </li></ul><ul><li>http:// www.cisco.com </li></ul><ul><li>The linux kernel: David A Rusling </li></ul><ul><li>Linux IP Networking: Glenn Herrin </li></ul>