Sie sind auf Seite 1von 90

Computer

Networks Yuan Wei

Huazhong University of Science and Technology, China

1
Some boring concepts
• Protocol
• Layering
• Protocol stack
• Network architecture
• Interface
• Service
• Reference models
• …

2
Chapter 1 Introduction
• Switching Strategies
• Protocols
• Layering
• Reference models

3
Switching Strategies
Circuit Switching:
– reserve a path (bandwidth, buffers) bw 2 hosts
– e.g., original telephone networks

Packet Switching:
– no path is reserved; no guarantees, best effort
– store and forward
– e.g. Internet

4
Circuit Switching
• http://www.tcpipguide.com/free/t_CircuitSwitchingandPacketSwitchingNetworks.htm
• In a circuit-switched network, before communication can occur between two devices,
a circuit is established between them.
• Once set up, all communication between these devices takes place over this circuit.
• The circuit may either be a fixed one that is always present, or it may be a circuit that
is created on an as-needed basis.

5
Circuit Switching
• The classic example of a circuit-switched network is the
telephone system.
– When you call someone and they answer, you establish a circuit
connection and can pass data between you.
– That circuit functions the same way regardless of how many
intermediate devices are used to carry your voice.
– You use it for as long as you need it, and then terminate the
circuit.
– The next time you call, you get a new circuit, which may
(probably will) use different hardware than the first circuit did,
depending on what's available at that time in the network.

6
Circuit Switching

A B
交换机
 
C

D

7
Packet Switching
• No specific path is used for data transfer.
• The data is chopped up into small pieces called packets and sent over the
network.
– The packets can be routed, fragmented, as required to get them to their eventual
destination.
– On the receiving end, the process is reversed—the data is read from the packets
and re-assembled into the form of the original data.
– A packet-switched network is more analogous to the postal system than it is to
the telephone system (though the comparison isn't perfect.)
• Blocks of data, even from the same file or communication, may take any
number of paths as it journeys from one device to another

8
Packet Switching (1)
• In the source node, the message is
chopped up into small segments
Message
1101000110101010110101011100010011010010

Too long to transmit

9
Packet Switching (2)
• Segment+ header = packet 。
Message
data data data
Packet 1
header
Packet 2

header
Packet 3

header

10
Packet Switching (3)
• Packets are used as the basic units of transmission

packet 1

首部 data
Packet 2

首部 data
packet 3

首部 data
11
Why we use the headers
• Headers contain some important control
information such as addresses
• According to the address, the router
forward the packet to the next
router/host

12
Packet Switching (4)
• After receiving the packets, the destination node
remove the headers
packet 1

首部 data
Packet 2

首部 data
Packet 3

首部 data

13
Packet Switching (5)
• In the end, the destination node (receiver)
reassembles the segments and gets the original
message
Message
data data data
1101000110101010110101011100010011010010

• In this case, we assume that no error


and packet loss occur
14
packet switching
H4
H2
The Path is changed!
D
router
B
H6
host
H1 E
H2 =>H6
A

H5 H1 => H5
C

H3 15
Store and forward
H4
H2
Reach
ItItisIt the destination
isbuffered
isbuffered
buffered andandnode
and
D
router
finds
finds
gets
the
the
the
output
output
output
port
B port
port H1 => H5
H6
host
H1 E
A

H5
C

H3 The Packet Switched Network 16


Comparing Circuit Switching and Packet Switching
• With circuit switching, a route is reserved from source to
destination.
• The entire message is sent in order so that it does not
have to be reassembled at the destination.
• Circuit switching can be relatively inefficient because
capacity is wasted on connections which are set up but
are not in continuous use (however momentarily).
• On the other hand, the connection is immediately
available and capacity is guaranteed until the call is
disconnected.

17
Comparing Circuit Switching and Packet Switching
• Packet switching is the process of segmenting a
message/data to be transmitted into several smaller packets.
• Each packet is labeled with its destination and the number of
the packet, precluding the need for a dedicated path to help
the packet find its way to its destination.
• Each is dispatched and many may go via different routes.
• At the destination, the original message is reassembled in the
correct order, based on the packet number.
• Packet switching networks do not require a circuit to be
established and allow many pairs of nodes to communicate
almost simultaneously over the same channel.

18
Chapter 1 Introduction
• Switching Strategies
• Protocols
• Layering
• Reference models

19
The need for a protocol
• A set of rules is needed for any means of
communication:
– Human intercommunication (in pairs or larger groups) requires
rules of conversation (do not speak if someone else is speaking)
to function effectively.
– Computers are no different. Consider the following simplistic
analogy:
• Two computers connected via a single connection -- Imagine two
people talking via two tin cans connected via a piece of string:
– If the two people talk at the same time then we get what is known (in
networking terms) as data collision.
– Therefore, we need regulations and rules to how we
communicate over a computer network.
– The set of rules and regulations is called a Protocol.

20
21
Protocol Example
Brunch request: URL request:

hello
connection request

yes?
connection reply

got pan-cakes? get http:www.umd.edu/index.html

coming up soon index.html

(not necessarily typical:) 22


Protocols
• A protocol is a set of rules and formats that govern the communication between
communicating peers
– set of valid messages
– meaning of each message
• A protocol is necessary for any function that requires cooperation between peers
• A protocol can be defined as the rules governing the syntax, semantics, and
synchronization of communication.
– Protocols may be implemented by hardware, software, or a combination of the two.

23
What does a protocol tell us?
• Syntax of a message
– what fields does it contain?
– in what format?
• Semantics of a message
– what does a message mean?
– for example, not-OK message means receiver got a
corrupted file
• Actions to take on receipt of a message
– for example, on receiving not-OK message, retransmit the
entire file

24
Examples

25
example application layer protocol: http (client side)

1. Telnet to UCD WWW server:


Open TCP connection to port 80
telnet www.cs.ucdavis.edu 80
(default http server port) at www.cs.ucdavis
Anything typed in sent
to port 80 at www.cs.ucdavis

2. Type in a GET http request:


GET /instruction/default.html HTTP/1.0
Host: www.cs.ucdavis.edu hit carriage return twice

3. Look at response message sent by http server in response to your minimal, but complete request

26
Another way to view a protocol
• As providing a service
• The example protocol provides reliable file
transfer service
• Peer entities use a protocol to provide a
service to a higher-level peer entity
– for example, postal workers use a protocol to
present customers with the abstraction of an
unreliable letter transfer service

27
Chapter 1 Introduction
• Switching Strategies
• Protocols
• Layering
• Reference models

28
Protocol layering
• A network that provides many services needs many
protocols
• Turns out that some services are independent
• But others depend on each other
• Protocol A may use protocol B as a step in its execution
– for example, packet transfer is one step in the execution of the
example reliable file transfer protocol
• This form of dependency is called layering
– reliable file transfer is layered above packet transfer protocol

29
Some terminology
• Service access point (SAP)
– interface between an upper layer and a lower layer
• Protocol data units (PDUs)
– packets exchanged between peer entities
• Service data units (SDUs)
– packets handed to a layer by an upper layer
• PDU = SDU + optional header or trailer

30
Protocol stack
• A set of protocol layers
• Each layer uses service from the layer below
and provides a service to the layer above
• Key idea
– once we define a service provided by a layer, we
need know nothing more about the details of how the
layer actually implements the service
– information hiding
– decouples changes

31
The importance of being layered
• Breaks up a complex problem into smaller
manageable pieces
– can compose simple service to provide complex ones
• Abstraction of implementation details
– separation of implementation and specification
– can change implementation as long as service
interface is maintained
• Can reuse functionality
– upper layers can share lower layer functionality

32
Advantages of Layering
• Layering provides two nice features.

• Firstly, it decomposes the problem of building a network


into more manageable components.
– Rather than implementing a monolithic piece of software that
does everything you will ever want, you can implement several
layers, each of which solves one part of the problem.
• Secondly, it provides a more modular design.
– If you decide that you want to add some new service, you may
only need to modify the functionality at one layer, reusing the
functions provided at all the other layers..

33
Problems with layering
• Layering hides information
– if it didn’t then changes to one layer could
require changes everywhere
• But sometimes hidden information can be
used to improve performance

34
Example: A five-layer network

35
A five-layer network
• No data are directly transferred from layer
n on one machine to layer n on another
machine.
• Each layer passes data and control
information to the layer immediately below
it, until the lowest layer is reached.
• Below layer 1 is the physical medium
through which actual communication
occurs.
36
Interface
• The interface defines which primitive operations and
services the lower layer makes available to the upper
one.
• When network designers decide how many layers to
include in a network and what each one should do, one
of the most important considerations is defining clean
interfaces between the layers.
• In addition to minimizing the amount of information that
must be passed between layers, clear-cut interfaces also
make it simpler to replace the implementation of one
layer with a completely different implementation

37
Network architecture
• A set of layers and protocols is called a
network architecture.
• A list of protocols used by a certain
system, one protocol per layer, is called a
protocol stack.

38
An analogy: The Foreigner-translator-telephone architecture

39
The Foreigner-translator-telephone architecture
• The two foreigners exchange ideas, i.e., they communicate. But they only do so
virtually.
– In reality, they are both handing over information to their interpreters
– The interpreters are far away from each other, they communicate over the phone;
– Thus the information is physically transmitted over phone lines.
• We can therefore talk about virtual communication in the horizontal direction
(philosophical communication, the shared language between interpreters, and
electronic signals transmitted via phone lines) and real communication in the
vertical direction (foreigner-to-interpreter and interpreter-to-phone).
• We can thus distinguish three levels of communication:
– 1. Between two foreigners
– 2. Between interpreters
– 3. Physical transmission of information using media (phone lines, sound waves, etc.)
• Communication between the two foreigners and between the two interpreters is
only virtual.
• In fact, the only real communication happens between the foreigner and his or her
interpreter.

40
The Relationship of Services to Protocols
• A service is a set of primitives (operations) that a layer provides to the layer
above it.
• The service defines what operations the layer is prepared to perform on
behalf of its users, but it says nothing at all about how these operations are
implemented.
• A service relates to an interface between two layers, with the lower layer
being the service provider and the upper layer being the service user.
• A protocol is a set of rules governing the format and meaning of the
packets, or messages that are exchanged by the peer entities within a layer.
• Entities use protocols to implement their service definitions. They are free to
change their protocols at will, provided they do not change the service
visible to their users.
• Services relate to the interfaces between layers. And protocols relate to the
packets sent between peer entities on different machines

41
Connection-Oriented and Connectionless Services
• Layers can offer two different types of
service to the layers above them:
connection-oriented and connectionless
– Connection-oriented service is modeled after
the telephone system
– Connectionless service is modeled after the
postal system.

42
Connection-Oriented Services
• To talk to someone, you pick up the phone, dial the
number, talk, and then hang up.
• Similarly, to use a connection-oriented network service,
the service user first establishes a connection, uses the
connection, and then releases the connection.
• The essential aspect of a connection is that it acts like a
tube: the sender pushes objects (bits) in at one end, and
the receiver takes them out at the other end.
• In most cases the order is preserved so that the bits
arrive in the order they were sent.

43
Connectionless Services
• Each message (letter) carries the full destination
address, and each one is routed through the
system independent of all the others.
• Normally, when two messages are sent to the
same destination, the first one sent will be the
first one to arrive.
• However, it is possible that the first one sent can
be delayed so that the second one arrives first.

44
Design Issues for the Layers
• Some of the key design issues that occur in
computer networks are present in several layers.
– Addressing
– Error control
– Flow control
– Multiplexing/demultiplexing
– …

45
Design Issues for the Layers (1)
• Every layer needs a mechanism for identifying senders and
receivers.
• Since a network normally has many computers, some of which have
multiple processes, a means is needed for a process on one
machine to specify with whom it wants to talk.
• As a consequence of having multiple destinations, some form of
addressing is needed in order to specify a specific destination.

46
Design Issues for the Layers (2)
• Another set of design decisions concerns the rules for
data transfer.
• In some systems, data only travel in one direction; in
others, data can go both ways.
• The protocol must also determine how many logical
channels the connection corresponds to and what their
priorities are.
• Many networks provide at least two logical channels per
connection, one for normal data and one for urgent data.

47
Design Issues for the Layers (3)
• Error control is an important issue because physical
communication circuits are not perfect.
• Many error-detecting and error-correcting codes are
known, but both ends of the connection must agree on
which one is being used.
• In addition, the receiver must have some way of telling
the sender which messages have been correctly
received and which have not.

48
Design Issues for the Layers (4)
• Not all communication channels preserve the order of
messages sent on them.
• To deal with a possible loss of sequencing, the protocol
must make explicit provision for the receiver to allow the
pieces to be reassembled properly.
• An obvious solution is to number the pieces, but this
solution still leaves open the question of what should be
done with pieces that arrive out of order.

49
Design Issues for the Layers (5)
• An issue that occurs at every level is how to keep a
fast sender from swamping a slow receiver with data.
• Various solutions have been proposed and will be
discussed later.
– Some of them involve some kind of feedback from the
receiver to the sender, either directly or indirectly, about the
receiver's current situation.
– Others limit the sender to an agreed-on transmission rate.
• This subject is called flow control.

50
Design Issues for the Layers (6)
• Another problem that must be solved at several levels is
the inability of all processes to accept arbitrarily long
messages.
• This property leads to mechanisms for disassembling,
transmitting, and then reassembling messages.
• A related issue is the problem of what to do when
processes insist on transmitting data in units that are so
small that sending each one separately is inefficient.
• Here the solution is to gather several small messages
heading toward a common destination into a single large
message and dismember the large message at the other
side.
51
Design Issues for the Layers (7)
• When it is inconvenient or expensive to set up a
separate connection for each pair of
communicating processes, the underlying layer
may decide to use the same connection for
multiple, unrelated conversations.
• As long as this multiplexing and demultiplexing
is done transparently, it can be used by any
layer.
• Multiplexing is needed in the physical layer, for
example, where all the traffic for all connections
has to be sent over at most a few physical
circuits.
52
Design Issues for the Layers (8)
• When there are multiple paths between
source and destination, a route must be
chosen.
• This topic is called routing.

53
Chapter 1 Introduction
• Switching Strategies
• Protocols
• Layering
• Reference models

54
Reference Models
• the OSI reference model
– Although the protocols associated with the OSI model are rarely
used any more, the model itself is actually quite general and still
valid, and the features discussed at each layer are still very
important

• the TCP/IP reference model


– the model itself is not of much use but the protocols are widely
used

55
The OSI reference model

56
Purpose
• The OSI model divides the functions of a protocol into a
series of layers.
• Each layer has the property that it only uses the functions of
the layer directly below, and only exports functionality to the
layer directly above.
• A system that implements protocol behavior consisting of a
series of these layers is known as a protocol stack or simply
stack.
• Protocol stacks can be implemented either in hardware or
software, or a mixture of both.
• Typically, only the lower layers are implemented in
hardware, with the higher layers being implemented in
software.

57
The Physical Layer Application
• The physical layer is concerned with transmitting raw
bits over a communication channel.
• The design issues have to do with making sure that
Presentation
when one side sends a 1 bit, it is received by the other
side as a 1 bit, not as a 0 bit. Session
– Typical questions here are how many volts should be
used to represent a 1 and how many for a 0,
– how many nanoseconds a bit lasts, Transport
– whether transmission may proceed simultaneously in both
directions,
– how the initial connection is established and how it is torn Network
down when both sides are finished,
– and how many pins the network connector has and what
each pin is used for. Data Link
• The design issues here largely deal with mechanical,
electrical, and the physical transmission medium, which
lies below the physical layer. Physical

58
The Data Link Layer Application
• The data link layer provides the
means to transfer data between Presentation
neighboring computers and to detect
and possibly correct errors that may Session
occur in the Physical layer.
Transport
• It arranges bits from the physical
layer into logical chunks of data, Network
known as frames.
Data Link

Physical

59
The Network Layer Application
• The Network Layer provides the
functional and procedural means of Presentation
transferring variable length data
sequences from a source to a Session
destination via one or more networks.
• The Network Layer performs network Transport
routing functions, and might also
perform fragmentation and Network
reassembly, and report delivery errors.
• Routers operate at this layer—sending Data Link
data throughout the extended network
and making the Internet possible. Physical
60
The Transport Layer Application
• The basic function of the transport layer
is to accept data from above, split it up Presentation
into smaller units if need be, pass these
to the network layer, and ensure that
Session
the pieces all arrive correctly at the
other end.
Transport
• Furthermore, all this must be done
efficiently and in a way that isolates the
upper layers from the inevitable Network
changes in the hardware technology. Data Link

Physical

61
The Session Layer Application
• The session layer controls the
Presentation
connections (sessions) between
computers. Session
• It establishes, manages and
terminates the connections Transport
between the local and remote Network
application.
Data Link

Physical

62
The Presentation Layer
• The presentation layer is concerned Application
with the syntax and semantics of the
information transmitted. Presentation
• It establishes a context between
Application Layer entities, in which the Session
higher-layer entities can use different
syntax and semantics, as long as the
Presentation Service understands both Transport
and the mapping between them.
• Encoding, data compression, data Network
encryption and similar manipulation of
the presentation is done at this layer
Data Link

Physical
63
The Application Layer Application
• The application layer is the OSI layer closest to the
end user, which means that both the OSI Presentation
application layer and the user interact directly with
the software application. Session
• The application layer provides a means for the user
to access information on the network through an Transport
application. This layer is the main interface for users
to interact with the application and therefore the
network.
Network
• One widely-used application protocol is HTTP
(HyperText Transfer Protocol), which is the basis for
Data Link
the World Wide Web.
Physical

64
The TCP/IP Reference Model

65
The Application Layer
• The TCP/IP model does not have session or
presentation layers since they are of little use to
most applications
• The application layer is provided by the program
that uses TCP/IP for communication.
• An application is a user process cooperating
with another process usually on a different host
(there is also a benefit to application
communication within a single host).
• Examples of applications include Telnet and the
File Transfer Protocol (FTP).

66
The Transport Layer
• The transport layer provides the end-to-end data
transfer by delivering data from an application to
its remote peer.
• Two end-to-end transport protocols have been
defined here.
– TCP (Transmission Control Protocol) is a reliable connection-
oriented protocol that allows a byte stream originating on one
machine to be delivered without error on any other machine in
the internet.
– UDP (User Datagram Protocol) is an unreliable, connectionless
protocol for applications that do not want TCP's sequencing or
flow control and wish to provide their own.

67
The Internet Layer
• also called the internet layer or the network layer
• Its job is to permit hosts to inject packets into any
network and have them travel independently to the
destination (potentially on a different network).
• The internet layer defines an official packet format and protocol
called IP (Internet Protocol).
• The job of the internet layer is to deliver IP packets where they are
supposed to go.

68
The Host-to-Network Layer
• Also called Network interface layer
• the interface to the actual network hardware
• The TCP/IP reference model does not really say
much about what happens here, except to point out
that the host has to connect to the network using
some protocol so it can send IP packets to it.
• This protocol is not defined and varies from host to
host and network to network.

69
70
The hybrid reference model
• the OSI model (minus the session and presentation
layers) has proven to be exceptionally useful for
discussing computer networks.
• In contrast, the OSI protocols have not become popular.
• The reverse is true of TCP/IP: the model is practically
nonexistent, but the protocols are widely used.

71
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP1 sends data to the application layer AP2

5 PDU=data + header 5

4 4

3 3

2 2

1 1

72
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 The application layer sends its PDU to the transport layer


5

4 PDU= PDU (al)+Header(tl) 4

3 3

2 2

1 1

73
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 The transport layer sends its PDU to the network layer 4

3 IP packet = PDU (tl)+ Header (nl) 3

2 2

1 1

74
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4

3 The IP packet is sent to the data link layer 3

2 Frame = packet + Header (dl) 2

1 1

75
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4

3 3

2 The frame is sent to the physical layer 2

1 The physical layer sends the bits stream into the physical medium 1

76
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4

3 3

2 2
The signal is transmitted in the physical medium
1 1

• 应用层 (application layer)


Physical Medium
77
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4

3 3

2 2

1 The physical layer receives the bits stream and delivers it to the upper layer 1

78
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4

3 3
Data link layer removes the frame header and trail and
2 sends the packet to the upper layer
2

1 1

79
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4

3 Network layer removes the header and send the data to the upper layer 3

2 2

1 1

80
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5
Transport layer removes the header and sends
4 the data to the upper layer 4

3 3

2 2

1 1

81
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2
Application layer removes the header and 5
5
sends the data the application process

4 4

3 3

2 2

1 1

82
Node 1 sends data to Node 2
Node 1 Node 2
I received the
AP1 data from AP1 ! AP2

5 5

4 4

3 3

2 2

1 1

83
Node 1 sends data to Node 2
Node 1 Node 2

AP1 Data AP2

5 H5 data 5

4 H4 H5 data 4

3 H3 H4 H5 data 3

2 H2 H3 H4 H5 data T2 2

1 10100110100101 bits stream 110101110101 1

84
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5

4 4
Node 2 的物理层收到比特流后
3 3
交给数据链路层
2 H2 H3 H4 H5 data T2 2

1 10100110100101 bits stream 110101110101 1

85
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2

5 5
数据链路层剥去帧首部和帧尾部后
4 把帧的数据部分交给网络层 4

3 H3 H4 H5 data 3

2 H2 H3 H4 H5 data T2 2

1 1

86
Node 1 sends data to Node 2
Node 1 Node 2

AP1 AP2
网络层剥去分组首部后
5 把分组的数据部分交给运输层 5

4 H4 H5 data 4

3 H3 H4 H5 data 3

2 2

1 1

87
Node 1 sends data to Node 2
Node 1 Node 2
运输层剥去报文首部后
AP1 把报文的数据部分交给应用层 AP2

5 H5 data 5

4 H4 H5 data 4

3 3

2 2

1 1

88
Node 1 sends data to Node 2
Node 1 Node 2

AP1 data AP2

5 H5 data 5

4 应用层剥去应用层 PDU 首部后 4


把应用程序数据交给应用进程
3 3

2 2

1 1

89
Node 1 sends data to Node 2
Node 1 Node 2
I received the
AP1 data from AP1 ! AP2

5 5

4 4

3 3

2 2

1 1

90

Das könnte Ihnen auch gefallen