Successfully reported this slideshow.



Published on

Published in: Technology
  • Be the first to comment


  1. 1. TCP/IP Basics Happyman 2008/6/24
  2. 2. Theory first
  3. 3. Communications Architecture <ul><li>Communications functions can be divided into subset activities </li></ul><ul><ul><ul><li>concept of layered communications </li></ul></ul></ul><ul><li>Each activity can be looked as a layer </li></ul><ul><ul><li>A layer provides a specific service (function) to other layers </li></ul></ul><ul><ul><li>A layer has a specific protocol (control messages) to connect to other systems </li></ul></ul><ul><li>Two standards: </li></ul><ul><ul><li>IBM’s proprietary SNA </li></ul></ul><ul><ul><li>ISO’s Reference Model for Open Systems Interconnection (OSI model) </li></ul></ul>
  4. 4. The OSI Model Lower Layer connects one node to another Upper Layer directly assist the user 7 Application 6 Presentation 5 Session 4 Transport 3 Network 2 Data Link 1 Physical Layer Function Network Choosing the next node and the link to it Data Link Controls the flow of messages on the chosen link Physical Connecting to the physical medium that provides the link Layer Function Application Provides services directly to an application program Presentation Presentation of information to user in a format that the user will understand Session Controls the user to user dialogue – its direction and synchronization Transport Raises the quality of service provided by the network to the level required by user
  5. 5. The OSI model <ul><li>OSI Protocol Stack </li></ul><ul><li>7. Application -- End user services such as email. </li></ul><ul><li>6. Presentation -- Data problems and data compression </li></ul><ul><li>5. Session -- Authenication and authorization </li></ul><ul><li>4. Transport -- Gaurentee end-to-end delivery of packets </li></ul><ul><li>3. Network -- Packet routing </li></ul><ul><li>2. Data Link -- Transmit and receive packets </li></ul><ul><li>1. Physical -- The cable or physical connection itself. </li></ul>
  6. 7. Network Protocol Operations
  7. 8. TCP/IP and OSI <ul><li>In OSI reference model terminology – the TCP/IP protocol suite covers the network and transport layer </li></ul><ul><li>TCP/IP can be used on many data-link layers (can support many network hardware implementations) </li></ul>
  8. 9. But First…
  9. 10. Ethernet – A Real Data-Link Layer <ul><li>Discuss a real data-link layer. </li></ul><ul><li>Ethernet (IEEE 802.3) is widely used. </li></ul><ul><li>Supported by variety of physical layer implementations. </li></ul>
  10. 11. CSMA/CD Carrier Sense Multiple Access with Collision Detection <ul><li>Carrier Sense: can tell when another host is transmission </li></ul><ul><li>Collision Detection: cal tell when another host is transmission at the same time </li></ul>
  11. 12. An Ethernet Frame <ul><li>Preamble: a sequence of alternating 1s and 0s used for synchronization. </li></ul><ul><li>CRC: Cyclic Redundancy Check </li></ul>
  12. 13. Ethernet Addressing <ul><li>Each interface looks at every frame and inspects the destination address. If the address does not match the hardware address of the interface (or the broadcast address), the frame is discarded. </li></ul><ul><li>Some interface can also be programmed to recognize multicast address. </li></ul><ul><li>Hardware address or MAC (Media access contorl) address: 48 bits </li></ul><ul><li>Notation: </li></ul><ul><ul><li>01-23-45-67-89-ab or 01:23:45:67:89:ab </li></ul></ul>
  13. 14. Varieties of Ethernet <ul><li>10Mbs </li></ul><ul><ul><li>10Base2 (coaxial cable) </li></ul></ul><ul><ul><li>10BaseT(UTP, Unshielded twisted pair ) </li></ul></ul><ul><li>Fast Ethernet (100Mbs) </li></ul><ul><ul><li>100BaseT (cat5) </li></ul></ul><ul><li>Gigabit Ethernet </li></ul><ul><ul><li>1000BaseT -- 1 Gbit/s over cat-5 cable. </li></ul></ul><ul><li>10Gigabit Ethernet </li></ul><ul><ul><li>The 10 gigabit Ethernet family of standards encompasses media types for single-mode fibre (long haul), multi-mode fibre (up to 300m), copper backplane (up to 1m) and copper twisted pair (up to 100m). </li></ul></ul>
  14. 15. How to see your MAC address?
  15. 16. Back to TCP/IP
  16. 17. IP: Internet Protocol in TCP/ IP <ul><li>IP is the network layer </li></ul><ul><ul><li>Packet delivery service </li></ul></ul><ul><ul><li>Translation between different data-link protocols. </li></ul></ul>IP packet
  17. 18. IP Characteristics <ul><li>IP is a connectionless protocol </li></ul><ul><ul><li>No concept of a job or a session (each packet is treated as an entity in itself) </li></ul></ul><ul><li>IP is an unreliable protocol </li></ul><ul><ul><li>It is unconcerned with whether a packet reaches its eventual destination, or whether they arrive in the original order </li></ul></ul><ul><ul><li>IP cannot tell if packets were lost or whether they were received out of order </li></ul></ul><ul><li>IP packets are not identified as a part of a sequence or belonging to a particular job. </li></ul>IP packet 1 IP packet 2 IP packet 3 IP packet 4
  18. 20. IP Addresses <ul><li>IP is a network layer – it must be capable of providing communication between hosts on different kinds networks (different data-link implementations) </li></ul><ul><li>The address must include information about what network the receiving host is on. This is what makes routing feasible. (possible) </li></ul>
  19. 21. IP Addresses <ul><li>IP addresses are logical addresses (not physical) </li></ul><ul><li>IPv4: 32bits </li></ul><ul><li>Include a network ID and a host ID. </li></ul><ul><li>Every host must have a unique IP address. </li></ul><ul><li>IP addresses are assigned by a central authority (American Registry for Internet Numbers of North America, IANA ). </li></ul>
  20. 24. Number of IP Addresses 2^8=256 2^21=2,097,152 (2M) Class C 2^16=65535 (64K) 2^14=16384 (16K) Class B 2^24=16,777,216 (16M) 2^7=128 Class A # of host IDs per network ID # of network IDs Class
  21. 25. Class A-D addresses 1111xxxx D 110xxxxx C 10xxxxxx B 0xxxxxx A Finish address Start address Leftmost bits Class
  22. 26. Network and Host IDs <ul><li>A Network ID is assigned to an organization by a global authority. </li></ul><ul><li>Host IDs are assigned locally by a system administrator. </li></ul><ul><li>Both Network ID and Host ID are used for routing. </li></ul>
  23. 27. IP Addresses <ul><li>IP Addresses are shown in dotted decimal notation: </li></ul><ul><li> => 00000001 00000010 00000011 0000100 </li></ul><ul><li> => 0 1111100 .00101000.00101001.01101110 (class A) </li></ul><ul><li> => 110 01011.01110001.10000011 .01000101 (class C) </li></ul>
  24. 28. IP calculator <ul><li>http:// = = </li></ul>
  25. 29. Host and Network address <ul><li>A single network interface is assigned a single IP Address is called the host address. </li></ul><ul><li>A host may have multiple interfaces, therefore multiple host addresses . </li></ul><ul><li>Hosts that share a network all the same IP network address (network ID) </li></ul>
  26. 30. IP broadcast and Network address <ul><li>An IP broadcast addresses has a host ID of all 1s. </li></ul><ul><li>IP broadcasting is not necessarily a true broadcast, it relies on the underlying hardware technology. </li></ul><ul><li>An IP Address that has a host ID of all 0s is called a network address and refers to an entire network. </li></ul>
  27. 32. Divided a class B into 3 class C subnets.
  28. 33. Subnet ing (subnetworking) <ul><li>Subnets can simplify routing. </li></ul><ul><li>It’s possible to have a single wire network with multiple subnets. </li></ul>
  29. 34. IP Subnet Table (1) CIDR = Classless Inter-Domain Routing
  30. 35. IP Subnet Table(2)
  31. 36. IP Subnet Table (3)
  32. 37. IP Subnet table
  33. 38. IP Subnet Table (5) <ul><li> </li></ul><ul><li> </li></ul><ul><li>Ask google .. </li></ul>
  34. 39. Mapping IP Address to Hardware address <ul><li>IP Address are not recognized by hardware. </li></ul><ul><li>If we know the IP address of a host, how do we find out the hardware address? </li></ul><ul><li>The process of finding the hardware address of a host given the IP address is called Address Resolution . </li></ul>
  35. 40. Reverse Address Resolution <ul><li>The process of finding out IP Address of a host given a hardware address is called Reverse Address Resolution . </li></ul><ul><li>Reverse Address Resolution is needed by diskless workstations when booting. </li></ul>
  36. 41. ARP <ul><li>The Address Resolution Protocol is used by a sending host when it knows the IP Address of the destination but needs the hardware (Ethernet, mac) address. </li></ul><ul><li>ARP is a broadcast protocol – every host on the network receives the request. </li></ul><ul><li>Each host checks the request against it’s own IP address – the right one responds. </li></ul>
  37. 42. ARP cache <ul><li>ARP does not need to be done everytime an IP datagram is sent – hosts remember the hardware addresses of each other. </li></ul><ul><li>Part of the ARP protocol specifies that the receiving host should also remember the IP and hardware address of the sending host. </li></ul>
  38. 45. ARP command
  39. 46. Services provided by IP <ul><li>Connectionless Delivery (each datagram is treated individually) </li></ul><ul><li>Unreliable (delivery is not guaranteed) </li></ul><ul><li>Fragmentation / Reassembly (base on hardware MTU: maximum transfer unit) </li></ul><ul><li>Routing </li></ul><ul><li>Error detection </li></ul>
  40. 47. IP Datagram
  41. 48. IP Datagram Fragmentation <ul><li>Each fragment (packet) has the same structure as IP datagram. </li></ul><ul><li>IP specifies that datagram reassembly is done only at the destination . (not on hop-by-hop basis) </li></ul><ul><li>If any of the fragment are lost – the entire datagram is discarded (and an ICMP message is sent to the sender) </li></ul>
  42. 49. IP Flow Control & Error Detection <ul><li>If packets arrive too fast – the receiver discards excessive packets and sends an ICMP message to the sender (SOURCE QUENCH) </li></ul><ul><li>If an error is found (header checksum problem) the packet is discarded and an ICMP message is sent to the sender. </li></ul>
  43. 50. ICMP Internet Control Message Protocol <ul><li>ICMP is a protocol used for exchanging control messages. </li></ul><ul><li>ICMP uses IP to deliver messages. </li></ul><ul><li>ICMP messages are usually generated and processed by the IP software, not the user process. </li></ul>
  44. 51. ICMP Message Types <ul><li>Echo Request </li></ul><ul><li>Echo Response </li></ul><ul><li>Destination Unreachable </li></ul><ul><li>Redirect </li></ul><ul><li>Time Exceeded </li></ul><ul><li>Redirect (route change) </li></ul><ul><li>More… </li></ul>
  45. 52. IP … <ul><li>Let’s go to TCP </li></ul>
  46. 53. Transport Layer & TCP <ul><li>IP is the network layer, TCP must be the transport layer right? </li></ul><ul><ul><li>No.. Almost </li></ul></ul><ul><li>TCP is only part of the TCP/IP transport layer, the other part is UDP (User Datagram Protocol) </li></ul>
  47. 54. TCP/IP Layers
  48. 55. UDP User Datagram Protocol <ul><li>UDP is a transport protocol </li></ul><ul><ul><li>Communication between processes </li></ul></ul><ul><li>UDP uses IP to deliver datagrames to the right host </li></ul><ul><li>UDP uses ports to provide communication services to individual processes. </li></ul>
  49. 56. Ports <ul><li>TCP/IP uses an abstract destination point called a protocal port. </li></ul><ul><li>Ports are identified by a positive integer.(16 bit : 0-65535) </li></ul><ul><li>Operating systems provide some mechanism that proecsses use to specify a port. </li></ul><ul><li>Well known port numbers: http:// /assignments/port-numbers </li></ul>
  50. 58. UDP <ul><li>Datagram Delivery </li></ul><ul><li>Connectionless </li></ul><ul><li>Unreliable </li></ul><ul><li>Minimal </li></ul>
  51. 59. TCP: Transmission Control Protocol <ul><li>TCP is an transport layer protocol support by TCP/IP. </li></ul><ul><li>TCP provides: </li></ul><ul><ul><li>Connection-oriented </li></ul></ul><ul><ul><li>Reliable </li></ul></ul><ul><ul><li>Full-duplex </li></ul></ul><ul><ul><li>Byte-stream </li></ul></ul>
  52. 60. Reliable TCP
  53. 61. Connection-Oriented <ul><li>Connection oriented means that a virtual connection is established before any user data is transferred. </li></ul><ul><li>If the connection cannot be established – the user program is notified. </li></ul><ul><li>If the connection is ever interrupted – the user program can find out there is a problem. </li></ul>
  54. 62. Reliable <ul><li>Reliable means that every transmission of data is acknowledged by the reciver. </li></ul><ul><li>If the sender does not receive acknowledgement within a specified amount of time, the sender retransmits the data. </li></ul><ul><li>(Reliable does not mean that things don’t go wrong, it means that we find out when things go wrong) </li></ul>
  55. 63. Byte stream <ul><li>Stream means that the connection is treated as a stream of bytes. </li></ul><ul><li>The user application does not need to package data in individual datagrams. (as with UDP) </li></ul><ul><ul><li>Somebody still needs to package data into IP packets, just the application doesn’t care. </li></ul></ul>
  56. 64. Buffering <ul><li>TCP is responsible for buffering data and determining when it’s time to send the datagram. </li></ul><ul><li>It is possible for an application to tell TCP to send the data it has buffered without waiting for a buffer to fill up. </li></ul>
  57. 65. Full Duplex <ul><li>TCP provides transfer in both directions (over single virtual connection) </li></ul><ul><li>To the application program these appear as 2 unrelated data streams, although TCP can piggyback control and data communication by providing control information (such as ACK) along with user data. </li></ul>
  58. 66. TCP ports <ul><li>Interprocess communication via TCP is achieved with the use of ports.( just like UDP) </li></ul><ul><li>UDP ports have no relation to TCP ports. (different name spaces) </li></ul>
  59. 67. TCP Segments <ul><li>The chunk of data that TCP asks IP to deliver is called a TCP segment. </li></ul><ul><li>Each segment contains: </li></ul><ul><ul><li>Data bytes from the byte stream. </li></ul></ul><ul><ul><li>Control information that identifies the data bytes. </li></ul></ul>
  60. 68. TCP segment format
  61. 69. Addressing in TCP/IP <ul><li>Each TCP/IP address includes: </li></ul><ul><ul><li>Internet Address (IP) </li></ul></ul><ul><ul><li>Protocol (UDP or TCP) </li></ul></ul><ul><ul><li>Port Number </li></ul></ul>
  62. 71. TCP/IP summery <ul><li>IP: network layer protocol </li></ul><ul><ul><li>Unreliable datagram delivery between hosts </li></ul></ul><ul><li>UDP: transport layer protocol </li></ul><ul><ul><li>Unreliable datagram delivery between processes </li></ul></ul><ul><li>TCP: transport layer protocol </li></ul><ul><ul><li>Reliable, byte-stream delivery between processes </li></ul></ul>
  63. 72. TCP or UDP <ul><li>Electronic commerce? </li></ul><ul><li>Video server? </li></ul><ul><li>File transfer? </li></ul><ul><li>Email? </li></ul><ul><li>Chat groups? </li></ul>
  64. 73. OK. <ul><li>Reference: </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li>Images from </li></ul></ul>