Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 2 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
An example: Booking a hotel
Image: famebiography.netLund University Slide 3 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
HBP: Hotel Booking Protocol
What data needs to be exchanged to book a hotel room?
Lund University Slide 4 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
What language should we use to convey the HBP data?
Lund University Slide 5 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
How can we get the HBP data to the hotel in Sydney?
Lund University Slide 6 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
What would happen if we wanted to book a plane ticketinstead? Or used a different language? Or sent an email instead ofcalling?
Would this affect the other layers?
Lund University Slide 7 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 8 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Networking is like a cake...
Image: sweets.seriouseats.com
Lund University Slide 9 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The networking stack
Just like our hotel booking example, communicating over anetwork uses independent layers
Lund University Slide 10 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The networking stack
Not all layers are present in all parts of the network.
Lund University Slide 11 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 12 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The physical layer
The physical layer consists of the physical connection between twodevices and the modulation and coding to represent data as asignal on that connection.
Examples: Radio, optic fibre, twisted-pair cable
Images: Wikimedia commons
Lund University Slide 13 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 14 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The data link layer
The data link layer is responsible for getting data between twodevices that have a physical layer connection between them. It isalso known as the Medium Access Control (MAC) layer.
It controls when each device should use the link, and may alsoinclude error correction and retransmission.
Examples: Ethernet, Point to Point Protocol (PPP), 802.11(WiFi), Bluetooth
Images: Wikimedia commons
Lund University Slide 15 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 16 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The network layer
The network layer is responsible for end-to-end data delivery, thatis, between two devices (hosts) anywhere on the network.
It is responsible for routing and forwarding.
Examples: Internet Protocol (IP), Internet Control MessageProtocol (ICMP), routing protocols
Images: Wikimedia commons
Lund University Slide 17 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Routing and Forwarding
Routing is the process of selecting the best end-to-end paththrough a network.
Forwarding is the process of selecting the next hop for a packet.
Lund University Slide 18 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Circuit Switching vs. Packet Switching
In circuit switching, dedicated resources are allocated end-to-endfor a particular flow of data. No other flows may use thoseresources.
In packet switching, no resources are allocated to a flow, and eachflow’s data is broken up into discrete packets. Each packet isrouted and forwarded independently.
Lund University Slide 19 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Circuit Switching
Image: computernetworkingsimplified.com
Lund University Slide 20 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Packet Switching
Image: computernetworkingsimplified.com
Lund University Slide 21 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Dijkstra’s Algorithm
• Algorithm to find the shortest path through a graph• Dijkstra invented it in about 20 minutes without the aid of
pen or paper to demonstrate the capabilities of the ARMACcomputer
• Traverses through a graph, starting with an initial node, anditeratively updates estimates of the shortest paths to all othernodes
• Can either traverse the entire graph, or stop when we reachsome target node
Image: Wikimedia commons
Lund University Slide 22 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Dijkstra’s Algorithm
1. Assign tentative distance estimate to each node: 0 for theinitial node, ∞ for all other nodes
2. Mark all nodes except the initial node as unvisited. Set initialnode as current node.
3. For the current node, iterate through its unvisited neighboursand calculate their distance. Compare to the current distancevalue and take whichever is smaller as the new value.
4. Mark the current node as visited.
5. If we have reached the target node or there are no moreunvisited nodes with distance <∞, stop. Otherwise, set theunvisited node with the smallest distance as the new currentnode and go back to step 3.
Lund University Slide 23 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The Bellman-Ford Algorithm
• In Dijkstra’s algorithm, edge weights must be non-negative.
• The Bellman-Ford algorithm is also used to compute theshortest path.
• Slower than Dijkstra’s but works even with negative weightsand in cases where we do not have complete information atthe start.
• Dijkstra’s algorithm starts at the source and builds up theshortest path step-by-step. In the Bellman-Ford algorithm,first we find all shortest paths with one edge, then two edges,and so on until we have covered the whole graph.
Lund University Slide 24 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The Bellman-Ford Algorithm
1. Set the distance for the source node to 0 and for all othernodes to ∞. Set the predecessor of all nodes to null.
2. Iterate through each edge (u, v). If the distance to u, plus theedge weight, is less than the current distance to v, we havediscovered a shorter path to v. Set the distance to v to thisnew value and the predecessor of v to u.
3. Repeat step 2 N − 1 times, where N is the number of nodesin the graph. (N − 1 is the maximum length of a non-cyclicpath.)
4. For each edge (u, v) in the graph, if the distance to u plus theedge weight is less than the distance to v, the graph containsa negative-weight cycle. Terminate.
5. Otherwise, we have found the shortest paths to each nodefrom the source.
Lund University Slide 25 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Static and Dynamic Routing
• Static routing: manually configured tables• Dynamic routing
• Distance vector routing• Link state routing
• Each node has a routing table that contains the cost to eachdestination and the next hop for each.
Image: technet.microsoft.com
Lund University Slide 26 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Distance Vector Routing
• Uses the Bellman-Ford algorithm
• Nodes begin only with knowledge of their immediateneighbours and the costs to reach them.
• Nodes then send this information (the routing table)to theirneighbours.
• If a neighbour sends us a route that is shorter than one wealready have, update our table to reflect this.
• After updating, send the new table to our neighbours.
• If a node goes down, discard any lines in the routing tablethat have it as the next hop and follow the above to find anew route.
Lund University Slide 27 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Link State Routing
• Uses Dijkstra’s algorithm
• Each node floods the network with the list of nodes it canconnect to and the costs to them.
• Every node builds up a picture of the entire network, then canuse Dijkstra’s algorithm to determine the shortest path toeach destination.
• The routing table is then constructed based on the computedshortest paths.
Lund University Slide 28 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Path Vector Routing
• Both distance vector and link state routing are only usedwithin a single autonomous system (typically a network run bya single provider).
• These protocols do not scale well to large networks such asthe internet.
• Between autonomous systems, we use a variant of distancevector routing called path vector routing. Each autonomoussystem has a speaker node.
• Only speaker nodes communicate across the AS boundary,and exchange information about which destinations they canreach and the paths to them.
Lund University Slide 29 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
IP Addresses
On the internet, routing destinations are described by InternetProtocol addresses.
32 bits for IPv4, 128 bits for IPv6(e.g. 2001:db8:0:1234:0:567:8:1)
Image: www.hotspotshield.com
Lund University Slide 30 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
CIDR
• IP addresses are hierarchical. Each address belongs to ssubnet.
• Originally, the subnet part of the address had a fixed lengthdepending on the address class.
• With the introduction of classless inter-domain routing(CIDR), the subnet could be any length.
• Subnet addresses are written with a suffix indicating thenumber of bits in the subnet, e.g. 192.168.2.0/24 (IPv4) or2001:db8::/32 (IPv6).
• Destinations in a router’s routing and forwarding tables maybe full IP addresses or subnets.
• A destination IP address will then be matched to the mostspecific destination in the table when making forwardingdecisions.
Lund University Slide 31 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 32 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The transport layer
The transport layer exists only in the end hosts and is responsiblefor connection-oriented communication, multiplexing different dataflows, reliable data delivery, flow control, and congestion control.
Not all transport layer protocols provide all of these functions.
Examples: Transmission Control Protocol (TCP), User DatagramProtocol (UDP)
Lund University Slide 33 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Connection-oriented vs. connectionless communication
Connection-oriented communication means that a connection isestablished between the hosts before any data is transferred.
The connection must be maintained throughout thecommunication.
In connectionless communication, hosts can send data anytimewithout a connection.
Lund University Slide 34 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Connection-oriented vs. connectionless communication
Is the postal service connection-oriented or connectionless?
What about telephones?
What other examples can you think of?
Lund University Slide 35 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Connection-oriented vs. connectionless communication
Is the postal service connection-oriented or connectionless?
What about telephones?
What other examples can you think of?
Lund University Slide 35 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Connection-oriented vs. connectionless communication
Is the postal service connection-oriented or connectionless?
What about telephones?
What other examples can you think of?
Lund University Slide 35 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Multiplexing
A single host may have many different flows of data. These maybe from different applications or different instances of the sameapplication.
In both TCP and UDP, flows are given unique port numbers.
Some of these are standard for particular applications, e.g. port 80for HTTP (web), port 25 for SMTP (email)
The transport protocol uses the port number to deliver data to thecorrect application.
Lund University Slide 36 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Reliable data delivery
Data can easily get lost along the way between end hosts. Thiscan happen at any layer.
What are some ways data might get lost at the physical layer?
At the data link layer?
At the network layer?
How can we get reliable data delivery over an unreliablechannel?
Lund University Slide 38 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Reliable data delivery
Data can easily get lost along the way between end hosts. Thiscan happen at any layer.
What are some ways data might get lost at the physical layer?
At the data link layer?
At the network layer?
How can we get reliable data delivery over an unreliablechannel?
Lund University Slide 38 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Reliable data delivery
Data can easily get lost along the way between end hosts. Thiscan happen at any layer.
What are some ways data might get lost at the physical layer?
At the data link layer?
At the network layer?
How can we get reliable data delivery over an unreliablechannel?
Lund University Slide 38 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Reliable data delivery
Data can easily get lost along the way between end hosts. Thiscan happen at any layer.
What are some ways data might get lost at the physical layer?
At the data link layer?
At the network layer?
How can we get reliable data delivery over an unreliablechannel?
Lund University Slide 38 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Flow control
A receiving host may have limited buffer space for incomingmessages and takes time to process each message.
Flow control refers to signalling between the sender and receiver toensure the sender does not send data faster than the receiver canprocess it.
Lund University Slide 39 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Congestion control
Congestion in a network occurs when there is too much data beingsent and the network is unable to deliver it all.
This can result in data loss or long delays.
Congestion control refers to mechanisms for detecting andreducing congestion.
What are some ways end hosts could detect or reducecongestion?
Lund University Slide 40 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Congestion control
Congestion in a network occurs when there is too much data beingsent and the network is unable to deliver it all.
This can result in data loss or long delays.
Congestion control refers to mechanisms for detecting andreducing congestion.
What are some ways end hosts could detect or reducecongestion?
Lund University Slide 40 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
UDP
UDP is the simplest transport protocol. It performs multiplexingand error checking, but nothing else.
When a host wants to send data to another host, it just sends it. Ifthe data gets lost, too bad.
Lund University Slide 41 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
TCP
TCP is connection-oriented, and includes all the bells and whistles:
• Multiplexing
• Reliable data delivery
• Error detection
• Ordered data delivery
• Flow control
• Congestion control
Lund University Slide 43 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
TCP connections
TCP uses a three-way handshake to establish a connection.
Because this handshake is asymmetrical, there is a differencebetween servers and clients.
A server must have a port open, listening for clientconnections
Image: Wikimedia commons
Lund University Slide 44 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
TCP connections
A four-way handshake is used to close a connection. Each host canclose its side of the connection independently.
Image: Wikimedia commonsLund University Slide 45 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Data delivery
TCP uses sequence numbers to make sure data is complete and inorder when it is delivered.
It also includes error detection, and segments with errors areretransmitted.
Lund University Slide 47 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Flow control
Flow control in TCP uses a sliding window mechanism.
Lund University Slide 48 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Congestion control
In TCP, lost data is considered a sign of congestion and the sendershould reduce its rate.
The sender has a congestion window, which refers to the maximumnumber of unacknowledged segments that may be in transit at atime.
Lund University Slide 50 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Congestion control
A TCP connection begins in slow start, where the congestionwindow is doubled every round trip.
When a threshold is reached, it changes to congestion avoidance,where the congestion window increases by 1 maximum segmentsize each time.
When packet loss is detected, the congestion window is halved.
Lund University Slide 51 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Introduction
Networking stack
Physical layer
Data link layer
Network layer
Transport layer
Application layer
Lund University Slide 54 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
The application layer
The application layer is where data is actually generated andconsumed. It is the layer that interfaces with the user. It includesthe World Wide Web, email, instant messaging, video streaming,and any other application that communicates over the Internet.
Examples: Hypertext Transfer Protocol (HTTP), Simple MailTransfer Protocol (SMTP), Extensible Messaging and PresenceProtocol (XMPP), Skype
Images: Wikimedia commons, texascatny.comLund University Slide 55 of 57
Introduction Networking stack Physical layer Data link layer Network layer Transport layer Application layer
Headers and Footers
Each layer of the networking stack add a header and possibly afooter.
The process of adding headers and footers is called encapsulationand removing them again at the other end is called decapsulation.
Information in headers and footers includes source and destinationaddresses, checksums, packet size, and protocol identifiers.
Image: business.wikinut.comLund University Slide 56 of 57