2001 copyright scut dt&p labs 1 the principle of tcp/ip part 2

111
2001 Copyright 2001 Copyright SCUT DT&P Labs SCUT DT&P Labs 1 The Principle of TCP/IP The Principle of TCP/IP Part 2 Part 2

Upload: austen-fitzgerald

Post on 03-Jan-2016

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 1

The Principle of TCP/IPThe Principle of TCP/IP

Part 2Part 2

Page 2: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 2

The Internet Protocol SuiteThe Internet Protocol Suite

IP: Internet Protocol; ARP: Address Resolution Protocol;RARP: Reverse Address Resolution Protocol;

ICMP: Internet Control Message Protocol.

Page 3: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 3

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

A source must know a destination’s hardware address

before it can send an IP packet directly to it

ARP is the mechanism that maps IP to hardware

addresses.

ARP uses a local broadcast to obtain a hardware

address

ARP stores mappings in cache for future use

Page 4: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 4

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

The ARP is used to get IP addresses mapped onto data link layer addresses (MAC (Media Access Control ) addresses) in a LAN.According to IP addresses, look for MAC addresses.

Example 1: Host A (197.15.22.33) wants to send a IP datagram to host F (197.15.22.77), but it don’t know the MAC address of host F. Host A uses ARP to look for it. Host A

197.15.22.33Host B197.15.22.44

Host C197.15.22.123

Host D197.15.22.88

Host E197.15.22.36

Host F197.15.22.77

Page 5: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 5

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

Host A send a ARP request Packet with the MAC broadcast address.

197.15.22.33

Host F should response by sending back to answer the request.

197.15.22.77

Dest. SourceFF.FF.FF.FF.FF.FF 02.60.8C.01.0C.03Dest. SourceFF.FF.FF.FF.FF.FF 02.60.8C.01.0C.03

Dest. Source197.15.22.77 197.15.22.33Dest. Source197.15.22.77 197.15.22.33

ARP request packetWhat is your MAC addr.?

ARP request packetWhat is your MAC addr.?

MAC header IP header

Dest. Source02.60.8C.01.0C.03 05.68.7f.99.0B.02Dest. Source02.60.8C.01.0C.03 05.68.7f.99.0B.02

Dest. Source197.15.22.33 197.15.22.77Dest. Source197.15.22.33 197.15.22.77

ARP responsion packetThis is my MAC addr..

ARP responsion packetThis is my MAC addr..

MAC header IP header

Page 6: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 6

Then host A gets host F’s MAC address and can use it to transmit frames to host F.By the way, all other hosts in the same LAN know their MAC addresses. They save the addresses in their ARP table.Each item on the ARP table will be updated termly.

If the source and destination hosts are not in the same LAN, the source host would first look for the default router’s MAC address by ARP, then sends the frames (IP packets) to the default router.

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

Page 7: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 7

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

Source 160.30.100.2000-AA-00-12-34-56

Destination160.30.100.1000-A0-C9-78-9A-BC

“If your IP address is 160.30.100.10 please send me a reply stating your hardware address”

That’s me and my Hardware address is 00-A0-C9-78-9A-BC

Broadcast

Unicast

Example 2

Page 8: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 8

ARP Packet StructureARP Packet Structure

Sender’s Hardware Address (Octets 0-3)

Protocol Type

Target HA (octets 2 - 5)

32 bits (4 Bytes)

Hardware Type

PLENHLEN Operation code

Sender IP (Octets 0-1)Sender HA (Octets 4-5)

Sender IP (Octets 2-3) Target HA (Octets 0-1)

Target IP (octets 0 - 3)

Variable Length

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

Page 9: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 9

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

Hardware Type (16 bits): This specifies the hardware interface type, for example, Ethernet has a value of 1.

Protocol type (16 bits): This specifies the higher-level protocol whose address needs to be mapped onto the hardware, for example, IP - 0800.

HLEN, Hardware address LENgth (8 bits): This specifies the length in bytes of the hardware address in this packet, for example, Ethernet - 6.

PLEN, Protocol address LENgth (8 bits): This specifies the length in bytes of the protocol address in this packet. For IP this is four.

Operation code (16 bits): This specifies whether this is an ARP request (1) or an ARP reply (2).

Page 10: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 10

Sender’s hardware address (48 bits): This contains the hardware address of the sender (the ARP requester).

Sender’s IP address (32 bits): This contains the protocol address of the sender (the ARP requester).

Target’s hardware address (48 bits): This contains the hardware address of the target (the ARP responder).

Target’s IP address (32 bits): This contains the protocol address of the sender (the ARP responder).

8. Address Resolution Protocol (ARP)8. Address Resolution Protocol (ARP)

Page 11: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 11

9. Reverse Address Resolution Protocol9. Reverse Address Resolution Protocol

Reverse ARP is the mechanism that maps

hardware addresses to the IP address

RARP protocol allows a newly booted machine to broadcast its Ethernet address

The RARP server sees this request and sends back the corresponding IP address

Page 12: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 12

10. Internet Control Message Protocol (ICMP)10. Internet Control Message Protocol (ICMP)

Reports errors and sends control messages on behalf

of IP

ICMP messages are encapsulated within an IP packet

One of the most frequently used debugging tools uses

ICMP

It tests whether a destination is reachable and responding, by

sending ICMP echo requests and receiving back ICMP echo

replies

It carries out this test by using the “PING” command

Page 13: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 13

10.1 Echo Request and Reply Message 10.1 Echo Request and Reply Message FormatFormat

Code (0) Checksum

Identifier

Type (8 or 0)

Sequence Number

Optional Data

IP Header......

10. Internet Control Message Protocol (ICMP)10. Internet Control Message Protocol (ICMP)

Page 14: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 14

10. Internet Control Message Protocol (ICMP)10. Internet Control Message Protocol (ICMP)

Type (8 bits): This specifies the type of ICMP message;

Code (8 bits): This field is always set to 0 in PING messages.

Checksum (16 bits): This is a checksum carried out on the ICMP header only.

Identifier and Sequence number (16 bits each): These are used by the sender to match replies to requests.

Optional Data: This field contains information to be returned to the sender. An Echo reply always returns exactly the same data as was received in the Echo request.

Page 15: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 15

10.2 Reports of Unreachable Destinations10.2 Reports of Unreachable DestinationsCode Value Meaning

012345678

9

1112

Network unreachableHost unreachableProtocol unreachablePort unreachableFragmentation needed and DF setSource route failedDestination network unknownDestination host unknownSource host isolated

Communication with destination network administratively prohibited

Network unreachable for type of service

10Communication with destination host administratively prohibited

Host unreachable for type of service

10. Internet Control Message Protocol (ICMP)10. Internet Control Message Protocol (ICMP)

Page 16: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 16

10.2 ICMP Message Types10.2 ICMP Message Types

TYPEFIELD ICMP Message Types

03458

1112131415161718

Echo ReplyDestination UnreachableSource QuenchRedirect (change a route)Echo RequestTime exceeded for a packetParameter problem on a packetTimestamp requestTimestamp replyInformation request (obsolete)Information reply (obsolete)Address mask requestAddress mask reply

10. Internet Control Message Protocol (ICMP)10. Internet Control Message Protocol (ICMP)

Page 17: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 17

11. Trace-route11. Trace-route Trace-route uses ICMP and the TTL field in the IP header, to let

us see the route that IP packets follow from one host to another.

Source sends packet with TTL set to 1

First router sends back “time exceeded” message

Source increments TTL counter by 1

Second router on path send back “time exceeded” message

Process continues until ultimate destination send back “port

unreachable” message.

Source uses response to display route

Page 18: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 18

12. 12. BridgesBridges

12.1 Transparent Bridging

Source Address tableAddress Interface

1 A2 A3 A4 B5 B6 B7 C8 C9 C

A

B 6

5

4

2

3

1BRIDGE

9

8

7

C

Page 19: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 19

12. 12. BridgesBridges

12.2 Advantages of Bridging

Bridges can connect networks running different protocols without requiring additional software.

Bridges form logically single networks. A bridge makes the movement of network devices, e.g. PCs, within the network easy.

Bridges are simple to install. Bridges are cheaper than routers. The presence of a bridge is transparent to users

from the instant it is first installed, and bridges adapt automatically to network changes.

Page 20: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 20

12.3 Disadvantages of Bridging12. 12. BridgesBridges

Bridges cannot load-share traffic over two paths to a single destination.

Bridges cannot prevent a ‘broadcast storm’.

Bridges do not provide significant support for fault isolation or other distributed management capabilities.

Page 21: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 21

13.1 Path Taken by an IP Packet in an Internetwork

3

2

1 2

3

A

B

C

Destination Host (Protocol Address) Router 1 (Physical address)

Destination Host (Protocol Address) Router 2 (Physical address)

Destination Host (Protocol Address) Destination Host (Physical address)

13. 13. RoutersRouters

Page 22: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 22

13.2 Default Gateway

IP AddressSubnet Mask

Default Gateway

160.30.100.20255.255.255.0160.30.100.1

IP AddressSubnet Mask

Default Gateway

160.30.100.10255.255.255.0160.30.100.1

IP AddressSubnet Mask

Default Gateway

160.30.200.10255.255.255.0160.30.200.1

160.30.100.1 255.255.255.0

160.30.200.1 255.255.255.0

13. 13. RoutersRouters

Page 23: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 23

13.3 Routing Algorithms

Distance Vector Algorithms- calculate the best path to each destination separately, usually trying to find a path that minimize a simple metric, such as the number of hop counts to the destination.Example is Routing Information Protocol (RIP).

Link State Algorithms- Instead of advertising a list of distances to each known destination, a router running link-state algorithm advertises the states of its local network links. Example is Open Shortest Path First (OSPF).

13. 13. RoutersRouters

Page 24: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 24

13.4 Commonly used Metrics in IP Routing Path Length / Hop Count Reliability Delay Bandwidth Load Communications Cost

13. 13. RoutersRouters

Page 25: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 25

13.5 Advantages of Routers

Flexible - can differentiate between paths using metrics.

Can load share over redundant paths. Network Devices understand routers -

they understand congestion messages. Easier to administer and control

because each segment has a different address.

Provide a protective firewall.

13. 13. RoutersRouters

Page 26: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 26

13.6 Disadvantages of Routers Because routers are protocol-dependent

devices, they require software for each protocol that they run.

Routers make movement of network devices between network segments more difficult.

Some low level protocols, for example, DEC LAT and NetBIOS cannot be routed because they do not contain a network layer address.

13. 13. RoutersRouters

Page 27: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 27

14. 14. Autonomous System (AS)Autonomous System (AS)

An autonomous system (AS) is defined as a logical portion of larger IP networks that are administered by a single authority.

The AS would normally comprise the internetwork within an organization.

Gateway (router) protocols are referred to as interior or exterior, depending on whether they are used within or between ASs.

Page 28: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 28

14.1 IP Routing Protocol Hierarchies

Area 1

Router 4

Router 1

Router 5

H2Router 8

Router 7

Router 11

Router 13

H1

Area 2

Area 3

Router 12

Area 0(Backbone)

Router 2Router 3

Router 6

Router 9

Router 10

14. 14. Autonomous System (AS)Autonomous System (AS)

Page 29: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 29

15.1 Static Routing Static routing requires that routes be

configured manually for each router. Static Routing can be attractive in the

following cases: To define a default route; To supplement or replace exterior gateway

protocols for some special purposes: To avoid the cost of routing protocol

traffic; To implement complex routing policies.

15. 15. Routing AlgorithmsRouting Algorithms

Page 30: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 30

15. 15. Routing AlgorithmsRouting Algorithms15.2 Distance Vector Routing 1. Each router in an AS maintains the distance

table vector table which determines the distance from the router to every known routers.

2. The sequence of operations for maintaining the table:

Each router is configured with an identifier and a cost for each of its network links;

Each router initializes with a distance vector table containing 0 for itself, 1 for directly attached networks , and infinity for every other destination.

Each router periodically transmits its distance vector table to each of its neighbors.

Page 31: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 31

15. 15. Routing AlgorithmsRouting Algorithms15.2 Distance Vector Routing Each router uses the information to calculate its

own distance vector table. The total cost to each destination is calculated

by adding the cost reported to it in a neighbors’s distance vector table to the cost of the link to that neighbor.

The distance vector table for the router is then created by taking the lowest cost calculated for each destination.

The Count-to-Infinity Problem: it occurs when a network becomes unreachable, but erroneous routes to that network persist because of the time for the distance vector tables to converge.

Page 32: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 32

15. 15. Routing AlgorithmsRouting Algorithms15.2 Distance Vector Routing To prevent the Count-to-Infinity Problem

Split Horizon: a route to a destination is never reported back in the distance vector table that is sent to the neighbor from which the route was learned.

Split Horizon with Poison Reverse: Poison reverse is an enhancement to split horizon, whereby routes learned from a neighbor router are reported back to it, but with a metric of infinity.

Triggered Updates: when a router changes the cost for a route in its distance vector table, it must send the modified table immediately.

Page 33: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 33

15.3 Link-State Routing An LSPs (Link-State Packet) must be received

successfully and must be explicitly acknowledged.

A scheme called flooding is employed to distributed LSPs to all routers in a network.

All LSPs are sequenced and time-stamped to ensure duplicates are not received and retransmitted.

15. 15. Routing AlgorithmsRouting Algorithms

Page 34: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 34

15.3 Link-State Routing The principle of Link-State Routing Routers are responsible for contacting

neighbors and learning their identities. Routers construct link-state packets that contain

lists of network links and their associated costs. Link-state packets are transmitted to all routers

in a network. All router therefore have an identical list of links

in a network and construct identical list of links in a network and can construct identical topology maps.

The maps are used to compute the best routes to all destinations.

15. 15. Routing AlgorithmsRouting Algorithms

Page 35: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 35

15.3 Link-State Routing Link-state information is sent in the form of link-

state packets (LSPs) and under the following specific circumstance:

When a router discovers a new neighbor; When a link to a neighbor goes down; When the cost of a link changes; When basic refresh packets are sent every 30

minutes

15. 15. Routing AlgorithmsRouting Algorithms

Page 36: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 36

16 Routing Information Protocol (RIP)

RIP is a very simple protocol of the distance vector family. RIP was documented in RFC-1058 in June 1988 .

RIP messages can be broadly classified into two types: Routing information messages and messages used to request information.

RIP uses a very simple metric - the hop count. RIP packets are carried over User Data Protocol

(UDP) and IP. The RIP processes uses UDP port number 520. RIP updates are normally sent every 30 seconds by default.

Every entry has a timer (180 seconds by default) associated with it and on expiry the distance for that entry is set to infinity.

Page 37: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 37

16.1 Advantages of RIP

RIP automatically creates and maintains a network of routes.

Since RIP uses a single metric it is very easy to configure.

16. 16. RIPRIP

Page 38: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 38

16.2 Disadvantages of RIP

The diameter of the internetwork is limited to 15 router hops.

Network administrators cannot take into account such factors as bandwidth or delay when configuring their routing systems using RIP.

Each routing entry is updated every 30 seconds or so, regardless whether there has been a change in the network topology or not.

16. 16. RIPRIP

Page 39: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 39

16.3 Slow Convergence Problem

A B C D

Network Hops

A

B

C

D

Network Hops

A

B

C

D

Network Hops

A

B

C

D

1 3

1 1

1

1

1

2

2

2

2

3

16. 16. RIPRIP

Page 40: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 40

17 Open Shortest Path First (OSPF)

A more descriptive routing metric was introduced

OSPF can discover multiple best paths to a given destination

OSPF supports a 2 level routing hierarchy OSPF supports Variable Length Subnet Masks

(VLSM) OSPF packets have a space reserved for

authentication OSPF is an example of a link state algorithm

that adjusts to network changes quicker than RIP and is more robust

17. 17. OSPFOSPF

Page 41: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 41

17.1 Hierarchical OSPF Internetwork (2 level)

Area 1

Router 4

Router 1

Router 5

H2Router 8

Router 7

Router 11

Router 13

H1

Area 2

Area 3

Router 12

Area 0(Backbone)

Router 2Router 3

Router 6

Router 9

Router 10

17. 17. OSPFOSPF

Page 42: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 42

17.2 OSPF Packet Header Format

Version(1) Type Message Length

Router IP address

Area ID

Checksum

Authentication (octets 0-3)

0 8 16 24 31

Authentication Type

Authentication (octets 4-7)

Type Meaning1 Hello2 Database description3 Link status request4 Link status update5 Link status

acknowledgementIP protocol 89

IP Packet

24 byte header

17. 17. OSPFOSPF

Page 43: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 43

17.3 Sending and Receiving an OSPF Packet

Version(1) Type Message Length

Router IP address

Area ID

Checksum

Authentication (octets 0-3)

Authentication Type

Authentication (octets 4-7)

Version = 2

Type = 1 (hello)

Length = entire length

Router IP address = 192.168.10.1

Area ID = 3.0.0.0

Checksum = 16 bit checksum of entire packet

Authentication = 64 bits

Check on IP level

Check IP protocol number (89)

OSPF version must be 2

IP address must be on same network as receiving interface

Area ID must be = 3.0.0.0

Checksum must be successful

Authentication must be successful

13. 13. OSPFOSPF

Page 44: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 44

17.4 The Protocols within OSPF

Hello protocol-To check that the links are operational.-To elect the Designated Router (DR) and the Backup Designated Router (BDR).

Exchange protocol-Performs initial OSPF database synchronisation between two adjacent routers.

Flooding protocol-The flooding protocol is used to maintain the two databases in adjacent routers in synchronisation

17. 17. OSPFOSPF

Page 45: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 45

17.5 Advantages of OSPF OSPF is a standard protocol that all vendors

can implement interoperability. It provides rapid, deterministic calculation of

internet routes. It uses Link State Advertisements.

It facilitate separate administration of differing parts of the internet.

It facilitate hiding of detailed information about the internet.

It provides a more advanced use of metrics. With OSPF one can isolate misconfigured or

malfunctioning routers in the internet and route around them.

OSPF provides for the effective use of information derived from other routing protocols

17. 17. OSPFOSPF

Page 46: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 46

17.6 Disadvantages of OSPF

Link-state protocols use large amounts of router memory to store topological databases, as each router keeps a map of the entire network.

When a network experiences frequent changes, link-state routers use a large portion of network bandwidth by sending out LSPs at each network change.

17. 17. OSPFOSPF

Page 47: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 47

The TCP & UDP ProtocolThe TCP & UDP Protocol

Page 48: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 48

The Transmission Control The Transmission Control ProtocolProtocol (TCP)

Page 49: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 49

1. Transmission Control Protocol (TCP)1. Transmission Control Protocol (TCP)

Connection-oriented Provides logical connections between pair of processes:

These are uniquely identified using sockets Socket = IP address & port number, e.g. FTP is port

21

End-to-End reliable delivery Implements Flow Control

Page 50: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 50

1. Transmission Control Protocol (TCP)1. Transmission Control Protocol (TCP)

Units of data transferred between two devices running TCP software are called “segments”

Segments are exchanged to do the following: Establish a connection Agree window size Transfer data Send acknowledgements Close connection

Page 51: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 51

2. TCP Packet Structure2. TCP Packet Structure

TCP Headerlength

URG

ACK

PSH

RST

SYN

FIN

Window size

Checksum Urgent point

Options (0 or more 32-bit words)

Data

Acknowledgement number

Sequence number

Source port Destination port

Bit 0 31

Page 52: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 52

2.1 The Header Parameters of the TCP Packet2.1 The Header Parameters of the TCP Packet

Source port & Destination port: these fields identify the local end points of the connection.

A port plus its host’s IP address forms a 48-bit unique TSAP (Transport Service Access Point).

Each host may decide for itself how to allocate its own ports staring at 256.

Sequence number & Acknowledgement number: they perform the packet sequence control and receiving acknowledgement functions, respectively.

TCP header length: it tells how many 32-bit works are contained in the TCP header.

2. TCP Packet 2. TCP Packet StructureStructure

Page 53: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 53

2.1 The Header Parameters of the TCP Packet 2.1 The Header Parameters of the TCP Packet (continued)(continued)

URG is set to 1 if the Urgent point is in use. Urgent point: it is used to indicate a byte offset from the current sequence number at which urgent data are to be found.

ACK bit is set to 1 to indicate that the Acknowledgement number is valid.

PSH bit indicates PuSHed data. The receiver is hereby kindly requested to deliver the data to the application upon arrival and not buffer it until a full buffer has been received.

SYN bit is used, together with ACK, to establish connection.

2. TCP Packet 2. TCP Packet StructureStructure

Page 54: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 54

2.1 The Header Parameters of the TCP Packet 2.1 The Header Parameters of the TCP Packet (continued)(continued)

FIN bit is used to release a connection. Window size: it is used to data flow control. This field tells how many bytes may be sent starting at the bytes acknowledged.

Checksum is provided for extreme reliability. Options: this filed was designed to provide a way to add extra facilities not covered by regular header. The most important option is the one that allows each host to specify the maximum TCP payload it is willing to accept.

2. TCP Packet 2. TCP Packet StructureStructure

Page 55: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 55

3. TCP Connection Management3. TCP Connection Management

Connections are established in TCP using the three-way handshake:

Host 1 Host 2

SYN (SEQ=x)

SYN (SEQ=y, ACK=x+1)

SYN (SEQ=x+1, ACK=y+1)

Page 56: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 56

Example: Establishing a TCP ConnectionExample: Establishing a TCP Connection

SYN

SEQ # 1,000Window 8,760 bytes

Max segment 1,460 bytes

Client Server

SEQ # 3,000ACK # 1,001

Window 8,760 bytesMax segment 1,460 bytes

ACKSEQ # 1001ACK # 3001

SYN

3. TCP Connection Management3. TCP Connection Management

Page 57: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 57

3.1 TCP Connection Management (continued)3.1 TCP Connection Management (continued)

Three-way handshake can solve the effects and problems such as

Old duplicate CONNECT REQUEST appearing out of nowhere;

Duplicate CONNECTION REQUEST and duplicate ACK.

3. TCP Connection Management3. TCP Connection Management

Page 58: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 58

4. Positive Acknowledgement with Retransmit4. Positive Acknowledgement with Retransmit

Packet lost

Packet should arriveACK should be sent

Send Packet 1Start Timer

ACK would normally arrive at this time

Timer Expires

Retransmit Packet 1Start Timer

Receive Packet 1Send ACK 2

Receive ACK 2Cancel Timer

Events at Sender Site Network Messages Events at Receiver Site

Page 59: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 59

5. Sliding Window Protocol5. Sliding Window ProtocolInitial window

Window Slides

Segments 1, 2 and 3acknowledged

Page 60: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 60

5.1 Sliding Window Protocol5.1 Sliding Window Protocol

Send Segment 1

Send Segment 2

Send Segment 3

Receive Segment 1

Receive Segment 2

Receive Segment 3Send ACK 4 for next

segment expected

Data, SEQ#2,000 length=100

Data, SEQ#2,100 length=100

Data, SEQ#2,200 length=100

ACK#2,200

ACK#2,300

Send ACK 3 for nextsegment expected

Page 61: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 61

5.2 Example: TCP Transmission Policy5.2 Example: TCP Transmission PolicyThe Flow Control based on Shift Window Mechanism in TCP:

Sender Receiver

2K, SEQ=02K, SEQ=0

ACK=2048, WIN=2048ACK=2048, WIN=2048

2K, SEQ=20482K, SEQ=2048

ACK=4096, WIN=0ACK=4096, WIN=0

ACK=4096, WIN=2048ACK=4096, WIN=2048

1K, SEQ=40961K, SEQ=4096

Receiver’ buffer

2K

Empty0 4K

Full

Applicationreads 2k

2K

2K1K

Applicationdoes a 2kwrite

Applicationdoes a 3kwrite

Sender is blocked

Sender may sendup to 2K

Page 62: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 62

6. Well-known Port Numbers6. Well-known Port Numbers

Port Number

Description

7202123255380

160 -223

EchoFile transfer protocol (FTP) dataFile transfer protocol (FTP)controlTelnetSimple mail transfer protocol (SMTP)Domain name server (DNS)World wide web (WWW)Reserved

Page 63: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 63

7. TCP Congestion Control7. TCP Congestion ControlThe Congestion Algorithm in TCP: Congestion Window

0 5 10 15 20 250

5

10

15

20

25

30

35

40

Threshold

Timeout

Threshold

Transmission Number

Congestion Window (KByte)

Transmission Window=Min(Sliding Window, Congestion Window)

Page 64: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 64

7.1 Congestion Avoidance7.1 Congestion Avoidance Allowed-window = minimum of receiver_advertisement

and congestion window

Steady state: congestion window =

receiver_advertisement

Congestion occurs: reduce the congestion window by half

each time a segment is lost down to a minimum of one

segment

Congestion clears: increase the congestion window by

one each time an acknowledgement is received (“Slow

start”)

The congestion window is flow control imposed by the

sender, while the advertised window is flow control

imposed by the receiver.

Page 65: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 65

The UDP ProtocolThe UDP Protocol

Page 66: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 66

1. User Datagram Protocol (UDP)1. User Datagram Protocol (UDP)

Connectionless No session is established

Does not guarantee delivery No sequence numbers No acknowledgements

Reliability is the responsibility of the application

Uses port numbers as end points to communicate

UDPUDP

Page 67: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 67

2 The Header of the UDP Packet2 The Header of the UDP Packet

Source portSource port Destination portDestination port

31

UDP lengthUDP length UDP checksumUDP checksum

0

UDPUDP

Page 68: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 68

2. The Header of the UDP Packet (continued)2. The Header of the UDP Packet (continued)

Source port & Destination port: these fields identify the local and the end points of the connection.

UDP length : the length of the header and data.

Checksum is provided for extreme reliability, it include the pseudo-header.

UDPUDP

Page 69: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 69

2. The Header of the UDP Packet (continued)2. The Header of the UDP Packet (continued)

The pseudo-header includes in the TCP or UDP checksum

Source address Source address

Destination addressDestination address

TCP/UDP segment lengthTCP/UDP segment lengthProtocol #Protocol #0000000000000000

UDPUDP

Page 70: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 70

3. The Computation of the TCP/UDP 3. The Computation of the TCP/UDP ChecksumChecksum

It checksums the header, the data and the conceptual pseudo-header of the packet.

The checksum algorithm is simply to add up all the 16-bit words and then to take 1’s complement of the sum.

When the receiver performs the calculation on the entire segment, including the checksum field, the result should be zero.

UDPUDP

Page 71: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 71

The Transport Layer Service PrimitivesThe Transport Layer Service Primitives

Page 72: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 72

The Transport Layer Service The Transport Layer Service PrimitivesPrimitives

•Transport service primitives allow transport users (e.g., application programs) to access the transport service .

•The application programs assume the connection between them is perfect. They do not want to know about acknowledgements, lost packets, congestion, or anything like that.

•The connection-oriented transport service hides the imperfections of the network service so that user processes can just assume the existence of an error-free bit stream.

1. Transport service

Page 73: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 73

•The transport layer can also provide unreliable (datagram) service. In such case, the application layer is responsible for error control, flow control, etc. .

•The network service is used only by the transport entities. Many programs (and thus the programmers) see only the transport primitives.

The Transport Layer Service PrimitivesThe Transport Layer Service Primitives

Page 74: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 74

2. Berkeley Sockets Primitive Meaning

SOCKET : Create a new communication end point.BIND: Attach a local addresser to a socket.LISTEN: Announce willingness to accept connections; give queue size.ACCEPT: Block the caller until a connection attempt arrives.CONNECT: Actively attempt to establish a connection.SEND: Send some data over the connection.RECEIVE: Receive some data from the connection. CLOSE: Release the connection.

The Transport Layer Service PrimitivesThe Transport Layer Service Primitives

Page 75: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 75

3. Server side3. Server side

•The SOCKET primitive creates a new end point and allocates table space for it within the transport entity.

•The parameters of the call (SOCKET) specify (1) the addressing format to be used, (2) the type of service desired (e.g. reliable

byte stream);(3) the protocol.

•The BIND primitive (call) is used to assign an address and a port number to a socket;

The Transport Layer Service PrimitivesThe Transport Layer Service Primitives

Page 76: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 76

•The LISTEN primitive allocates space to queue incoming calls for the case that several clients try to connect at the same time.

•The ACCEPT primitive is executed by a server to block waiting for an incoming connection.

The Transport Layer Service PrimitivesThe Transport Layer Service Primitives

Page 77: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 77

4. Client side:4. Client side:

•A socket must first be created using the SOCKET primitive;

•The CONNECT primitive (it contains the address and port number) is to block the caller and actively starts the connection process.

•When an appropriate TPDU is received from the server, the client process is unblocked and the connection is established.

•Both sides can now use SEND and RECEIVE to transmit and receive data over the full-duplex connection.

The Transport Layer Service PrimitivesThe Transport Layer Service Primitives

Page 78: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 78

5. Connectionless (UDP) communication operation

socket()

Server

bi nd()

recvf rom()sendto()

cl osesocket()

socket()

Cl i ent

bi nd()

recvf rom()sendto()

cl osesocket()

request f ordata

send data

Page 79: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 79

6.Connection-oriented (TCP) communication operation

socket()

Server

bi nd()

cl osesocket()

Cl i entl i sten()

accept()

read()

wri te()

socket()

connect()

wri te()

cl osesocket()

wri te()

request f orconnecti on

request f ordata

send data

Page 80: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 80

The Application layer Protocol of TCP/IPThe Application layer Protocol of TCP/IP

Page 81: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 81

The Application layer Protocol of TCP/IPThe Application layer Protocol of TCP/IP

The application layer supports addressing protocols and network management. It also has protocols for file transfer, e-mail, and remote login.

File Transfer : TFTP ; FTP E-Mail : SMTP Remote Login : Telnet ; FTP Network Management : SNMP Name Management : DNS

Page 82: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 82

DNS- Domain Name SystemDNS- Domain Name System

Internet addresses are hard for humans to remember

- Easy for protocol software to work with.

Symbolic names are more natural for humans

- Hard for protocol software to work with.

HumansProtocol software

185.26.69.125

Kiss.val.com

?

Page 83: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 83

Internet Domain Name SpaceInternet Domain Name Space

int com edu gov mil org net us se ie

Generic Countries

tcl

eng

Oxford

CS eng

ai Linda

robot

Pizza

cookie 4Star

Krusty

Burger

Page 84: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 84

Domain Name ResolutionDomain Name Resolution

com

TCLJuniper ACC

saleseng research

.

Page 85: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 85

Domain Name Resolution 1Domain Name Resolution 1

Root Name Server

Com NameServer

tcl.com

eng.tcl.com

LocalNameServer

DNSClient

1 10

2 34

5

6

7

8

9

Recursivequery

Page 86: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 86

Domain Name Resolution 2Domain Name Resolution 2

Flits.cs.vu.nl Cs.vu.nlEdu-server

.netYale.edu Cs.yele.edu

Originator UV CSName Server

EduName Server

YaleName Server

Yale CSName Server

How the originator (flits.cs.vu.nl) gets the IP address of the host, ai.cs.yale.edu.

1 2 3 4

5678

Page 87: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 87

DNS CachingDNS Caching Internet name servers use name caching to reduce the traffic

on the internet and improve performance.

Servers report cached information to clients, but mark it as a

non-authoritative binding,

If efficiency is important, the client will choose to accept the

non-authoritative answer and proceed.

If accuracy is important the client will choose to contact the

authority and verify that the binding between name and

address is still valid.

Whenever an authority responds to a request, it includes a

Time To Live (TTL) value in the response that specifies how

long it guarantees the binding to remain

Page 88: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 88

TCP and UDP port numbersTCP and UDP port numbers

The concept of the Well-Known Port Number

FTP

Telnet

SNMP

DNS

TFTP

SNMP

Port number Transport Layer

ApplicationLayer

TCP UDP

21 23 25 53 69 161

Page 89: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 89

TelnetTelnet

Remote terminal protocol which allows a user at

one site to establish a TCP connection to a login

server at another

Defines a network virtual terminal that provides a

standard interface to remote systems

Includes a mechanism that allows the client and

server to negotiate options, and it provides a set of

standard options

Treats both ends of the connection symmetrically

Page 90: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 90

Telnet (Contd)

LAN

LocalLogin

RemoteLogin SERVER

Remote Telnet Client Local directly attached Client

Page 91: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 91

Network Virtual Terminal (NVT)

TelnetClient

TelnetServer

NUL

BEL

BS

HT

LF

VT

FF

CR

ASCIIControl

code

Decimalvalue

0

7

8

9

10

11

12

13

Assigned meaning

No operation (has no effect on output)

Produce audible signal

Move left one character position

Move right to the next horizontal tab stop

Move down (vertically) to the next line

Move down to the next vertical tab stop

Move to the top of the next page

Move to the left margin on the current line

TCP Connection

NVT format used

Server system format used

Client system format used

Page 92: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 92

Telnet Command Codes

SENOPDMBRKIPAOAYTEC

240241242243244245246247

End of option sub-negotiationNo operationData markBreakInterrupt processAbort outputAre you thereErase character

CommandDecimalValue

Assigned Meaning

ELGASBWILLWONTDODONTIAC

248249250251252253254255

Erase lineGo aheadBegin sub-negotiationSender request enabling optionSender rejects enabling optionSender requests other side enabling optionSender rejects other side enabling optionInterpret next octet as command

Page 93: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 93

Telnet (Contd)

Telnet command codes are one or more octets in

length, and are preceded by an interpret as

command (IAC) character,which is an octet with

each bit set equal to one (FF hex).

If an octet equal to FF hex occurs in real date, it must

be preceded by an IAC character in order to

prevent it being mistaken as an IAC character.

Example: IAC IP ----- 255 followed by 244.

Page 94: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 94

Telnet OptionsTelnet Options

Transmit Binary

Echo

Suppress-GA

Status

Timing-mark

Terminal-type

End-of-record

Linemode

Name Code

0

1

3

5

6

24

25

34

Assigned meaning

Change transmission to 8-bit binary

Allow one side to echo data it receives

Suppress go-ahead signal after data

Request for status of a Telnet option from remote site

Request timing mark to be inserted in return stream

Exchange info.. about the terminal type being used

Terminate data sent with EOR code

Send complete lines instead of individual characters

RFC

856

857

858

859

860

884

885

1116

Page 95: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 95

File Transfer Protocol (FTP)

FTP is the Internet standard for file transfer.

FTP is used to copy a complete file from one system to

another system.

FTP also offers other facilities beyond the transfer

function itself:

Interactive access

Format specification

Authentication control

Page 96: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 96

File Transfer Protocol - (FTP)File Transfer Protocol - (FTP)

FTP control (port 21)

FTP data (port 20)

Page 97: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 97

FTP CommandsFTP Commands

Command DescriptionABORLIST filelistPASS passwordPORT n1,n2,n3,n4,n5,n6QUITRETR filenameSTOR filenameSYSTTYPE typeUSER username

Abort previous FTP command and any data transferList files or directoriesPassword on serverClient IP address (n1.n2.n3.n4) and port (n5 * 256 + n6)Logoff from serverRetrieve (get) a fileStore (put) a fileServer returns system typeSpecify file type: A for ASCII, I for imageUsername on server

Page 98: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 98

FTP RepliesFTP Replies

1yzPositive preliminary reply. The action is being started, but expect another reply, before sending another command.

Positive completion reply. A new command can be sent.

Positive intermediate reply. The command has been accepted but another command must be sent.Transient negative completion reply.The requested action did not take place, but the error condition is temporary so the command can be reissued later.Permanent negative completion reply. The command was not accepted and should not be retried.

2yz

3yz

4yz

5yz

Syntax errors

Information

Connections; Replies referring to the control or data connections.

Authentication and accounting. Replies for the login or accounting commands.

Unspecified

Filesystem status

Reply Description

x0z

x1z

x2z

x3z

x4z

x5z

Page 99: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 99

FTP ExampleFTP Example> ftp rs.internic.netConnected to rs.internic.net.220-*****Welcome to the InterNIC Registration Host **********Login with username "anonymous"*****You may change directories to the following:policy - Registration Policiestemplates - Registration Templatesnetinfo - NIC Information Filesdomain - Root Domain Zone Files220 And more!User (rs.internic.net:(none)): anonymous331 Guest login ok, send your complete e-mail address as password.Password:xxxxxxxxxxxx230 Guest login ok, access restrictions apply.ftp> cd rfc250 CWD command successful.ftp> get rfc1878.txt200 PORT command successful.150 Opening ASCII mode data connection for rfc1878.txt (19414 bytes).226 Transfer complete.ftp: 19865 bytes received in 85.02Seconds 0.23Kbytes/sec.

Page 100: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 100

FTP Example (Contd)FTP Example (Contd)Client Server

USER

PASSguest

TYPE ASCII

STRU FILE

MODE STREAM

QUIT

RETR

200 Command OK

150 Opening data connection for...226 Transfer complete

anonymous

200 Command OK

200 Command OK

200 Port Command OK

Page 101: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 101

TFTP- Trivial File Transfer ProtocolTFTP- Trivial File Transfer Protocol

TFTP is an extremely simple protocol to transfer files

Communication between a TFTP client and server uses

UDP (port 69) not TCP

TFTP does not have authorisation

TFTP always sends 512 byte blocks of data

Page 102: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 102

TFTP ProcessTFTP ProcessTFTP Client TFTP Server

(DATA)DATA

512 octets

WRQ

(WRQ)

ACK(ACK)

ACK(ACK)

(DATA)DATA

< 512 octetsACK

(ACK)

Page 103: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 103

Format of TFTP MessagesFormat of TFTP Messages

Read request (1) 00Filename Mode

Write request (2) 00Filename Mode

Block numberData (3) Data

Block numberAck (4)

Error codeError (5) Error message 0

2 octets

2 octets

2 octets

2 octets

2 octets

2 octets

2 octets2 octets

n octets n octets

n octets

n octets

n octets

Up to 512 octets

1 octet

1 octet

1 octet

1 octet

Page 104: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 104

Simple Mail Transfer Protocol (SMTP)Simple Mail Transfer Protocol (SMTP)

SMTP is the Internet standard mail service Uses TCP port 25

SMTP

TCP

IP

Network Interface (data-link & physical)

Page 105: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 105

SMTP ProcessSMTP Process

User interactively creates the message

User agent accepts the message and formats it builds list of destinations sends list and message to a queue for the client

Client establishes TCP connection with remote SMTP servers sends addresses to the relevant servers sends single copy of message to each server

Server constructs a header (which includes pointer to user’s

text) for each address places header in the queue of the appropriate mailbox

Page 106: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 106

SMTP Process (Contd)SMTP Process (Contd)

SMTPClient

SMTPClient

SMTPServer

TCP/IP InternetSMTPServer

Port 25

Port 25

User terminal A User terminal CUser terminal B

SMTP System 1 SMTP System 2

Page 107: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 107

SMTP CommandsSMTP Commands

HELO sent by an SMTP agent to initialise a connection and

identify the SMTP client.

format: “HELO(SP){domain host name}(CRLF)”.

MAIL identifies the sender

format: “MAIL(SP)<reverse path>(CRLF)”.

RCPT identifies the recipient

format: “RCPT(SP)TO:<forward path>(CRLF)”.

Page 108: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 108

SMTP Commands (Contd)SMTP Commands (Contd)

DATA informs the SMTP server that the phase of sending

forward paths is complete implies the next communication is data. format: “DATA(CRLF)”

SEND identifies an individual terminal to receive the mail format: “SEND(SP)TO:<reverse path>(CRLF)”.

QUIT advises the SMTP server that the SMTP client is finished format: “QUIT(CRLF)”.

Page 109: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 109

Reply CodesReply CodesReplyCode

Meaning

211 System status

214 Human information about how to use SMTP

220 <domain> service ready

221 <domain> service closing channel

250 Requested mail action okay, completed

251 User not local, forwarded to forward path

354 Start mail input, end with <CRLF>.<CRLF>

421 <domain> Service not available

450 Requested action aborted; mailbox unavailable

451 Requested action aborted; error in processing

452 Requested action aborted; insufficient storage

504 Command parameter not implemented

ReplyCode

Meaning

500 Syntax error, command unrecognised

501 Syntax error, in parameters or arguments

550 Requested action not taken; mailbox unavailable

551 Requested action not taken; error in processing

552 User not local; please try <forward path>

553 Action not taken; mailbox name not allowed

503 Bad sequence number

502 Command not implemented

554 Transaction failed

Page 110: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 110

SMTP Protocol ExampleSMTP Protocol Example

1 Server 220 {Server Name B} Mail Transfer Service Ready

Number Client/Server Reply code communication

2 Client HELO {Host Name A}3 250 {Service Name B}4 MAIL FROM:<[email protected]>5 250 OK6 RCPT TO:<[email protected]>7 250 OK

Server

Server

Server

Client

Client

Page 111: 2001 Copyright SCUT DT&P Labs 1 The Principle of TCP/IP Part 2

2001 Copyright 2001 Copyright SCUT DT&P LabsSCUT DT&P Labs 111

SMTP Protocol Example (Contd)SMTP Protocol Example (Contd)

8 Client RCPT TO:<[email protected]>

Number Client/Server Reply code communication

9 Server 550 No such user here

10 RCPT TO:<[email protected]>

11 250 OK

12 DATA

13 354 Start mail input; end with <CRLF>.<CRLF>

14 {ASCII character text}

Client

Client

Client

Client

Client

Server

Server

Server

Server

15

16

17

18

<CRLF>.<CRLF>

250 OK

QUIT

221 {Host Name B} Service closing channel