Top Banner
TCP/IP Basics Happyman 2008/6/24
73
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tcp

TCP/IP Basics

Happyman

2008/6/24

Page 2: Tcp

Theory first

Page 3: Tcp

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

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

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
Page 7: Tcp

Network Protocol Operations

Page 8: Tcp

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

But First…

Page 10: Tcp

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

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

An Ethernet Frame

•Preamble: a sequence of alternating 1s and 0s used for synchronization.

•CRC: Cyclic Redundancy Check

Page 13: Tcp

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

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

How to see your MAC address?

Page 16: Tcp

Back to TCP/IP

Page 17: Tcp

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

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
Page 20: Tcp

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

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
Page 23: Tcp
Page 24: Tcp

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

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

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

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 29: Tcp

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

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
Page 32: Tcp

Divided a class B into 3 class C subnets.

Page 33: Tcp

Subnet ing (subnetworking)

• Subnets can simplify routing.

• It’s possible to have a single wire network with multiple subnets.

Page 34: Tcp

IP Subnet Table (1)

CIDR = Classless Inter-Domain Routing

Page 35: Tcp

IP Subnet Table(2)

Page 36: Tcp

IP Subnet Table (3)

Page 37: Tcp

IP Subnet table

Page 38: Tcp

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

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

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

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

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
Page 44: Tcp
Page 45: Tcp

ARP command

Page 46: Tcp

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

IP Datagram

Page 48: Tcp

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

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

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

ICMP Message Types

• Echo Request

• Echo Response

• Destination Unreachable

• Redirect

• Time Exceeded

• Redirect (route change)

• More…

Page 52: Tcp

IP …

• Let’s go to TCP

Page 53: Tcp

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

TCP/IP Layers

Page 55: Tcp

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

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
Page 58: Tcp

UDP

• Datagram Delivery

• Connectionless

• Unreliable

• Minimal

Page 59: Tcp

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

Reliable TCP

Page 61: Tcp

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

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

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

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

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

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

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

TCP segment format

Page 69: Tcp

Addressing in TCP/IP

• Each TCP/IP address includes:– Internet Address (IP)– Protocol (UDP or TCP)– Port Number

Page 70: Tcp
Page 71: Tcp

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

TCP or UDP

• Electronic commerce?

• Video server?

• File transfer?

• Email?

• Chat groups?

Page 73: Tcp

OK.

• Reference:– http://www.slideshare.net/fgirella/tcpip– Images from http://en.wikipedia.org/