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