Datalink and Network layers
Yuzo Taenaka
Laboratory for Cyber Resilience, NAIST
Agenda
1. Assignment follow-up
2. Datalink layer (Logical Link Control sublayer)
3. Network layer (Internet protocol)
4. Hands-on
– Network building challenge
Internet Engineering / 2019
Application
Presentation
Session
Transport
Network
Data Link
Physical
OSI 7 layer
Application
Transport
Network
TCP/IP model
Network
interface layer
Assignment 2
Capture the traffic in two scenarios on the topology you make in hands-on and answer the questions– Scenario 1: pyng from host A to B
– Scenario 2: pyng from host A to C
– Questions
• (1) Describe each field of frame header in several frames you captured in scenario 1
• (2) Describe what happens in each scenario by showing frames you captured
• (3) Describe the difference between scenario 1 and 2, and guess the reason of the difference
(4) Why CSMA/CD is not used any more? What changed by discarding CSMA/CD?
(5) Why CSMA/CA is still used?
Deadline: June 18 (Tue) 17:00, 2019
Submission: via e-mail with PDF formatInternet Engineering / 2019
Frame generated by pyng
Internet Engineering / 2019
Frame header
data just saying ”Hi“
Ethernet header + data
Follow-ups
Internet Engineering / 2019
Host A Host B Host C Host D
Scenario 1
Scenario 2
A frame (a chunk of datalink) only
reaches a host on a same datalink
but never go outside of the datalink (network)
→ network layer technology required
→ Successfully delivered
→ Nothing delivered
[FYI] Good examples
(4) Why CSMA/CD is not used any more? What changed by discarding CSMA/CD?– CSMA/CD is not being used anymore because we no longer needed it.
The mechanism is used in half-duplex ethernet in the old times where point-to-point, bus, or ring network topology still exist. Nowadays, the network cable had become full duplex, any device can communicate at any time. The computers do not need to consider the collusion anymore in wired connection. Moreover, the network cable cost has reduced such that everyone prefer reliability than cost effective approaches. Hence, network from big to small is already using the star and/or mesh network topology. This is where every device connects directly to the switch via wire. So, almost no collusion.
(5) Why CSMA/CA is still used?– CSMA/CA is still being use due to the popularity of wireless
communication, especially wireless LAN. This is where every device is forced to be mindful of every other device around it to avoid communication loss. Since communication through the air at the same time with the same frequency still cause collision. If some entity is sending data, other should wait for a random time and try again. It is still viewed as a great solution to avoid frame collusion.
Internet Engineering / 2019
Logical Link Control (LLC) sublayer
Internet Engineering / 2019
Datalink Layer
Application
Presentation
Session
Transport
Network
Data Link
Physical
OSI 7 layer
Application
Transport
Network
TCP/IP model
Network
interface layer
Data Link
IP (network)
802.3
MAC
Ethernet WLAN
LLC
802.11
MAC
Data Link Layer (LLC) Services overview
Error Detection:
– Errors caused by signal attenuation and noise
– Receiver detects presence of errors
Error Correction:
– Receiver identifies and corrects bit error(s) without resorting
to retransmission
Flow Control:
– Pacing between adjacent sending and receiving nodes
Internet Engineering / 2019
Error detection & correction
Internet Engineering / 2019
Errors in Physical Layer
Noise
Attenuation
Distortion
Internet Engineering / 2019
Internet Engineering / 2019
Error Control
Goal– Detecting and correcting transmission error in channel
• Was the frame correctly sent?
• Was the frame sequence order correct?
Techniques– Introducing the concept of frame (failure localization)
– Coding techniques
• Error Detection Code – Parity, CRC (Cyclic redundancy check)
• Error Correction Code – FEC
– Protocol techniques for error correction
• Timer
• Retransmission
Basic idea of CRC
Given:
– Polynomial expression of m bit frame M(x) (degree m-1)
– Generator polynomial G(x), of degree r (r < m)
Compute:
– prepare xrM(x): frame with r zeros → M’(x)
– Compute modulo (XOR) of M’(x) divided by G(x): R(x)
– Frame for transmission: F(x)
• F(x) = M’(x) + R(x)
Successful transmission: F(x) / G(x) = 0
– Nonzero otherwise. i.e., error detection.
– Consecutive errors less than r bits can be detected
Internet Engineering / 2019
Simplified concept: 5 mod 2 = 1, 5 + 1 = 6 → 6 / 2 = 0M(x) G(x) F(x)
Standardized CRC polynomials
Commonly known standards
– CRC-12
• x12+x11+x3+x2+x+1
– CRC-16
• x16+x15+x2+1
– CRC-32
• x32
+x26
+x23
+x22
+x16
+x12
+ x11
+x10
+x8+x
7+ x
5+x
4+x
2+x+1
– CRC-CCITT
• x16+x12+x5+1
There are many other error detection codes.
Internet Engineering / 2019
Flow control
Internet Engineering / 2019
Flow Control
Flow Control Protocols deal with how to send
sequences of frames
They have two goals:
– Recover from lost frames
– Prevent buffer overflows
Network Layer may want to receive same set of
frames in the same order they were sent
Automatic Repeat Request (ARQ)
– Stop-and-wait
– Go-back-N
– Selective-repeat
Internet Engineering / 2019
In a case without flow control
Sender sends frames at an arbitrary timing
Frames may be dropped on an intermediate media
Receiver takes time to process a frame
Internet Engineering / 2019
sender receiver
3 frames arrives while
processing 1 frame
→ buffer overflow
sender receiver
X
X
Internet Engineering / 2019
Stop-and-wait ARQ (1)
t1 t2 t3
t4
t5t1Sender
Receiver
t1: Round Trip Time
t2: Frame Transmission Time
t3: Frame Processing Time
t4: ACK Transmission Time
t5: ACK Processing Time
Internet Engineering / 2019
Stop-and-wait ARQ (2)
Procedure
– Waiting to receive ACK on each frame
transmission
– Setting a sender timer greater than
2t1+t2+t3+t4
– Retransmission when sender timer
times out.
Characteristics
– Simple
– The buffer never contains more than
one frame for the receiver and the
sender
– Very low utilization of channel capacity
Internet Engineering / 2019
Go-back-N ARQ
1 653 45432
1 653 4542
Time out for Frame3
!!
Internet Engineering / 2019
Selective-Repeat ARQ
1 873 65432
1 873 6542
Time out for Frame3
!!
ARQ: simplicity vs efficiency, adaptability
Stop-and-Wait
– Simple
– No large buffer required in both ends
Go-back-N
– Still simple, but buffer management has to be done at
SENDER.
– N means the buffer size
– There is no large buffer required at RECEIVER side.
Selected Repeat
– Efficient but complicated scheme that requires buffer, timer,
and ACK managements.
– Buffers are required in both ends.
– Window Flow Control is needed for buffer management.
Internet Engineering / 2019
Internet Engineering / 2019
Burden sharing among layers
Assignment of function depends on communication
system designs
Various solutions exist
Data Link
Network
Transport sequence assurance
flow control
retransmission
interconnection of network
error detection and correction
frame boundary
Network Layer
Internet Engineering / 2019
Application
Presentation
Session
Transport
Network
Data Link
Physical
OSI 7 layer
Application
Transport
Network
TCP/IP model
Network
interface layer
Coverage
Internet Engineering / 2019
Application
Presentation
Session
Transport
Network
Data Link
Physical
ES (End System)
Physical connection
Physical
802.11 MAC
Physical
802.3 MAC
LLC
Network
Data
Link
Physical
IS (Intermediate System)
switch
Router
Data
Link
Physical
End-to-end communication over multiple
datalinks (networks).
Application
Presentation
Session
Transport
Network
Data Link
Physical
ES (End System)
Role of internet protocol (IP)
Globally unique IP address
– Hierarchical address architecture
– Supplemental protocols such as DHCP (Dynamic host
configuration protocol) and DNS (domain name system)
End-to-end packet delivery (Routing)
– Connecting heterogeneous datalinks
– Failure recovery
1-N communication (broadcast/multicast)
Internet Engineering / 2019
How the Internet works
Internet Engineering / 2019
Network
Network
LLC
A
B
Where is B?
Network 1
Network 2
Network 3R1
R2
Network 3 → R2
Routing table:
IPv4 address
Characteristics of IP address:
It is global: uniquely identifiable worldwide
It is hierarchical: delegated to regional bodies
It has two parts: network identifier and host identifier
It has several types
Type of
address
Subspace of addresses that
are hierarchically delegated
Network Host
0xDD0xA3 0x4A 0x7F
163.221.74.127/24
163 221 74 127
Network address : 16bit
Prefix length
e.g. IPv4 address
Internet Engineering / 2019
NAIST: 163.221.0.0/16
IPv4 address space: minor exceptionsRFC 1918, RFC 3330
Internet Engineering / 2019
The Internet Assigned Numbers Authority (IANA) has reserved the
following three blocks of the IP address space for private internets:10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
0.0.0.0/8 – Addresses in this block refer to source hosts on "this” network.
127.0.0.0/8 – loopback address. A datagram sent by a higher level protocol
to an address anywhere within this block should loop back inside the host.
169.254.0.0/16 – "link local" block. It is allocated for communication between
hosts on a single link. Hosts obtain these addresses by auto-configuration,192.0.2.0/24 – "TEST-NET" for use in documentation and example code.
Addresses within this block should not appear on the public Internet.
224.0.0.0/4 – multicast address. This block, formerly known as the Class D
address space, is allocated for use in IPv4 multicast address assignments.
IPv4 address representations
Internet Engineering / 2019
1 0 1 0 0 0 1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 1 1 1
163 . 221 . 74 . 127 / 24
1 byte = 8 bit x 4 section
4 byte = 32 bit
Network address (24bit)
Decimal notation
Binary notation
Host address
hierarchical IP address assignment
Internet Engineering / 2019
163.221.0.0/16NAIST
* This is not a real scenario
163.221.0.0/18 163.221.64.0/18
LibraryAdmin. section
163.221.128.0/18
ITC
Graduate school
163.221.192.0/18
Bio Material
Information
163.221.192.0/20 163.221.208.0/20
163.221.224.0/20
JPNIC 0 0 0 0 0 0 0 0 = 0
0 1 0 0 0 0 0 0 = 64
1 0 0 0 0 0 0 0 = 128
1 1 0 0 0 0 0 0 = 192
IP address is good for routing
Internet Engineering / 2019
163.221.0.0/16NAIST
163.221.0.0/18 163.221.64.0/18LibraryAdmin. section
163.221.128.0/18
ITC
Graduate school
163.221.192.0/18
Bio Material Information
163.221.192.0/20 163.221.208.0/20 163.221.224.0/20
R3 R4
R1
R2
163.221.0.0/16
is at me.
Single information
Routing table:
163.221.0.0/18 → R2
163.221.64.0/18 → R3
163.221.128.0/18 → R4
163.221.192.0/18 → R5
R5
* Routing will be in next class, July 26
Addressing one or more nodes
Unicast– Point-to-point communication
– Specify a source and a destination address
Broadcast
Multicast– Transmission to “interested” hosts
– Interested hosts join the group
Internet Engineering / 2019
Broadcast
Broadcast– Sends data to all hosts on the same datalink
• Broadcast depends on the same capability in datalink– IP broadcast
should be mapped to:
– Link-layer broadcast
• Some datalinks don’t support broadcast
– Some hosts may not be hearing you
• Offline hosts can’t receive
• Receiver may be busy
Internet Engineering / 2019
Multicast
Multicast– Group communication; one-to-many or many-to-many
– Membership:• if a host is not a member of the group, it doesn’t receive
packets to the group
– membership management
– group management
Well-defined mapping– IP multicast, to
– Link-layer multicast
Internet Engineering / 2019
key protocol to connect network and datalink
A source terminal must ask a router to relays packets to
outside of the datalink
– How to reach the router?
→ identify the datalink address of router by address resolution protocol
(ARP)
→ a frame encapsulating an IP packet send to the datalink address
Internet Engineering / 2019
163.221.11.43
Known router
Destination
163.221.11.43ARP
ARP
ARP
Network to datalink: Address Resolution
Protocol (ARP) for IP version 4
A → B: “M”
– a → all stations (broadcast in datalink): “where is B”
– b → a: “B is at b”
– a → b: “A → B: “M””
Internet Engineering / 2019
A B C
a b c Data-link layer
Network layer
RFC 826
Network to datalink: the case of bridged or
switched networks
A → C: “M”
– a → all stations: “where is C”
– c → a: “C is at c”
– a → c: “A → C: “M””
Internet Engineering / 2019
A B
a b
C D
c d
T
t
Data-link layer
Network layer
Network to datalink: the case of routed networks
A → C: “M”
– a → all stations: “where is R”
– r → a: “R is at r”
– a → r: “A → C: “M”
Internet Engineering / 2019
r → all stations: “where is C”
c → r: “C is at c”
r → c: “A → C: “M””
A B
a b
C D
c d
Data-link layer
Network layer
R
r
A hierarchical perspective
Datalink Layer Datalink Layer
Network Layer
Datalink to Network
(demultiplexing):
Using
Ethernet II header
Network to Datalink
(multiplexing):
Using ARP
Internet Engineering / 2019
Datalink to network layer
Multiple network layer protocols are multiplexed on a
single datalink
Needed: Multiplexing, de-multiplexing
IPv4 IPv6 ....
Ethernet
IPv4 IPv6 ....
Ethernet Datalink
Network
?
Internet Engineering / 2019
Demultiplexing by DIX Ethernet header
Internet Engineering / 2019
Source address Payload (IP packet)Destination
addressType
0x0800 IPv4
0x0806 ARP
0x0809 AppleTalk
0x8191 NetBIOS
0x86dd IPv6
・・・
Example
Internet Engineering / 2019
Debugging IP
How do I know IP is nicely working over given datalink?
How do I know the IP address is correct?
Internet Engineering / 2019
ICMP: internet control message protocol
Handy for probing the Internet
without help of transport protocols
A very simple “debug function” for IP:
– Echo request
– Echo reply
Gateways may return diagnostic ICMP messages:
0 = net unreachable;
1 = host unreachable;
2 = protocol unreachable;
3 = port unreachable;
4 = fragmentation needed and DF set;
5 = source route failed.
Internet Engineering / 2019
RFC 792
End-to-end diagnostics with ICMP
ICMP echo can be used to:
– Check if the destination IP is reachable from source
– Identify faulty section in the middle
By obtaining echo reply
or other diagnostic ICMP messages
Application
Presentation
Session
Transport
Network
Data Link
Physical
Application
Presentation
Session
Transport
Network
Data Link
Physical
Internet Engineering / 2019
ICMP message
IP version 6
Internet Engineering / 2019
Unallocated IPv4 address
Internet Engineering / 2019
https://ipv4.potaroo.net
IPv4 address is only 232
IPv6 Address representations
eight groups of four hexadecimal digits (16bits)
– Totally 128bit → 2128 = 340,282,366,920,938,463,463,374,607,431,768,211,456
– Separated by “ : “
Too long → shorten address
– One or more leading zeroes can be removed
– Consecutive sections of zeroes are replaced with :: only once
Internet Engineering / 2019
2001:0200:016a:1010:0000:0000:0796:0ae7
2001:200:16a:1010:0:0:796:ae7
2001:200:16a:1010::796:ae7
2001:0200:016a:1010:0000:0000:0796:0ae7
2001::50::351 →XTwice
hexagonal notation
2001:0:0:50:0:0:0:351?
2001:0:0:0:50:0:0:351?
IPv6 address space
Internet Engineering / 2019
Usage Prefix Ratio
Reserved 00000000 1/256
...
Global Unicast 001 1/8
Unassigned 010 1/8
Unassigned 011 1/8
Unassigned 100 1/8
Unassigned 101 1/8
..
Link-Local Unicast 11111110 10 1/1024
Multicast Address 11111111 1/256
Global Unicast: It’s a pretty big address space of 2^30,
large enough to accommodate Internet of Things
Multiplexing/demultiplexing in IPv6
Datalink Layer Datalink Layer
Network Layer
Datalink to Network
(demultiplexing):
Using
Ethernet II header
Network to Datalink
(multiplexing):
Using
NDP (IPv6)
Internet Engineering / 2019
Same with IPv4 case
Network to datalink: Neighbor Discovery
Protocol for IP version 6
A → B: “M”
– A → M(B): “where is B”
– B → A: “B is at b”
– a → b: “A → B: “M””
– M() maps unicast address to solicited-node multicast
address
Internet Engineering / 2019
RFC 4861
A B C
a b c Data-link layer
Network layer
Some tricks in connecting networks
Is it so simple to connect vastly different two networks?
Internet Engineering / 2019
Fragmentation and reassembly:
adapting to diverse datalinks
Datalinks have different MTUs– MTU: Maximum Transmission Unit
Fragmentation:– Splits packets in order to fit into smaller MTU
Reassembly:– Assembles fragmented packets at the receiving host
NOTE: this applies to IPv4 only
MTU = 1520MTU = 9128
Internet Engineering / 2019
4500 1500 1500 1500
Fragmentation info in IPv4 header
Flags = {0, MF, DF}
Fragment offset: 13 bits
8 310 4 16
Ver.
Option (if any)
IHL Type of
ServiceTotal Length (in Octet)
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source Address
Destination Address
Internet Engineering / 2019
Path MTU discoverymandatory in IP version 6
Probe MTU for destination
Remember MTU
Avoid fragmentation in the middle
Internet Engineering / 2019
RFC 1981
Application
Presentation
Session
Transport
Network
Data Link
Physical
ICMP
packet too big
90009000 1500
Summary
Basic ideas of Network layer (Internet protocol)
How to make a end-to-end packet delivery
Basic concept of IPv6
Since you already got the concept, you can easily
learn the technical detail.
Internet Engineering / 2019
Assignment 3
build your own network and answer the following
questions for the network.
– (1) illustrate your network with IP address assignment
– (2) describe everything what you did to build the network and
what it was for
– (3) Prove that the multiplexing/demultiplexing between datalink
and network layers happens on your network
• You may need to send/capture packets anywhere on your network
※ You can use the network that you made at hands-on but you will get extra
score if you build a network with more complexity (you can find how to extend the
topology in the supplemental material).
Answer the questions by your own knowledge
– (4) Describe how the Internet delivers packets to a destination.
You must introduce how the datalink and network layers works
and how the headers of datalink and network layers are used.Internet Engineering / 2019
※ Note your report must be understandable to undergraduate students.
Assignment 3 (contd.)
Make the routing tables of all hosts in the below
figure on a paper and describe why so
Submit PDF via email by June 25, 2019 17:00 JST
– ※ Even if you do not finish, you should submit.
Internet Engineering / 2019