Week10.1 Final
Week10.1 Final
Computer Networks
1
Reminder
• Course Evaluations:
https://sucourse.sabanciuniv.edu/mynotif-
tool/goToEvaluationDashboard.jsp
2
Protocol Suites
5
Switch
Switch is a link-layer device: takes an active role
• Uses MAC addresses
• store, forward frames
• examine incoming frame’s MAC address, selectively forward
frame to one-or-more outgoing links when frame is to be
forwarded on segment,
transparent: hosts unaware of presence of switches
plug-and-play, self-learning
• switches do not need to be configured
domain 5 4
3
B’ C
A’
switching: A-to-A’ and B-to-B’ can transmit
simultaneously, without collisions switch with six
interfaces
• but A-to-A’ and C to A’ can not happen
(1,2,3,4,5,6)
simultaneously
Link Layer: 6-10
Switch forwarding table
Q: how does switch know A’ reachable via
interface 4, B’ reachable via interface 5? A
C’ B
A: each switch has a switch table,
each entry: 1 2
6
(MAC address of host, interface to 3
5 4
reach host, time stamp)
looks like a routing table! B’ C
A’
Q: how are entries created,
maintained in switch table?
something like a routing protocol?
Link Layer: 6-11
Small institutional network
mail server
to external
network web server
router
IP subnet
13
Switches vs. routers application
transport
both are store-and-forward: datagram network
frame link
routers: network-layer devices physical link frame
(examine network-layer headers) physical
6-14
Link Layer: 6-14
Internet Protocol (IP)
IHL
• Routing **
• Datagram lifetime *
• Fragmentation and re-assembly
• Error control
• Flow control
• Addressing *****
Routing
• End systems and routers maintain routing tables
— Indicate next router to which datagram should be sent
• Static
— Tables do not change but may contain alternative routes
• Dynamic
— If needed, the tables are dynamically updated
— Flexible response to congestion and errors
— status reports issued by neighbours about down routers
• Source routing
— Source specifies route as sequential list of routers to be followed
— useful, for example, if the data is top secret and should follow a set of trusted routers.
• Route recording
— routers add their address to datagrams
— good for tracing and debugging purposes
Host Routing Tables
• On Windows, route print or netstat -r
to display the PC routing table
• Three sections displayed by these two
commands:
—Interface List – all potential
interfaces and MAC addressing
—IPv4 Routing Table
—IPv6 Routing Table
Router Packet Forwarding Decision
What happens when the router receives the frame from the host device?
IP Router Routing Table
port
introduction
223.1.1.1
223.1.1.4
192.168.56.8
223.1.1.2
223.1.9.2 223.1.7.0
223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.0
223.1.2.6 223.1.3.27
37
IPv4 Address Formats (RFC 791 in 1981)
223.5.9.3 = 11011111 00000101 00001001 00000011
• 32 bit global Internet address: 2^32 (4,294,967,296) possible IP addresses
• Network part and host part –
• 0 to 127
• 128 to 191
• 192 to 223
Example: dotted-decimal IP address notation
223 1 1 1
39
IP Addresses - Class A
• Start with binary 0
• 7-bit network - 24-bit host
• Range 1.x.x.x to 126.x.x.x
—10.x.x.x is for private networks
• 01111111 (127) (network part ) reserved for loopback
—Generally 127.0.0.1 is used
• Few networks - many hosts
—126 networks
—16,777,214 of hosts can be addressed
• All Class-A addresses have been allocated
IP Addresses - Class B
• Starts with binary 10
• Range 128.x.x.x to 191.x.x.x
—Second octet is also part of the network id.
—172.16.0.0 - 172.31.255.255 for private networks
Step-1 Check your IPv4 address from device settings Are they different?
Step-2 Check with Google: «My IP address» or whatismyip.com 45
Subnets
What’s a subnet ? 223.1.1.1
• To identify the network and host portions of an IPv4 address, the subnet mask is
compared to the IPv4 address bit for bit, from left to right.
mask.
255.255.255.192 11111111.11111111.11111111.11000000 /26
• Networks are most easily subnetted at the octet boundary of /8, /16, and /24.
• Notice that using longer prefix lengths decreases the number of hosts per subnet.
Prefix Length Subnet Mask Subnet Mask in Binary (n = network, h = host) # of hosts
nnnnnnnn.hhhhhhhh.hhhhhhhh.hhhhhhhh
/8 255.0.0.0 11111111.00000000.00000000.00000000
16,777,214
nnnnnnnn.nnnnnnnn.hhhhhhhh.hhhhhhhh
/16 255.255.0.0 11111111.11111111.00000000.00000000
65,534
nnnnnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh
/24 255.255.255.0 11111111.11111111.11111111.00000000
254
Subnet on an Octet Boundary (Cont.)
• In the first table 10.0.0.0/8 is subnetted using /16 and in the second table, a /24 mask.
Subnet Address Host Range Subnet Address
Host Range
(256 Possible (65,534 possible hosts per Broadcast (65,536 Possible Broadcast
(254 possible hosts per subnet)
Subnets) subnet) Subnets)
53
144.122.0.0 – Class?
• How many IP numbers?
55
144.122.0.0 – Class?
• 144.122.0.0/?
• How many IP numbers?
nnnnnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh
11111111.11111111.11111111.00000000
56
Ceng wanted to have 4 networks, solution?
• 144.122.71.0
nnnnnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh
11111111.11111111.11111111.00000000
57
Classless Addresses - (variable-length
subnet masks VLSM)
• CIDR (Classless Inter-Domain Routing)
• Extension of subnet idea to the whole Internet
• Assigning IP numbers by partitioning network and host parts at any
bit position
• A precaution against exhaustion of IP addresses
• Special notation (CIDR notation)
—network address/number of 1-bits in the mask
Routing Using Subnets (Example)
Subnet Mask:
255.255.255.224
Addresses start with 192, so class C
addresses. Last octet is for Subnet
number and Host number
224 -> 11100000 in binary last 5 bits
are for Host number, previous 3 bits
are for Subnet number
Don't forget! All zero host number
identifies the subnet and all ones is
used for broadcast on that subnet
60
Subnet within an Octet Boundary
• Refer to the table to see six ways to subnet a /24 network (e.g. 192.165.8.x)
Prefix Subnet Mask in Binary # of
Subnet Mask # of hosts
Length (n = network, h = host) subnets
nnnnnnnn.nnnnnnnn.nnnnnnnn.nhhhhhhh
/25 255.255.255.128 11111111.11111111.11111111.10000000 2 126
nnnnnnnn.nnnnnnnn.nnnnnnnn.nnhhhhhh
/26 255.255.255.192 11111111.11111111.11111111.11000000 4 62
nnnnnnnn.nnnnnnnn.nnnnnnnn.nnnhhhhh
/27 255.255.255.224 11111111.11111111.11111111.11100000 8 30
nnnnnnnn.nnnnnnnn.nnnnnnnn.nnnnhhhh
/28 255.255.255.240 11111111.11111111.11111111.11110000 16 14
nnnnnnnn.nnnnnnnn.nnnnnnnn.nnnnnhhh
/29 255.255.255.248 11111111.11111111.11111111.11111000 32 6
nnnnnnnn.nnnnnnnn.nnnnnnnn.nnnnnnhh
/30 255.255.255.252 11111111.11111111.11111111.11111100 64 2
IP addresses: how to get one?
Q: how does network get subnet part of IP address?
A: gets allocated portion of its provider ISP’s address space
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
• Using classless addresses to generate several subnetworks will also be explained in lab and you
will have a quiz on this.
63
Hierarchical addressing: route
aggregation
hierarchical addressing allows efficient advertisement of routing
information:
Organization 0
200.23.16.0/23
Organization 1
“Send me anything
200.23.18.0/23 with addresses
Organization 2 beginning
200.23.20.0/23 . Türk Telekom 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
Vodafone with addresses
beginning
199.31.0.0/16”
Hierarchical addressing: more
specific routes
Organization 1 moves from Türk Telekom to Vodafone
ISPs-R-Us now advertises a more specific route to Organization 1
Organization 0
200.23.16.0/23
Organization 1
“Send me anything
200.23.18.0/23 with addresses
Organization 2 beginning
200.23.20.0/23 . Türk Telekom 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
Vodafone with addresses
Organization 1 beginning
199.31.0.0/16”
200.23.18.0/23 “or 200.23.18.0/23”
Hierarchical addressing: more
specific routes
Organization 1 moves from Türk Telekom to Vodafone
Vodafone now advertises a more specific route to Organization 1
Organization 0
200.23.16.0/23
“Send me anything
with addresses
Organization 2 beginning
200.23.20.0/23 . Türk Telekom 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
Vodafone with addresses
Organization 1 beginning
199.31.0.0/16”
200.23.18.0/23 “or 200.23.18.0/23”
Q: How does a host get IP address within its network (host part of
address)?
hard-coded by sysadmin in config file (e.g., /etc/rc.config in UNIX)
DHCP: Dynamic Host Configuration Protocol: dynamically get address from as
server
• “plug-and-play”
DHCP: Dynamic Host Configuration Protocol
DHCP overview:
host broadcasts DHCP discover msg [optional]
DHCP server responds with DHCP offer msg [optional]
host requests IP address: DHCP request msg
DHCP server sends address: DHCP ack msg
DHCP client-server scenario
Typically, DHCP server will be co-
DHCP server located in router, serving all subnets
223.1.1.1
223.1.2.1
to which router is attached
223.1.2.5
223.1.1.2
223.1.1.4 223.1.2.9
223.1.1.3
223.1.3.27 arriving DHCP client needs
223.1.2.2 address in this network
223.1.3.1 223.1.3.2
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server!
yiaddr:Here’s an IP
223.1.2.4
transaction ID: 654
address you can use
lifetime: 3600 secs
The two steps above can
DHCP request be skipped “if a client
src: 0.0.0.0, 68 remembers and wishes to
dest:: 255.255.255.255, 67
Broadcast: OK. I would reuse a previously
yiaddr: 223.1.2.4
like to transaction
use this ID:IP 655
address! allocated network address”
[RFC 2131]
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
Broadcast: OK. You’ve
yiaddr: 223.1.2.4
got that IPID:address!
transaction 655
lifetime: 3600 secs
Network Layer: 4-72
DHCP: more than IP addresses
DHCP can return more than just allocated IP address on
subnet:
address of first-hop router for client
name and IP address of DNS sever
network mask (indicating network versus host portion of address)
10.0.0.1
138.76.29.7 10.0.0.4
10.0.0.2
10.0.0.3
all datagrams leaving local network have datagrams with source or destination in
same source NAT IP address: 138.76.29.7, this network have 10.0.0/24 address for
but different source port numbers source, destination (as usual)
NAT: network address translation
all devices in local network have 32-bit addresses in a “private” IP
address space (10/8, 172.16/12, 192.168/16 prefixes) that can only
be used in local network
advantages:
just one IP address needed from provider ISP for all devices
can change addresses of host in local network without notifying
outside world
can change ISP without changing addresses of devices in local
network
security: devices inside local net not directly addressable, visible
by outside world
NAT: network address translation
implementation: NAT router must (transparently):
outgoing datagrams: replace (source IP address, port #) of every
outgoing datagram to (NAT IP address, new port #)
• remote clients/servers will respond using (NAT IP address, new port
#) as destination address
remember (in NAT translation table) every (source IP address, port #)
to (NAT IP address, new port #) translation pair
incoming datagrams: replace (NAT IP address, new port #) in
destination fields of every incoming datagram with corresponding
(source IP address, port #) stored in NAT table
NAT: network address translation
NAT translation table
2: NAT router changes 1: host 10.0.0.1 sends
WAN side addr LAN side addr datagram to
datagram source address
138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
from 10.0.0.1, 3345 to
138.76.29.7, 5001, …… ……
updates table
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 128.119.40.186, 80 10.0.0.3
D: 138.76.29.7, 5001 3
3: reply arrives, destination
address: 138.76.29.7, 5001