Network Fundamentels
Network Fundamentels
F U N DA M E N TA L S
Session1
2.1.4 Encapsulation
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Payload p
s
u
L
l
Network a
y
Header Payload a
t
e
i
r
o
Data Link s Header Payload
n
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Header Payload p
s
u
L
l
Network a
y The application layer gives a
t
e its packet to the transport i
r
layer, which adds its own o
Data Link s
header.
n
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Payload p
s
u
L
l
Network a
y The application packet is a
t
e now the transport i
r
protocol's payload. o
Data Link s
n
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Payload p
s
u
L
l
Network a
y
Header Header Payload a
t
e
i
r
The same technique is used o
Data Link s
by the following layers. n
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Payload p
s
u
L
l
Network a
y
Header Payload a
t
e
i
r
o
Data Link s
n
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Payload p
s
u
L
l
Network a
y
Header Payload a
t
e
i
r
o
Data Link s Header Header Payload
n
Application L
o
Header Payload
E
n
c
w
a
e
Transport r Header Payload p
s
u
L
l
Network a
y
Header Payload a
t
e
i
r
o
Data Link s Header Payload
n
Application L
o
Encapsulation Header Payload
E
n
w
headers c
a
e
Transport r Header Header Payload p
s
u
L
l
Network a
y
Header Header Header Payload a
t
e
i
r
o
Data Link s Header Header Header Header Payload
n
Internet Protocol
(IP)
73.5.12.132
73.5.12.132
First Second Third Fourth
This does not mean that you can assign any address
starting from 0.0.0.0 to 255.255.255.255 to a host. Some
addresses are reserved for special purposes.
You can find the details about the special use of IPv4
addresses in RFC5735.
http://tools.ietf.org/html/rfc5735 PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.43
2.2.3 IP/Mask
IP address: 192.168.5.100
Subnet mask: 255.255.255.0
192.168.33.12/255.255.224.0
11000000.10101000.00100001.00001100
255.255.224.0
11111111.11111111.11100000.00000000
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.46
2.2.3.1 IP/Mask CIDR Example
IP: 11000000.10101000.00100001.00001100
&
Mask: 11111111.11111111.11100000.00000000
=
Network: 11000000.10101000.00100000.00000000
11000000.10101000.00100001.00001100
255.255.224.0
11111111.11111111.11100000.00000000
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.50
2.2.3.2 IP/Mask Host Example
¬(11111111.11111111.11100000.00000000)
=
00000000.00000000.00011111.11111111
IP: 11000000.10101000.00100001.00001100
&
¬Mask: 00000000.00000000.00011111.11111111
=
Host: 00000000.00000000.00000001.00001100
• 10.54.12.0/24 (10.54.12.0/255.255.255.0)
• Contains 28 = 256 addresses
• 192.168.114.32/27 (192.168.114.32/255.255.255.224)
• Contains 25 = 32 addresses
http://www.subnet-calculator.com/
http://www.subnet-calculator.com/cidr.php PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.59
2.2.7 IPv6
2001:0db8:0020:130F:0000:0000:087C:140B
2001:0db8:0:160F::850C:140B
For example:
• ::1/128 is a loopback address
• ::FFFF:0:0/96 are IPv4 mapped addresses
1111111111111111.1111111111111111.11111111111111
11.0000000000000000.0000000000000000.00000000000
00000.0000000000000000.0000000000000000
Subnetting Range
The 16 bits from the 49th to the 64th are for defining
subnets.
0000000000000000.0000000000000000.00000000000000
00.1111111111111111.0000000000000000.00000000000
00000.0000000000000000.0000000000000000
0000000000000000.0000000000000000.00000000000000
00.0000000000000000.1111111111111111.11111111111
11111.1111111111111111.1111111111111111
In the above IPv6 address, the number after the slash (64)
is the number of bits that is used for a prefix. Everything
behind it can be used for hosts of the subnet.
As you may have noticed, /64 means that the first 64 bits
are a prefix. And, as previously mentioned earlier, each 4-
digit hex word is 16 bits, thus in following IPv6 address we
can divide it as such:
2001:1234:5678:1234:0000:0000:0000:0000 is a valid
prefix, but it can be shortened by omitting zeros, into
following form:
2001:1234:5678:1234::/64
In this section, you will see how the transport layer works,
and how the application layer uses its services to identify
server and client processes.
TCP UDP
Lower throughput Better throughput
Connection-oriented Connectionless
Does not guarantee packet
Guarantees delivery
delivery
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.164
2.5.1 Ports
In this example, ‘A’ communicates with the web server using 3028 as
the source port...
But, how can you know the right port for a common
service?
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.175
2.5.2 Well-known Ports
Ports in the ranging from 0-1023, the first 1024 that is, are
called well-known ports and are used by servers for the
most common services.
You do not need to know all the service port assignments, but
you should at least remember the most common, such as:
• SMTP (25) • SFTP (115)
• SSH (22) • Telnet (23)
• POP3 (110) • FTP (21)
• IMAP (143) • RDP (3389)
• HTTP (80) • MySQL (3306)
• HTTPS (443) • MS SQL Server (1433)
• NETBIOS (137, 138, 139)
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.178
2.5.2 Well-known Ports
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
TCPView shows:
• Process name • Local and remote ports
• PID • State of the connection (if
• Protocol applicable)
• Local and remote addresses
0 1
The header fields involved in 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
the handshake are: | Source Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
• Sequence number | Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
• Acknowledgement | Acknowledgment Number |
numbers +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F|
• SYN and ACK flags | Offset| Reserved |R|C|S|S|Y|I|
| | |G|K|H|T|N|N|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
Time Time
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.189
2.5.5 TCP Three Way Handshake
Time Time
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.190
2.5.5 TCP Three Way Handshake
Time Time
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.191
2.5.5 TCP Three Way Handshake
Time Time
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.192
2.5.5 TCP Three Way Handshake
SYN/ACK
Note that the client Seq: 498 Ack: 330
Time Time
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.193
2.3
Routing
The table can also contain an entry with the default address
(0.0.0.0). This entry is used when the router receives a
packet whose destination is an unknown network.
IP Netmask Interface
228.72.0.0 255.255.0.0 1
192.168.5.0 255.255.255.0 2
0.0.0.0 0.0.0.0 3
In fact, the first entry in the routing table does not match
the destination network.
IP Netmask Interface
228.72.0.0 255.255.0.0 1
To: 192.168.5.3 192.168.5.0 255.255.255.0 2
0.0.0.0 0.0.0.0 3
IP Netmask Interface
228.72.0.0 255.255.0.0 1
192.168.5.0 255.255.255.0 2
To: 192.168.5.3 0.0.0.0 0.0.0.0 3
IP Netmask Interface
228.72.0.0 255.255.0.0 1
192.168.5.0 255.255.255.0 2
0.0.0.0 0.0.0.0 3
To: 72.13.37.2
A packet arriving on
interface 3 for
11.32.3.118 is routed
through interface 1, as
the metric for that route
is 15.
Routing through
interface 2 would have a
metric of 17.
PTSv4: Section 1, Module 2 - Caendra Inc. © 2019 | p.97
2.3.3 Checking the Routing Table
root@host:~# ip route
default via 192.168.51.1 dev eth0 proto static
192.168.51.0/24 dev wlan0 proto kernel scope link src 192.168.51.123
C:\Users\User>route print
===========================================================================
Interface List
11...08 00 27 bf ac c8 ......Intel(R) PRO/1000 MT Desktop Adapter
1...........................Software Loopback Interface 1
===========================================================================
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.51.1 UGSc 13 0 en1
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 1 16 lo0
169.254 link#4 UCS 0 0 en1
192.168.51 link#4 UCS 4 0 en1
192.168.51.1 58:6d:8f:e5:e:d2 UHLWIir 14 24 en1 1200
192.168.51.109 2:f:b5:4b:76:cf UHLWIi 0 0 en1 1148
• MAC spoofing
• Testing switches security
• Sniffing techniques
• Man in the middle attacks
00:11:AA:22:EE:FF
The router will then take the packet and forward it to B's
network, rewriting the packet's MAC addresses:
• The destination MAC address will be B's
• The source MAC address will be the router's
You need to know his or her home address (IP address) and
the address of the nearest post office (MAC address)
where you can drop the letter.
FF:FF:FF:FF:FF:FF
192.168.2.0/24 10.10.0.0/16
The TTL determines how long an entry will stay in the table.
This is important because the CAM table has a finite size.
To forward a packet:
•1 The switch reads the destination MAC address of the
frame.
•2 It performs a look-up in the CAM table.
•3 It forwards the packet to the corresponding interface.
•4 If there is no entry with that MAC address, the switch will
forward the frame to all its interfaces.
When a host (A) wants to send traffic to another (B), and it only
knows the IP address of B:
1. A builds an ARP request containing the IP address of B
and FF:FF:FF:FF:FF:FF as destination MAC address.
This is fundamental because the switches will forward the
packet to every host.
2. Every host on the network will receive the request.
3. B replies with an ARP reply, telling A its MAC address.
FF:FF:FF:FF:FF:FF
11:22:33:44:55:66
192.168.7.9 is at
77:88:99:AA:BB:CC
11:22:33:44:55:66
‘A’ will save the IP – MAC binding in its ARP cache. Further
traffic to ‘B’ will not need a new ARP resolution protocol
round.
ARP cache entries have a TTL too, as the size of the device
RAM is finite. A host discards an entry at the power off or
when the entry's TTL expires.