Tcp

Post on 14-Nov-2014

1.733 views 0 download

Tags:

description

 

Transcript of Tcp

TCP/IP Basics

Happyman

2008/6/24

Theory first

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)

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

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.

Network Protocol Operations

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)

But First…

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.

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

An Ethernet Frame

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

•CRC: Cyclic Redundancy Check

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

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).

How to see your MAC address?

Back to TCP/IP

IP: Internet Protocol in TCP/IP

• IP is the network layer– Packet delivery service– Translation between different data-link

protocols.

IP packet

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

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)

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).

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

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

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.

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)

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)

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.

Divided a class B into 3 class C subnets.

Subnet ing (subnetworking)

• Subnets can simplify routing.

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

IP Subnet Table (1)

CIDR = Classless Inter-Domain Routing

IP Subnet Table(2)

IP Subnet Table (3)

IP Subnet table

IP Subnet Table (5)

• http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html#SUBNETS

• http://packetiq.com/reference/subnet-mask-table.htm

• Ask google ..

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.

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.

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.

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.

ARP command

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

IP Datagram

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)

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.

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.

ICMP Message Types

• Echo Request

• Echo Response

• Destination Unreachable

• Redirect

• Time Exceeded

• Redirect (route change)

• More…

IP …

• Let’s go to 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)

TCP/IP Layers

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.

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

UDP

• Datagram Delivery

• Connectionless

• Unreliable

• Minimal

TCP: Transmission Control Protocol

• TCP is an transport layer protocol support by TCP/IP.

• TCP provides:– Connection-oriented– Reliable– Full-duplex– Byte-stream

Reliable 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.

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)

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.

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.

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

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)

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.

TCP segment format

Addressing in TCP/IP

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

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

TCP or UDP

• Electronic commerce?

• Video server?

• File transfer?

• Email?

• Chat groups?

OK.

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