Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

157
Computer Networks An Open Source Approach Chapter 1: Fundamentals Chapter 1: Fundamentals 1

Transcript of Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Page 1: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Computer NetworksAn Open Source Approach

Chapter 1: Fundamentals

Chapter 1: Fundamentals

1

Page 2: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Content

1.1 Requirements for computer networking1.2 Underlying principles1.3 The Internet architecture1.4 Open source implementations1.5 Book roadmap: a packet’s life1.6 Summary

Chapter 1: Fundamentals

2

Page 3: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

3

1.1 Requirements for Computer Networking Definition of a computer network

A shared platform through which a large number of users and applications communicate with each other

Three requirements for data communications Connectivity: who and how to connect? Scalability: how many to connect? Resource sharing: how to utilize the connectivity?

Packet switching in datacom Circuit switching in telecom

Page 4: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.1.1 Connectivity: Node, Link, Path Another definition of a computer network

(connectivity version) A connected platform constructed from a set of

nodes and links, where any two nodes can reach each other through a path consisting of a sequence of nodes and links

Chapter 1: Fundamentals

4

Page 5: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Node: Host or Intermediary Host

End-point where users or applications reside Mainframe, workstation, desktop, hand-held, set-

top-box, etc. Act as client or server, or both

Intermediary Device to interconnect hosts Hub, switch, router, gateway, etc. Wire-speed processing is a goal Embedded system with special ICs for speedup or

cost reductionChapter 1: Fundamentals

5

Page 6: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Link: Point-to-Point or Broadcast

Point-to-point: connects exactly two nodes with one on each end Nodes transmit as they wish if it is a full-duplex link

(simultaneous bidirectional) Nodes take turns to transmit if it is a half-duplex

link (one-at-a-time bidirectional) Nodes utilize two links to transmit, one for each

direction, if it is a simplex link (unidirectional communication only)

Usually WANs (Wide Area Network)

Chapter 1: Fundamentals

6

Page 7: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Broadcast: connects more than two attached nodes Nodes attached to a broadcast link need to

contend for the right to transmit (multiple access) Usually LANs (Local Area Network)

This is because the multiple access methods used in broadcast links are usually more efficient over short distances

Chapter 1: Fundamentals

6

Page 8: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

7

Wired or Wireless Wired Twisted pair

Two copper lines twisted together for better immunity to noise

Widely used as the access lines in the plain old telephone system (POTS) and LANs such as Ethernet

A Category-5 (Cat-5) twisted pair, with a thicker gauge than the twisted pair for in-home POTS wiring, can carry 10 Mbps over a distance of several kilometers to

1 Gbps or Higher over 100 meters or so

Page 9: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

9

Coaxial cable Separate a thicker copper line from a thinner nested

copper wire with plastic shield Suitable for long-haul transmissions such as cable TV

distribution of over 100 6-MHz TV channels for an area spanning 40 km wide

Through cable modems, some channels each can be digitized at the rate of 30 Mbps for data, voice, or video services

Fiber optics Has large capacity and it can carry signals for much

longer distances Fiber optic cables are used mostly for backbone

networks (Gbps to Tbps) and sometimes for local networks (100 Mbps to 10 Gbps)

Page 10: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

7

Wireless Radio (104~108 Hz), microwave (108~1011 Hz),

infrared (1011~1014 Hz) , and beyond (ultra-violet, X ray, Gamma ray) in the increasing order of their transmission frequency

A low-frequency (below several GHz) wireless link is usually a broadcast one, which is omnidirectional

A high-frequency (over tens of GHz) wireless link could be point-to-point, which is more directional

Page 11: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

11

Wireless data communication systems (operating within 800 MHz to 2 GHz microwave spectrum) Wireless LANs (54 Mbps to 600 Mbps data transfer

rate within a 100-m radius) General Packet Radio Service (GPRS) (128 kbps

within a few km) 3G (3rd Generation, 384 kbps to several Mbps

within a few km) Bluetooth (several Mbps within 10 m)

Page 12: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Popular Wired and Wireless Link Technologies

Chapter 1: Fundamentals

8

Wired Wireless

Local Cat-5 twisted-pair Ethernet(10 Mbps ~ 1 Gbps)

2.4 GHz band WLAN(2 ~ 54 Mbps ~ 600 Mbps)

Last-mile POTS (28.8 ~ 56 kbps)ISDN (64 ~ 128 kbps)ADSL (16 kbps ~ 55.2Mbps)CATV (30 Mbps)FTTB (10 Mbps ~)

GPRS (128 kbps)3G (384 kbps ~ several Mbps)WiMAX (40 Mbps)

Leased-line T1 (1.544 Mbps)T3 (44.736 Mbps)OC-1 (51.840 Mbps)OC-3 (155.250 Mbps)OC-12 (622.080 Mbps)OC-24 (1.244160 Gbps)OC-48 (2.488320 Gbps)OC-192 (9.953280 Gbps)OC-768 (39.813120 Gbps)

Table 1.1 Popular Wired and Wireless Link Technologies

Page 13: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

13

Page 14: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

14

Page 15: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

• 802.11ac 在單一空間流 (spatial streams) 中使用不同頻寬 bandwidth 與不同調變 modulation 之理論傳輸速率 Mbps

• 若 802.11ac 使用最高 160 MHz bandwidth ,與最佳之調變 256-QAM ,在 8 個空間流 (spatial streams) 之情況下,最高可達 6.93 Gbps (=8 x 866.7 Mbps) 之理論傳輸速率

GI: Guard Interval(timing between wireless frames)

Page 16: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

16

Path: Routed or Switched?

Any attempt to connect two remote nodes must first find a path, a sequence of concatenated intermediate links and nodes, between them

A path can be either routed or switched

16

Page 17: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

17

Routed Path When node A wants to send messages to node B,

the messages are routed if they are transferred through non-preestablished and independently selected paths, perhaps through different paths

By routing, the destination address of the message is matched against a “routing” table to find the output link for the destination

This matching process usually requires several table-lookup operations, each of which costs one memory access and one address comparison

Routed path is a stateless or connectionless concatenation of intermediate links and nodes

The Internet is stateless and connectionless

Page 18: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

18

Switched path A switched path requires the intermediate nodes to

establish the path and record the state information of this path in a “switching” table before a message can be sent

Messages to be sent are then attached with an index number which points to some specific state information stored in the “switching” table

Switching a message then becomes easy indexing into the table with just one memory access

Switching is much faster than routing but at the cost of setup overhead

Switched path is a stateful or connection-oriented concatenation

Page 19: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

19

ATM (Asynchronous Transfer Mode) Has all its connections switched Before the data begins to flow, a connection along

a path between the source and the destination has to be established and memorized at all the intermediate nodes on the path

POTS (Plain Old Telephone Service) has all telephone calls switched

Page 20: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.1.2 Scalability: Number of Nodes Another definition of a computer network

(scalability version) Being able to connect 10 nodes is totally different

from being able to connect millions of nodes What could work on a small group does not

necessarily work on a huge group, we need a scalable method to achieve the connectivity

A computer network, from the aspect of scalability, must offer “a scalable platform to a large number of nodes so that each node knows how to reach any other node”

Chapter 1: Fundamentals

12

Page 21: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Hierarchy of Nodes Recursive clustering method creates a manageable tree-like

hierarchical structure Group

Each consisting of a small number of nodes Supergroup

If the groups is very large, we can further cluster these group into a number of supergroup

Super-supergroup If the supergroups is very large,

can be further clustered into super-supergroup

Chapter 1: Fundamentals

13

256

65,536

4,294,967,296

65,536

256 256 256x256 x256

X65,536

Group

Supergroup

Super Supergroup

Figure 1.1 Hierarchy of nodes grouping of billions of nodes in a 3-level hierarchy.

Page 22: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

22

LAN, MAN, WAN LAN: Local Area Network

It would be natural to form a bottom-level group with the nodes which reside within a small geographical area, say of several square kilometers

The network that connects the small bottom-level group is called a local area network (LAN)

For a group of size 256, it would require at least 256 (for a ring-shaped network) and at most 32,640 (256 x 255 / 2) point-to-point links (for a fully connected mesh) to establish the connectivity

22

Page 23: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

23

Since it would be tedious to manage this many links in a small area, broadcast links thus come to play the dominant role here

By attaching all 256 nodes to a single broadcast link (with a bus, ring, or star topology), we can easily achieve and manage their connectivity

Page 24: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

24

MAN: Metropolitan Area Network The application of a single broadcast link can be

extended to a geographically larger network, say metropolitan area network (MAN), to connect remote nodes or even LANs

MANs usually have a ring topology so as to construct dual buses for fault tolerance to a link failure

Page 25: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

25

WAN: Wide Area Network Broadcast ring arrangement has put limitations on the

degree of fault tolerance and on the number of nodes or LANs a network could support

Point-to-point links fit in naturally for unlimited, wide area connectivity

A wide area network (WAN) usually has a mesh topology due to the randomness in the locations of geographically dispersed network sites

A tree topology is inefficient in WAN’s case because in a tree network, all traffic has to ascend toward the root and at some branch descend to the destination node

If the traffic volume between two leaf nodes is huge, a tree network might need an additional point-to-point link to connect them directly, which then creates a loop in the topology and turns the tree into a mesh

25

Page 26: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

26

An internetwork made of two LANs and one WAN

Page 27: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

27

A heterogeneous network made of WANs and LANs

Page 28: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.1.3 Resource Sharing Yet another definition of a computer network (resource sharing

version) A shared platform where the capacities of nodes and links are

used to carry communication messages between nodes How to share?

Store-and-forward Put buffer space at nodes can absorb most congestion

caused by temporary data bursts Forward data message along the path toward their

destination Packetization: header information attached to the messages

to form packets Queuing: network of queues

At node: queuing/buffering and processing At link: queuing/buffering, transmission, propagation

Chapter 1: Fundamentals

15

Page 29: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Packet Switching vs. Circuit Switching Packet switching

Where message in data traffic are chopped into packets or datagrams, stored at the buffer queue of each intermediate node on the path, and forwarded along the path toward their destination

This mode of store-and-forward resource sharing is also called datagram switching

Chapter 1: Fundamentals

16

Page 30: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Circuit switching Which provides stable resource supplies and thus can

sustain quality in a continuous data stream such as video or audio signals

Not suitable for data communications where interactive or file-transfer applications

Chapter 1: Fundamentals

16

Page 31: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Packetization To send out a message, some header information must be

attached to the message to form a packet so that the network knows how to handle it

The message itself is then called the payload of the packet The header information usually contains the source and

destination address and many other fields to control the packet delivery process

Chapter 1: Fundamentals

17

Page 32: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

How large can packets and payload be ? It depends on the underlying link technologies A link has its limit on the packet length, which could

cause the sending node to transmit over the link The packet header would tell the intermediate nodes and

the destination node how to deliver and how to reassemble the packets

With the header, each packet can be processed either totally independently or semi-independently when traversing through the network

Chapter 1: Fundamentals

18

Page 33: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Packetization a MessageDecomposing a message into packets with added header

Chapter 1: Fundamentals

19

message

H H Hpacket with

headerFigure 1.2 Packetization: fragment a message into packets with added headers.

Page 34: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Queuing at a Node and a Link When a packet arrives at a node, it joints a buffer queue

with other packet arrivals, waiting to be proposed by the processor in the node

Once the packet moves to the front of the queue, it gets served by the processor, which figure out how to process the packet according to the header fields

Chapter 1: Fundamentals

20

Page 35: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

35

If the node processor decides to forward it to another data-transfer port, the packet then joint another buffer queue waiting to be transmitted by the transmitter of that port

When a packet is being transmitted over a link, it takes some time to propagate the packet’s data form one side to the other side of the link, be it point -to-point or broadcast

If the packet traverses through a path with 10 nodes and hence 10 links, this process will be repeated 10 times

Page 36: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Queuing at a Node and a Link

Chapter 1: Fundamentals

21

buffer transmitter

buffer processor

packets

node

packets

link

propagation

Figure 1.3 Queuing at a node and a link.

Page 37: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Principle in Action: Datacom vs. Telecom Datacom

Data communications or computer networking

Telecom Telecommunications

Datacom vs. Telecom Supported applications

Multiple vs. single Way to share resources

Packet switching vs. circuit switching Performance issues

Buffer vs. buffer-less Throughput / latency / jitter / loss vs. blocking / dropping

Chapter 1: Fundamentals

22

Page 38: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

38

1.2 Underlying Principles

Categories of principles Performance

Governs the quality of services of packet switching Operations

Details the types of mechanisms needed for packet handling

Interoperability Defines what should be put into standard protocols and

algorithms, and what should not

Page 39: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Performance measures Bandwidth (hardware capacity) Offered load (input traffic) Throughput (the output traffic as compared to the

offered load of input traffic) Latency (delay) Jitter (latency variation) Packet loss (due to congestion or error)

Operations at control plane Routing Traffic and bandwidth allocation

Chapter 1: Fundamentals

23

Page 40: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Operations at data plane Forwarding Congestion control Error control Quality of services (QoS)

Interoperability Standard protocols and algorithms Implementation-dependent

Unlike a protocol specification, there exists much flexibility in a protocol implementation

Not every part of an algorithms at the control and the data plane needs to be standardized

Chapter 1: Fundamentals

23

Page 41: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.2.1 Performance Measures Performance results of a system come either from

mathematical analysis or system simulations before the real system is implemented, or from experiments on a test bed after the system has been implemented

How a system performs, as perceived by a user, depends on three things The hardware capacity of the system The offered load or input traffic to this system The internal mechanisms or algorithms built into this

system to handle the offered load

Chapter 1: Fundamentals

24

Page 42: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The hardware capacity of the system The hardware capacity is often called bandwidth The referred hardware can be a node, link, path,

or even a network as whole The offered load or input traffic to this system

The offered load of a system may vary, from light load, normal operational load, to extremely heavy load (say wire-speed stress load)

Chapter 1: Fundamentals

25

Page 43: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The internal mechanisms or algorithms built into this system to handle the offered load There should be a close match between

bandwidth and offered load, if the system is to say in a stable operation

For packet switching, throughput (the output traffic as compared to offered load of input traffic) appears to be the performance measure that concerns us most, though other measures such as latency (often called delay) , latency variation (often called jitter), and loss are also important

Chapter 1: Fundamentals

25

Page 44: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Transmission Time and “Length” of a Bit Bandwidth

The maximum amount of data that can be handled by a system in a second

The number of bits transmitted and contained in the distance propagated by the signal in one second

Chapter 1: Fundamentals

26

Page 45: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Example Since the speed of light in a medium is fixed at around

2 × 108 m/sec, higher bandwidth means more bits contained in 2 × 108 m

For a transcontinental link of 6000 miles (9600 km) with a bandwidth of 10 Gbps Propagation delay

= 9600 km / (2 × 108 m/sec) = 48 ms Maximum number of bits per second contained in

the link = [9600 km / (2 × 108 m)] × 10 Gbps = 480 Mbps

Chapter 1: Fundamentals

27

Page 46: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The “width” of a transmitted bit propagating on a link varies according to the link bandwidth

Example: the bit width in a 10-Mbps link is 1/(10 × 106) = 0.1μs in time, or 0.1 μs × 2 × 108 m/sec = 20m, in length

The signal wave of one bit actually occupies 20 meters in the link

Chapter 1: Fundamentals

28

Figure 1.4 Bit width in time and length for a 10-Mbps link where the transmitted dataare encoded by the widely used Manchester code.

Speed of light in a medium = 2 × 108 m/sec

0.1μs in time, or 20m in length

Page 47: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The offered load or input traffic can be normalized with respect to the bandwidth and used to indicate the utilization or how busy the system is For a 10-Mbps link, an offered load of 5Mbps

means a normalized load of 0.5, meaning the link would be 50% busy on the average

It is possible for the normalized load to exceed 1, through it would put the system in an unstable state

Chapter 1: Fundamentals

29

Page 48: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The throughput or output traffic may or may not be the same as the offered load as shown in Figure 1.5. Ideally, they should be the same before the offered load reaches the

bandwidth (see cure A). Beyond that, the throughput converges to the bandwidth

In reality, the throughput might be lower than the offered load (see cure B) due to buffer overflow (in a node or link) or collisions (in a broadcast link) even before the offered load reaches the bandwidth

In link with uncontrolled collisions, the throughput may drop down to zero

as the offered load continues to increase (see cure C)

Chapter 1: Fundamentals30

Figure 1.5 Bandwidth, offered, load, and throughput.

Page 49: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

31

Performance MeasuresLatency in a Node

Latency (delay) in a node = queuing + processing

In queuing theory system If both packet inter-arrival time and packet service time

are exponentially distributed and the former is larger than the latter, plus infinite buffer size, the mean latency is the inverse of the difference between bandwidth and offered load

Mean latency = 1 / (bandwidth – offered load)

Page 50: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

32

Performance MeasuresLatency in a Node

Little’s Result: How many packets in the box? If the throughput equals the offered load, which means no

loss, the mean occupancy (the mean number of packets in the node) equals the mean throughput multiplied by the mean latency

Occupancy = throughput x latency (assume no loss)

1 packet/sec

mean occupancy = 5 packets

mean latency = 5 secs

1 packet/sec

Figure 1.6 Little’s result: How many packets in the box ?

Page 51: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Performance MeasuresLatency in a Link

Chapter 1: Fundamentals 33

Latency (delay) in a link

= queuing + transmission + propagation Bandwidth delay product (BDP) (Little’s result in a link or

path tells how many bits are contained in pipe in transit) Max outstanding bits in transit = bandwidth x delay The delay (L) here, is the propagation time instead of transmission or

queuing time, and is determined by the length of the link

0 1 1 0 1 1 0 1 0 1 0 1 0 0 10 0 1 0 0 1 1 1 0 0 1 1 1 1 01 0 0 1 1 0 0 0 1 0 1 1 0 1 00 1 1 0 0 0 1 1 0 1 0 0 1 0 0

L

B0 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0

L’

B’

long fat pipe short thin pipe

Figure 1.7 Bandwidth delay product: long, fat pipe vs. short, thin pipe.

Page 52: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

52

Node: Transmission Delay In a network based on packet switching,

transmission delay (or store-and-forward delay) is the amount of time required to push all of the packet's bits into the wire (This is the delay caused by the data-rate of the link)

Transmission delay is a function of the packet's length and has nothing to do with the distance between the two nodes

Transmission delay = the number of bits / the rate of transmission

Page 53: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

53

Note: Propagation Delay

In computer networks, propagation delay is the amount of time it takes for the head of the signal to travel from the sender to the receiver

It can be computed as the ratio between the link length and the propagation speed over the specific medium

Propagation delay = the distance / the wave propagation speed

53

Page 54: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Performance MeasuresJitter

Jitter: latency variation Important for continuous traffic, not for pure data Can be absorbed, by adding latency

O.K. for streaming but not for VoIP The streaming server pumps one-way

continuous traffic to clients, the perceived playout quality would be good provided the playout buffer at clients would not underflow

Chapter 1: Fundamentals

34

Page 55: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Performance MeasuresPacket Loss

Packet loss Cause 1: congestion buffer overflow Cause 2: bit errors drop

A single bit error or multiple bit errors could render the whole packet useless and hence dropped

Chapter 1: Fundamentals

35

Page 56: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

56

Bit errors Link errors: transmission errors

Many wired links now have good transmission quality with very low bit error rate

Most wireless links still have high bit error rates due to interference and signal degradation

Node errors: memory errors When packets queue in nodal buffers, bit errors

may hit the buffer memory so that the bytes read out are not the same as the bytes written in

Page 57: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.2.2 Operation at Control PlaneControl Plane vs. Data Plane

Operating a packet-switching network involves handling two kinds of packets: control and data Control packets

Carry the messages meant for directing nodes on how to transfer data packet

Control plane The set of operations for handling control packet

Data packets Enclose the message that user or applications actually

want to transfer Data plane

The set of operations for handling data packetsChapter 1: Fundamentals

36

Page 58: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Control Plane vs. Data Plane

Control plane is to maintain a platform for data plane to carry data

Key difference 1 Control plane: usually happens in background with longer

timescales, say hundreds of milliseconds (ms) to tens of seconds

Data plane: occurs in foreground with shorter timescales and more real-time, say microseconds (us) to nanoseconds (ns)

Chapter 1: Fundamentals

37

Page 59: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Key difference 2 Control plane: often requires more complex

computation per operation in order to decide, for example, how to route traffic and how to allocate resources so as to optimize resource sharing and utilization

Data plane: has to process and forward packets on the fly so as to optimize throughput, latency, and loss

Chapter 1: Fundamentals

38

Page 60: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Control Plane

The control plane of intermediary equipment needs to figure out Where to route packets (to which links or ports) Which usually requires exchange of control packets Complex route computation

The control plane may also need to deal with miscellaneous issues such as Error reporting System configuration and management Resource allocation

The control plane concerns more whether the resources have been utilized efficiently, fairly, and optimally

39

Routing Error reportingOperations at control plane

System cfg. & mgmt.

Resource allocation

Figure 1.8 Some operations at the control plane in an intermediary.

Page 61: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Routing Routing is to compute the routes and store them in tables

which are looked up when forwarding packets Routing is usually done in the background periodically, so as

to maintain and update the forwarding tables

40

Routing Error reportingOperations at control plane

System cfg. & mgmt.

Resource allocation

Figure 1.8 Some operations at the control plane in an intermediary.

Page 62: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

62

A connectionless packet-switched network

Page 63: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

63

Router components

Page 64: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

There are many questions to be answered before you come to design a routing algorithm Should the route be determined hop-by-hop at each

intermediate router or computed at the source host, i.e. source-routed ?

What is the granularity of the routing decision: per destination , per source destination, per flow, or even per packet in the extreme?

40

Routing Error reportingOperations at control plane

System cfg. & mgmt.

Resource allocation

Figure 1.8 Some operations at the control plane in an intermediary.

Page 65: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

For a given granularity, do we choose single-path routing or multiple-path routing?

Is the route computation based on global or partial information of the network?

How to distribute the global or partial information? By broadcasting among all routers or exchanging between

neighboring routers? What is the optimal path by definition? Is it the shortest, the

widest , or the most robust one? Should the router support only one-to-one forwarding or one-

to-many forwarding, that is, unicasting or multicasting?

41

Routing Error reportingOperations at control plane

System cfg. & mgmt.

Resource allocation

Figure 1.8 Some operations at the control plane in an intermediary.

Page 66: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Traffic and bandwidth allocation Traffic allocation (traffic engineering)

This option allows you to split your traffic beyond the default "divide all the traffic evenly between all variations"

Bandwidth allocation Optimization objectives?

Minimize the averaged end-to-end latency Optimal load balancing

Static planning or dynamic assignment? Other operations

Error reporting, host configuration, etc.

42

Routing Error reportingOperations at control plane

System cfg. & mgmt.

Resource allocation

Figure 1.8 Some operations at the control plane in an intermediary.

Page 67: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.2.3 Operations at Data Plane Forwarding

Lookup tables and forward packets All issues in routing! Small data structures for tables Fast algorithms for lookup and update

Classification Classify packets into classes for specific services by matching one

or several fields in the packet header against a set of rules (condition → action)

Classification speed depends on two things: the number of fields (from one to several) and the number of rules (from several to tens of thousands), and both numbers directly affect the classifier’s throughput scalability

43

Operations at data plane

Forwarding Classi-fication

Error control

Traffic control

Quality of service

Deep pkt.inspection

Figure 1.8 Some operations at the data plane in an intermediary.

Page 68: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Deep packet Inspection Both forwarding and classification examine packet header fields There are things, often malicious, hidden deep in the packet payload

For example, intrusions and viruses reside deep in the application headers and payloads, respectively

Knowledge about these contents is usually abstracted into a database of signatures, which is used to match against the payload of incoming packets. This matching process is called deep packet inspection (DPI) since it looks deep into the payload

Because the signatures are usually expressed in simple character strings or regular expressions, string matching is the key operation in DPI

44

Operations at data plane

Forwarding Classi-fication

Error control

Traffic control

Quality of service

Deep pkt.inspection

Figure 1.8 Some operations at the data plane in an intermediary.

Page 69: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Error control Error detection or correction? Hop-by-hop or end-to-end?

Traffic control Flow control

Synchronize sender and receiver (hop-by-hop or end-to-end) Congestion control

Synchronize a set of senders and the network Avoid buffer overflow / underflow Policy: low loss, high throughput, fairness

Quality of services (QoS) Policer, shaper, scheduler, etc.

44

Operations at data plane

Forwarding Classi-fication

Error control

Traffic control

Quality of service

Deep pkt.inspection

Figure 1.8 Some operations at the data plane in an intermediary.

Page 70: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

70

Policing vs. Shaping Traffic policing

When the traffic rate reaches the configured maximum rate, excess traffic is dropped (or remarked)

The result is an output rate that appears as a saw-tooth with crests and troughs

Traffic shaping Retains excess packets in a queue

and then schedules the excess for later transmission over increments of time

The result of traffic shaping is a smoothed packet output rate

Page 71: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

71

1.2.4 InteroperabilityStandard vs. Implementation-Dependent Two possible ways for various devices to talk with each other

1st: Buy all devices from only one vendor 2nd: Define standard protocols between devices so that as long as

vendors follow these protocols, we can interoperate devices bought from different vendors

For the packet handling process The parts that need standardization are the ones that affect

interoperability of devices from different vendors The formats of protocol messages certainly need to be standardized Many internal mechanisms (e.g., the data structure of a table and its

lookup and update algorithms) that do not affect the interoperability with other devices are implementation-dependent (vendor-specific), and it is often these vendor-specific designs that make a difference in the resultant performance

Page 72: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Standard protocols and algorithms Control-plane protocols

e.g. state info messages Control-plane algorithms

e.g. path computation Data-plane protocols

e.g. header Data-plane algorithms

e.g. checksum Implementation-dependent design

Control-plane algorithms e.g. path data structures

Data-plane algorithms e.g. table lookup

Chapter 1: Fundamentals

45

Page 73: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.3 The Internet Architecture

Internet has its solutions to achieving the three requirements of data communications Solutions to connectivity Solutions to scalability Solutions to resource sharing

Chapter 1: Fundamentals

46

Page 74: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.3.1 Solutions to ConnectivityRouted Connectivity Maintained at End-to-End Routing: stateless and connectionless

Stateless: means that routers do not keep any state information to track the packet streams passing

Stateless routing: all packets are routed independently without establishing paths in the intermediate routers in advance

50

Page 75: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

75

Switching is less efficient than routing for data communications in terms of space and time overhead Unlike the continuous voice traffic in telecom,

data traffic is usually bursty It would be inefficient, in terms of memory usage,

to keep the state information of a connection which is long-lived but bursty, since the state information is kept in memory for a long time but used only occasionally

Similarly, it is inefficient, in terms of initial time delay, to establish the state information for a short-lived connection, which costs large overhead for just a few packets

Page 76: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The Spectrum of “Statefulness” Figure 1.9 puts some architectures onto the

spectrum of statefulness, where the state means Table entries memorized in nodes

The mapping of (input port, incoming virtual circuit number) to (output port, outgoing virtual circuit number) in the virtual circuit table, of all passing connections

The link bandwidth reserved for streams of flows or connections

Chapter 1: Fundamentals

51

Statefulness Statelessness

Circuit Switching

Hard-StateSwitching

Hard-StateSwitching

Soft-StateSwitching Routing

POTS ATM X.25Frame Relay

MPLS Internet

Figure 1.9 the spectrum of statelessness

Page 77: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Note: POTS, ATM, IP, and MPLS POTS (Plain Old Telephone System) Hard state (HS) switching

HS: this state is created and deleted in a fully deterministic manner by cooperation among the routers

Once a host requests a session, the "network" takes responsibility for creating and later destroying the necessary state

The HS setup protocol must be reliable, with acknowledgments and retransmissions

Examples ATM (Asynchronous Transfer Mode) X.25 Frame Relay

47

Page 78: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Soft state (SS) switching SS: this regards the reservation state

as cached information that is installed and periodically refreshed by the end hosts

Unused state is timed out by the routers

MPLS (Multiprotocol Label Switching) A mechanism in high-performance

telecommunications networks that directs data from one network node to the next based on short path labels (20 bits) rather than long network addresses, avoiding complex lookups in a routing table

Use soft state mechanism to maintain resource reservation information

48

Page 79: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Stateless routing IP (Internet Protocol)

The principal communications protocol used for relaying datagrams (also known as network packets) across an internetwork using the Internet Protocol Suite

Responsible for routing packets across network boundaries, it is the primary protocol that establishes the Internet

49

Page 80: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The end-to-end argument End-to-end (only at end hosts) instead of hop-by-hop (for all links) Hop-by-hop only for performance optimization (to detect and

recover error earlier)

50

A single-layer protocol

Page 81: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

81

A three-layer protocol

Page 82: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

82

Communication through Internet

Page 83: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

83

Encapsulation / Decapsulation

Page 84: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

The 4-layer protocol stack Over a link: physical and data link layers Host-to-host: IP layer Process-to-process: TCP and UDP layers Client/server or P2P: application layer e.g. HTTP / TCP / IP / Ethernet

50

Page 85: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

85

FIGURE 1.10 (b) Packet encapsulation.

FIGURE 1.10 (a) Internet Protocol stack: commonly used protocols.

Page 86: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Internet Protocol Tree Commonly Used Protocols Figure 1.10 shows the Internet Protocol stack with

commonly used protocols The protocols marked with dotted circles are control

plane protocols, while the rest are data plane protocols TCP, UDP, and IP serve as the core protocols to support

a lot of application protocols

52

Page 87: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Internet Protocol Tree Commonly Used Protocols

Chapter 1: Fundamentals

Application-LayerProtocols

Transport-Layer protocols

Network-Layer protocols

Physical+Data Link(Type of Network)

FTP

Telnet SMTP

POP3

DNS RPC TFTP

NFS YP Mount

UDPTCP

BOOTPRARPARP ICMPIP

Wireless LANEthernet xDSL OC-3

RIP

OSPF

HTTPNNTP

DHCP

BGP

SNMP

PPP

Figure 1.10 (a) Internet Protocol stack: commonly used protocols.

Page 88: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Packet Encapsulation

An example hierarchy in this four-layer protocol stack is HTTP-TCP-IP-Ethernet, with a data payload encapsulated by the HTTP header, the TCP header, the IP header, and then the Ethernet header when transmitted

Chapter 1: Fundamentals

Page 89: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

89

Note: OSI Network Architecture

Page 90: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

90

1.3.2 Solutions to Scalability

Internet uses a subnet to denote nodes in a physical network with a contiguous address block

A physical network consists of a link, either point-to-point or broadcast, and the nodes attached to it

A subnet on broadcast link forms a LAN Which is broadcast domain Size usually depends on performance and

administration policy

Page 91: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A subnet on point-to-point link usually forms a WAN link between two routers Size of a subnet on point-to-point link is fixed at

two nodes Size of a subnet

Put too many hosts on one subnet would result in serious contention

The administration policy usually prefers a fixed size for all subnets in its management domain

A subnet of size 256 is a common setting

Chapter 1: Fundamentals

Page 92: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

92

To identify the subnet to which an IP address belongs by performing a bitwise AND operation on the mask and the IP address

subnetwork address = IP address AND subnet mask

Page 93: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Subnet IP subnet: denote nodes in physical network with contiguous

address block IP netmask: network address length IP prefix: network address

Chapter 1: Fundamentals

55

bitwise AND operation

Page 94: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

57

140 113 000 001

140 113 000 000

140 113 255 000

140 113 255 254

140 113 255 255

Subnet 140.113.0.0

with netmask 255.255.0.0

Subnet 140.113.255.0with netmask 255.255.255.0

Prefix

Prefix

256*256=65536 entries

256 entries

Figure 1.11 Subnet, netmask, prefix: segmented contiguous address blocks.

Page 95: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Autonomous system (AS, domain) Another level of hierarchy on top of subnet Many subnets within an AS Intra-AS and inter-AS routing and forwarding

If 1 AS =50 subnets, subnet size = 50 (hosts), given 50M hosts, how many ASs needed? 50M hosts / 50 = 1M subnets 1M subnets / 50 = 20,000 ASs

Chapter 1: Fundamentals

58

Page 96: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

59

140.113.136.[0-254]

140.113.137.[0-254]

140.113.138.[0-254]

140.113.173.[0-254]

140.113.177.[0-254]

140.113.200.[0-254]

140.113.209.[0-254]

CS department

140.113.142.[0-254]

140.113.143.[0-254]

140.113.144.[0-254]

140.113.147.[0-254]

EE department

140.113.149.[0-254]

140.113.152.[0-254]

140.113.153.[0-254]

MIS department

140.113.82.[0-254]

140.113.83.[0-254]

ME department

140.113.84.[0-254]

140.113.85.[0-254]

140.113.210.[0-254]

.......

.......

.......

.......

.......

(16 groups)

.......

(8 groups)

(4 groups)

(3 groups)

Supergroup: NCTU (140.113.[0-254].[0-254])

140.113.154.[0-254]

Figure 1.12 An example domain, AS, or supergroup : NCTU.

Page 97: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.3.3 Solutions to Resource Sharing Whether to differentiate the treatment of traffic from

different applications? What the resource sharing policy is? Where to put traffic control mechanism to enforce the

policy?

Chapter 1: Fundamentals

60

Page 98: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Common Best-Effort Service – IP The applications could be categorized into at least three

types Interactive applications

Generate small amounts of traffic but require timely responses

File transfer applications (ftp) Pump voluminous traffic but can tolerate higher

latency Real time applications

Have both continuous traffic volume and low latency requirements

Chapter 1: Fundamentals

61

Page 99: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

99

The Internet offers one single type of connectivity service, namely the best-effort IP service All IP packets are treated equally in sharing the

limited resources Unreliable, in terms of throughput, latency, jitter,

loss

Page 100: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

End-to-End Congestion Control and Error Recovery: TCP TCP is a polite end-to-end protocol

Regulates the outstanding bits of a packet flow from a source so that all flows can share the resources fairly

Fairly: equal outstanding bits (= Bandwidth Delay Product, BDP) for any flows

Chapter 1: Fundamentals

62

Page 101: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

TCP is a reliable end-to-end protocol that runs error recovery Reliable in terms of packet loss due to error or

congestion is recovered by TCP protocol TCP is unreliable in terms of other

performance measures such as Throughput Latency Jitter

Chapter 1: Fundamentals

62

Page 102: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.3.4 Control-Plane and Data-Plane OperationsControl-Plane Operations (for Internet) Routing

Pre-computed in background Hop-by-hop Per-destination-prefix (subnet or AS) granularity Partial or global network state info Mostly single shortest path

Error reporting Report to the source when an error occurs in

handling a packet at a router or destination ICMP (Internet Control Message Protocol) is the

protocol for error reporting

Chapter 1: Fundamentals

63

Page 103: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

103

Note: ICMP

ICMP Defines a collection of error messages that are

sent back to the source host whenever a router is unable to process an IP datagram successfully

ICMP segment structure

Page 104: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

104

ICMP header (starts at bit 160 of the IP header) Type

ICMP type Code (see the following table)

Further specification of the ICMP type e.g. an ICMP Destination Unreachable might have

this field set to 0 through 15 each bearing different meaning

Checksum Contains error checking data calculated from the

ICMP header+data

104

Page 105: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

105

ID Contains an ID value, should be returned in case of

ECHO REPLY Sequence

Contains a sequence value, should be returned in case of ECHO REPLY

105

Page 106: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

106

Page 107: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

107

185

List of Permitted Control Messages (incomplete list)

107

Page 108: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

108

186

Page 109: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

109

Page 110: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

110

170

Note: DHCP Host configuration

DHCP (Dynamic Host Configuration Protocol) is an effort to automate the configuration task to achieve plug-and-play

Though fully automatic configuration of whole network is still not possible today, DHCP frees administrators from having to manually configure the IP address and other parameters of all host machines

Page 111: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

111

170

DHCP Relies on the existence of a DHCP server that

is responsible for providing configuration information to hosts

There is at least one DHCP server for an administrative domain

At the simplest level, the DHCP server can function just as a centralized repository for host configuration information

Page 112: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

112

171

A more sophisticated use of DHCP saves the network administrator from even having to assign addresses to individual hosts DHCP server maintains a pool of available

addresses that it hands out to hosts on demand

This considerably reduces the amount of configuration an administrator must do by allocating a range of IP addresses (all with the same network number) to each network

Page 113: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

113

Application

Application

TransportNetworkData Link

Page 114: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

114

DHCP message format

Page 115: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

115

Page 116: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

116

178116

Page 117: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

117

Operation of DHCP

port: 67port: 68

Page 118: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Data-Plane Operations (for Internet) Forwarding

Forwarding a packet is actually a table lookup process Taking the destination IP address in the packet to

match against the IP prefix in table entries The IP prefix for subnet or an AS may be of any

length from 2 to 32 The entry with matched prefix contains the next-

hop information for forwarding the packet It is possible to have more than one matched prefix

if an address block is allocated to two subnets or ASs

Chapter 1: Fundamentals

65

Page 119: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Example If the address block of 140.113 is split into two

parts, 140.113.23 and the rest, and assigned to two ASs

The inter-AS forwarding table will contain two entries with prefix 140.113 and 140.113.23

When a packet destined to 140.113.23.52 is received, it will match both entries. By default, the one with the longest prefix matching (140.113.23) is followed

Chapter 1: Fundamentals

65

Page 120: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

120

Classful-IP Address Format

Page 121: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Error control Checksum in TCP and UDP

Checks against errors in the whole packet, though it can only detect a single bit error

If an error is detected UDP receiver: just drops and ignores the packet TCP receiver: acknowledges the TCP sender to ask for

retransmission

Chapter 1: Fundamentals

66

Page 122: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

122

m=16

Page 123: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Checksum in IP Protect the packet header to avoid errors in protocol

processing Does not protect the packet payload

If an error is detected at a node: the node drops the packet and sends back an ICMP packet to the source How the source handles it is implementation dependent For the purpose of efficiency, many underlying links also put

error control at the link layer, but such error control is independent of what has been done at TCP, UDP, and IP

Chapter 1: Fundamentals

66

Page 124: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Traffic control To avoid and resolve congestion, as well as to fairly share

the bandwidth resource TCP provides a fairly satisfactory solution, as discussed in

Subsection 1.3.3. UDP, on the other hand, is a wild rider that sends packets

as it wishes Although TCP traffic still dominates today in terms of traffic

volume Streaming and VoIP applications may someday push

UDP traffic to surpass TCP’s It calls for method to control UDP traffic by end-to-end

congestion and flow control similar to TCP’s (TCP-friendly)

67

Page 125: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.4 Open Source Implementations

Open vs. Closed Software Architecture in Linux Systems Linux Kernel Clients and Daemon Servers Interface Drivers Device Controllers

Chapter 1: Fundamentals

68

Page 126: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Open vs. Closed

Major components in a system Software, hardware, and IC components

Internet architecture mostly implemented in Software, and partial IC components

Chapter 1: Fundamentals

69

Page 127: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Open vs. Closed

There exist three ways to implement the Internet architecture into a system which is either a host or router Proprietary closed

For a large system vendor Third-party closed

For a small system vendor Open source

Without having to maintain a large team internally or be bound to specific component vender

Chapter 1: Fundamentals

70

Page 128: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Openness: Interface or Implementation?

What to open: interface or implementation?

Open source means open implementation Internet architecture is an open interface Linux is an open implementation IBM SNA (Structured Network Architecture) closed interface and

implementation Microsoft is a closed implementation of the open Internet

architecture

Chapter 1: Fundamentals

71

Page 129: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Openness: Interface or Implementation? Virtues to open interface

Interoperability Virtues to open implementation

World-wide contributors Fast updates and patches Better code quality

Chapter 1: Fundamentals

72

Page 130: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.4.2 Software Architecture in Linux System When converting an architecture into a real system,

several key decisions is important to identify where to implement what Where to implement the control-plane and data-plane operation? What should be implemented into the hardware, ICs, or

software? If implemented into software, which part of the software

architecture should it be?

Chapter 1: Fundamentals

73

Page 131: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Inside a Router and a Host Figure 1.13 illustrates the common operations of router. The routing

protocols (RIP, OSPF, BGP, etc.) are implemented in daemon programs (routed, gated, or zebra for advanced routing protocols), which update the routing table (also called the forwarding table) inside the kernel for the “protocol driver” to lookup. The protocol driver consist of IP, ICMP, TCP, and UDP and calls the adaptor drivers to send and receive packets. Another daemon, inetd (the super network daemon), invokes various programs for network-related services. As the arrowed lines show, packets at the control plane are processed in the protocol driver by ICMP or up in the daemon by RIP, OSPF, BGP, etc.

However, the packets at the data plane are to

be forwarded at the IP layer in the protocol driver.

Chapter 1: Fundamentals

74

Page 132: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Software Architecture in Linux Systems: Router

Chapter 1: Fundamentals

75

Routed (RIP) / gated or zebra(RIP, OSPF, BGP, etc.)

Inetd (ftp, telnet, etc.)

Kernel Space

User Space

Routing Table

up

da

te

Protocol Driver

AdapterDriver

AdapterDriver

Control Plane

Data Plane

Control Plane

Data Plane

Figure 1.13 Software architecture in Linux system: router.

Page 133: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Inside a Router and a Host Figure1.14 shows the operations of a server host machine. The

servers of various application protocols (e.g., Web, mail) are implemented in daemon programs (e.g., apache, qmail, net-snmp, etc.). The obvious difference between a host and router is that there is no packet forwarding in a host, and hence it needs only one link interface or adaptor card. For this host, most packets are data-plane packets that go up to and down from the daemon servers. The only control-plane protocol might be ICMP for error reporting

Chapter 1: Fundamentals

76

Page 134: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Software Architecture in Linux Systems: Host

Chapter 1: Fundamentals

77

Apache (HTTP) server / qmail (SMTP, POP3) server, etc.

net-snmp (SNMP) server

Kernel Space

User Space

Protocol Driver

AdapterDriver

Control Plane

Data Plane

Figure 1.14 Software architecture in Linux systems: server host.

Page 135: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Linux kernel Figure 1.15 displays the key components inside the Linux Kernel.

There are five major components: process management, memory management, file system, device control, and networking, just like any UNIX-like operating system.

Each component has two layers: hardware-independent and hardware-dependent. The hardware-independent part is in fact the drivers for disc, consoles, and adaptor cards, or CPU architecture-dependent codes and virtual memory managers for various CPU architectures.

Chapter 1: Fundamentals

78

Page 136: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Kernel Components

Chapter 1: Fundamentals

79

Figure 1.15 Kernel components.

Page 137: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Clients and Daemon Servers On top of kernel, user space processes run their user space

programs, although they occasionally invoke system calls and switch into the kernel to receive service. For network service, the socket APIs provide a set of system calls for a user-space process to communicate with another remote user-space process (through TCP or UDP sockets), generate it own IP packets (through raw socket), listen to an interface card directly (through the Data Link Provider Interface socket), or talk

to the kernel of same machine

(through the routing socket).

These sockets are illustrated

in Figure 1.16.

Chapter 1: Fundamentals

80

Page 138: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

81

Clients and Daemon ServersSocket APIs: TCP, UDP, raw, link, routing

Client

TCP

IP

MAC

PHY

routing socket

raw socket

DLPI socket

TCP/UDP socket

Server

TCP

IP

MAC

PHYInternet

Figure 1.6 Client and Daemon Servers : four socket APIs.

Page 139: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Interface Drivers Figure 1.17 shows the driver for a network interface card. The

packet receiver and parts of packet transmitter are registered as the interrupt service routine for the interface card. They are called by kernel due to hardware interrupts from the interface card. Parts of the transmitter are not registered in the interrupt service routine because it is called when the kernel has packets to transmit.

Chapter 1: Fundamentals

82

Page 140: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Interface Drivers: In and Out

Chapter 1: Fundamentals

83

kernel

driver

card

registers buffer DMA

TX TX RX

commanddatainterrupt

Figure 1.7 Interrupt-driven interface drivers: in and out

Page 141: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Device controllers Device controller usually is an integrated circuit (IC) chip

responsible for communicating with the driver Provides a set of registers for the driver to read and write

Based on the type of CPU architecture, there are two different methods to access these registers. Some CPUs provide a set of special I/O commands, e.g., in and out, For the driver to talk with the device while some reserve a range of memory

addresses for the driver to issue 1/0 commands like memory access, i.e., memory-mapped I/O.

Device controller is indeed the core of a device. Constantly monitors the device and immediately responds to the events from the

outside environment or the driver..

Chapter 1: Fundamentals

84

Page 142: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.5 Book Roadmap: A Packet’s Life (1/2) To avoid frequent data copying between these modules, a

common data structure is used to store and describe a packet, and thus each module can pass or access the packet simply by a memory pointer. In Linux, such a data structure is named sk_buff, which is defined in file sk_buff.h. An sk_buff structure is used to store one packet and its related information, e.g., length, type, or any data that are exchanged along with the packet between the network modules.

Chapter 1: Fundamentals

85

Page 143: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.5 Book Roadmap: A Packet’s Life (2/2) As shown in Figure 1.18, the structure includes many pointer variables, most of

which point to an additional fixed-size memory space where the packet is actually stored. A field name with a prefix "+" represents an offset based on the field head. The variables next and prev would link the structure with the previous and next sk_buf f so that packets in a node are maintained in a doubly linked list. The variables dev and sk indicate the network device and the socket,

Chapter 1: Fundamentals

86

Page 144: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

87

1.5 Book Roadmap: A Packet’s Lifesk_buff

nextprevdevsk....

headdata

+mac_header+network_header+transport_header

+tail+end

...

body

header

nextprevdevsk....

headdata

+mac_header+network_header+transport_header

+tail+end

...

body

header

nextprevdevsk....

headdata

+mac_header+network_header+transport_header

+tail+end

...

The sk_buff structure

Fixed size of memory space for each packet

The sk_buff structure

Figure 1.18 The doubly linked list of the sk_buff structure and some important fields in each sk_buff.

Page 145: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A Packet’s Life in a Web Server (1/3) Four packet flows often seen in a Web server are plotted in Figure 1.19. In

general, when an Internet client wants to fetch a page from a Web server, the client sends out a packet indicating the destination Web server and the requested page. Next, the packet IS forwarded by a sequence of routers to the Web server. After it is received by the network interface card (NIC) of the server, its journey in the server begins as plotted by path A. First, the NIC will decode the signal into data, which is a process covered in Chapter 2. The NIC then alerts the adapter driver to move the packet into the memory space which was allocated from the sk_buff pool by the driver in advance. By reading Chapter 3, reader can further learn the the protocols and mechanisms operated in NIC and the adapter driver.

Chapter 1: Fundamentals

88

Page 146: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A Packet’s Life in a Web Server (2/3) Once the packet is stored in a sk_buff, the adaptor driver calls and passes a

pointer to the sk_buff of the packet to the IP module's reception function. The reception function then checks the validity of the packet and hooks the packet on the IP prerouting table for security check. The table is one of the important structures used by netfilter, the firewall module embedded in the Linux kernel. The structures and operations in the IP module will be detailed in Chapter 4, with security operations left to Chapter 8. Next, the packet is pushed into the TCP module by netfilter, and Chapter 5will describe how to draw the user data out of the packet in a sk_buff, do error control, and pass it to the application program, the data, which is payload of the packet, has to be duplicated from the kernel memory to the user memory. Meanwhile, based on the header of the received packet, the TCP module builds the ACK packet, which is then transmitted along path B, The ACK passes down through the TCP module, IF module, adaptor driver, NIC, and network path, and arrives at the client side. Thus, the client side is assured that the request for the desired Web page has been successfully delivered to the Web server.

Chapter 1: Fundamentals

89

Page 147: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A Packet’s Life in a Web Server (3/3) In the meantime, the Web server, covered in Chapter 6, processes the

request in its socket data structure, which was duplicated from the TCP module, generates the response and sends it via the socket interface. The response passes through the TCP and IP modules as indicated by path C, being encapsulated with the protocol headers and maybe fragmented into multiple packets when leaving the IF module for transmission through the Internet. Finally, the space allocated to the packet will be released back to the sk_buf f pool. Later when the Internet client receives the response, its TCP module sends back a TCP ACK to the TCP module of the Web server, which goes through path D to confirm that the response has been successfully delivered to the Internet client.

Chapter 1: Fundamentals

90

Page 148: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

91

Book Roadmap Packets’ Life in a Web Server Web server

TCP

NICch2/ch3

hub

IPv4

sk_buffpool

Socket

Web Server

dro

p if

fa

il

Write ReadUse

r S

pace

Ker

nel

Spa

ce

ch4net/ipv4/*

ch3drivers/net/*

ch5net/ipv4/*

ch6Apache

TX

RX

Adapter Driver

Rcv DataSnd ACK

Request Handling Process

Rcv ACKSnd DATA

Build&Snd Responses Rcv Requests

AB DC

Get space for the receiving

freeReturn space after trans.

cp.cp.

A: incoming packet with the user req. B: TCP ACK for Packet A, C: web resp. to the req. embedded in A D: TCP ACK returned from the user for Packet C

version, len, and error chk

A

add IP header

BD AC

C

Calc. chksum

hook on ip prerouting table

Congestion Control

Error Control

Figure 1.19 Life of four packets in Web server.

Page 149: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Performance Matters: From Socket to Driver within a Server The tests are repeated to obtain the average consumed CPU time

of each protocol layer with significantly larger time eclipse than the average consumed CPU time are not counted to exclude the effect of context switching and interrupt handling

The consumed CPU time can be deconstructed into two parts The first part, RX, describes the time measured from receiving a packet by the

device driver in the link layer, processing the packet in the IP and transport layers, and delivering it to the user space

The second part, TX, depicts the time spent in each protocol layer in the kernel space to process an outgoing packet coming from the user-space server program

Chapter 1: Fundamentals

9292

Page 150: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Performance Matters: From Socket to Driver within a Server

Chapter 1: Fundamentals

93

Total time: 34.18μs

93

Figure 1.20 CPU time from socket to driver within a server.

Page 151: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A Packet’s Life in a Gateway (1/3) A router or a gateway usually has no TCP or upper-layer modules except some

daemons for routing and security functions, but it would have forwarding, firewall, and QoS functions turned on in the kernel, as we can see in Figure 1.21. Upon receiving a packet from the intranet, as indicated on Figure 1.21, the gateway may first verify its correctness and then check the pre-routing table 10 determine whether to forward the packet into the Internet. For example, if the functionality of transparency proxy is enabled in the gateway, then a packet of a URL request, instead of being sent to the actual website, may be redirected to a local Web proxy to seek the cached pages, as a proxy addressed in Chapter 6.

Chapter 1: Fundamentals

94

Page 152: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A Packet’s Life in a Gateway (2/3) Then it makes its forwarding or routing decision by checking the forward chain, i.e.,

forwarding table or routing table, with a remote destination lP address; this process is illustrated in Chapter 4. Because of security considerations and lack of IP address, a gateway might provides the network address translation (NAT) function of having a public IP address shared by all hosts in the internet. For NAT function, when the out going packets pass through the post-routing module, their source address may be replaced, which is commonly called IP masquerading, also covered in chapter 4. finally, a packet might be the attached to tag in the prerouting module to distinguish the packet’s service class and priority in forwarding with bandwidth reservation on the output link, which is managed by the traffic control module introduced in chapter 7.

Chapter 1: Fundamentals

95

Page 153: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

A Packet’s Life in a Gateway (3/3) On the other hand, for a packet coming from the Internet as indicated on Figure 1.21,

since it would be checked to see if it contained malware from the hosts in the Internet, the packet could be duplicated from the normal forward chain to the intrusion detection module for log analysis and detection. SNORT is such a software module. It will be introduced in Chapter 8 along with several other modules that offer the security functions. If the packet is addressed to a local process, say a routing daemon covered in Chapter 4, it goes through the input chain and up to the daemon. Again, the daemon may send its packets out through the output chain.

Chapter 1: Fundamentals

96

Page 154: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Book Roadmap A Packet’s Life in a Router

Chapter 1: Fundamentals

97

hub

router

IPv4

NIC 2ch2/ch3

TX Adapter Driver

Ker

nel

Spa

ce

ch4

ch3

NIC 1ch2/ch3

RXAdapterDriver

check input chain

check ouput chain

check forward chain

to local process

check prerouting table for (1) transparency proxy(ch6) & (2) flow classification(ch7)

host

check post routing for ip

masquerading

version, len, and error chk

makerouting

decision

TXRX

Log and detect Intrusion by Snort (ch8)

Use

r S

pace

Dest. IP is local

Dest. IP isn’t local

Src. IP is local

traffic control (ch7)

gateway

Routing by Zebra (ch4)

Figure 1.21 A packet’s life in a gateway.

Page 155: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Figure 1.22 shows the CPU time spent in processing a packet within a router. Here the DMA time is one exception. It is actually the time eclipse instead of the consumed CPU time. All other times are consumed CPU times. The PC based router has an Intel Pro/100 Ethernet adaptor and a 1.1 GHz CPU.

Chapter 1: Fundamentals

98

Performance Matters: From Input Port to Output Port within a Router

Page 156: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

Chapter 1: Fundamentals

99

Performance Matters: From Input Port to Output Port within a Router

Total time: 29.14μs

Figure 1.22 CPU time from inputto output within a router.

Page 157: Computer Networks An Open Source Approach Chapter 1: Fundamentals 1.

1.6 Summary

From requirements and principles to solutions and implementations

Key concepts: switching, routing, stateless, soft-state, best-effort, data plane, and control plane

Two biggest design decisions the end-to-end argument stateless, best-effort IP,

reliable/polite TCP three-level hierarchy good scalability

The evolving hourglass Single IP technology + many links + huge applications

Chapter 1: Fundamentals

100