Cybersecurity Essentials: Networking
Cybersecurity Essentials: Networking
Networking
201: TCP/IP Networking Model is the second in a series of courses that explain how
networks operate and some of the cybersecurity issues they exhibit.
October 2019
Version: 1.0
© 2019 Sophos Limited. All rights reserved. No part of this document may be used or
reproduced in any form or by any means without the prior written consent of Sophos.
Sophos and the Sophos logo are registered trademarks of Sophos Limited. Other names,
logos and marks mentioned in this document may be the trademarks or registered
trademarks of Sophos Limited or their respective owners.
While reasonable care has been taken in the preparation of this document, Sophos makes
no warranties, conditions or representations (whether express or implied) as to its
completeness or accuracy. This document is subject to change at any time without notice.
This course is designed for technical professionals who want to understand how the layers of
a TCP/IP network work together to support communication.
If you are unsure about any of these topics we recommend Sophos Cybersecurity Essentials
101: Getting Started with Networking.
Activities are suggested throughout the course that allow you to try the
techniques described
Use the Download Activity button to open instructions for a single activity
Activities are suggested throughout the course that allow you to try the techniques
described. You can complete these during the course or at a later time.
Each activity slide will include a button that opens a PDF containing instructions for that
activity. Instructions for all activities can be opened by selecting the file from the
RESOURCES menu. Instructions are also included at the back of the Student Handout.
Activities later in the course may rely on the completion of earlier activities.
The instructions are written for Windows computers but the notes will indicate where
alternatives are available for Mac or Linux.
2
Data Link Layer 3 Network Layer
5
4
Transport Layer Application Layer
Networks allow us to communicate and share; they are an essential part of our working and
social lives. The benefits they offer are huge but so are the potential security risks.
In this course you will learn how each layer of TCP/IP networking operates and supports
communication between hosts and their applications.
Network Models
Internet
Students who completed our 101: Getting Started with Networking course learned that a
network includes many components, ranging from the application which requires network
access to the wired or wireless communication mechanism connecting the devices to it.
Networking models are used to provide a clear explanation of how the various components
work together to support network communication.
Application Application
Presentation Presentation
Network models
Session divide networks into Session
Transport layers based on Transport
Network functions Network
Data Link Data Link
Physical Physical
9
In the early 1970s, the International Organization for Standardization (ISO) began defining a
set of rules which could be used by the manufacturers of networking components, whether
hardware or software, to ensure that the components from different manufacturers would
interoperate successfully. In the 1980s, this standard was published as the Open Systems
Interconnect (OSI) model.
The OSI model is made up of 7 layers. Each of these layers is responsible for a specific set of
tasks within the network communication process.
In the example shown, the workstation is sending a request to the server. Network
communication begins at the application layer of the workstation, where the request
message is passed down through the various layers until arriving at the physical layer. There
it is placed on the communication medium for transfer across the network to the
destination server. On arrival at the server, the message works its way back up the 7 layers
until reaching the application layer of the server where the original request is processed. The
server will send a response back to the workstation using the same procedure in reverse.
Each layer of the OSI model is responsible for handling one or more of the functions which
are required to pass a message across a network or networks. The main functions of each
layer are as follows:
• Layer 7 - Application – this layer handles interactions with any application requiring
network access
• Layer 6 - Presentation – this layer handles any transformation of data which is needed
because of the different requirements of the application and the network
• Layer 5 - Session – this layer initiates, manages and terminates the connections between
the local and remote applications
• Layer 4 - Transport – this layer is responsible for ensuring delivery of data across a
network
• Layer 3 - Network – this layer adds network addressing to the data and decides how to
route it across a network or networks
• Layer 2 - Data Link – this layer handles data transfer between two devices on the same
network
• Layer 1 - Physical – this layer specifies how the digital bits are converted into signals and
placed on the “wire”
Each layer is responsible for communicating with the layer above it and the layer below it.
For example, the network layer will receive information from the transport layer. It adds
network addressing, determines route selection, and then passes it down to the data link
layer.
Application Application
Transport Transport
Network Network
Data Link Data Link
Physical Physical
11
Like the OSI model, the TCP/IP (Transmission Control Protocol/Internet Protocol) model
began development in the early 1970s and was published in the 1980s as a standard called
RFC 1122. It was developed by the Defense Advanced Research Projects Agency (DARPA)
which is the part of the US Department of Defense (DoD) and responsible for developing
technologies for military use.
In the 1990s, network equipment manufacturers moved away from proprietary networking
models and instead began to favour the TCP/IP model. The TCP/IP model has become the
firm favourite for all network communication.
The model originally consisted of only four layers, however it was later updated with the
original bottom “link” layer now commonly divided into data link and physical layers as
shown.
Note: If you’d like to know more about the Request for Comment (RFC) documents that
define how the Internet operates see https://en.wikipedia.org/wiki/Request_for_Comments
Application Application
Transport Transport
Network Network
Data Link Data Link
Physical Physical
12
Let’s follow what happens at each layer of the TCP/IP model using an example of browsing
to a web server. Each of these layers will be covered in detail in later sections.
• Application Layer – makes an HTTP request from the browser and prepares it for
transmission to the destination web server. Preparation may include encryption and
compression. It then passes the data to the transport layer.
• Transport Layer – receives the data from the application layer and breaks it into
segments or datagrams of suitable size. This layer ensures delivery by handling error-
checking, error correction and flow control. It then passes the segment or datagram to
the network layer.
• Network Layer – is responsible for delivering the data across one or more networks. It
achieves this by placing the segment or datagram into an IP packet which contains
source and destination IP addresses. The IP packets are then passed the data link layer.
• Data Link Layer – this layer moves data between physically connected hosts on the
same network. It places the IP packet into a frame which has headers for source and
destination hardware addresses. The frame is then passed to the physical layer.
• Physical Layer – this layer converts the frames into bits and then converts the bits into
the appropriate type of signal for transmission over the network media.
7. Application
Network Models
5. Application 6. Presentation
5. Session
4. Transport 4. Transport
3. Network 3. Network
2. Data Link 2. Data Link
1. Physical 1. Physical
13
The original TCP/IP model combined layers 1 and 2 as the Link layer, with the layer above
this named the Internet layer. Since this was published, there have been significant
developments in the technologies and standards used in these layers. For example, fiber
optics and wireless media are now commonly used at layer 1 and faster more efficient
networking technologies have been developed for layer 2. The current model differentiates
the functions and also more closely aligns to the OSI model. The Internet layer is now
generally referred to as the network layer and this is the description we will use in this
course.
The OSI model provides a useful theoretical analysis of network traffic but it is the TCP/IP
model that has been practically implemented in numerous pieces of network equipment.
We will use this model in the following sections.
and routing
As we have described, each layer of the TCP/IP networking model is responsible for a
specific set of tasks within the network communication process. In this question, you can
match the layer of the TCP/IP model to the function it provides.
15
Packet capture tools provide a way to view the layers of the TCP/IP model. These tools are
pieces of hardware or software which are used to capture and analyse the network traffic.
The tools are variously known as “packet sniffers”, “packet analyzer”, “protocol analyzer” or
“network analyzer”.
When looking into network issues, it can be extremely useful to be able to capture and
analyze the network signals. The tools can also be used to perform network audits and to
detect network attacks.
Sniffers work by examining streams of data packets that flow between computers on a
network as well as between networked computers and the Internet. Although packets are
usually addressed to specific machines, using a packet sniffer in "promiscuous mode" allows
it to examine any packet, regardless of destination. It's possible to configure sniffers in two
ways. The first is "unfiltered," meaning they will capture all packets possible for later
examination. The other option is "filtered" mode, meaning analyzers will only capture
packets that contain specific data elements.
Packet sniffers can be used on both wired and wireless networks. On a wired network,
sniffers might have access to the packets of every connected machine or may be limited by
the placement of network switches. On a wireless network, most sniffers can only scan one
channel at a time, but the use of multiple wireless interfaces can expand this capability.
Read the information and follow the instructions to advance to the next step.
Start
Wireshark is a widely used packet capture tool. This simulation shows how Wireshark can be
used to capture and save network traffic.
Read the information and follow the instructions to advance to the next step.
Continue
35
36
As you saw in the packet capture simulation, network communication operates in layers.
Each layer has a name for the type of data it transfers; for example, at the network layer the
data structure is known as a Packet whilst at the data link layer it is called a Frame.
The layers are said to form a Network Stack because of the way they are positioned one
above the other.
Layer 2 - Frame
Layer 3 - Packet
Layer 4 - Segment
Layer 5 - Application Data
37
Wireshark does not show the physical layer but has captured the main data structures, from
the data link layer upwards. It has the ability to look in detail at the data structures and
analyse their type.
• In layer 3 the packet is shown as Internet Protocol Version 4 (IPv4). IPv6 packets may also
be found at layer 3.
• In layer 4 the Segment is shown as Transmission Control Protocol (TCP). The User
Datagram Protocol (UDP) datagram structure can also be used at this layer
• In layer 5 the application data is designated as Hypertext Transfer Protocol (HTTP). Other
forms of application data will be covered in the application layer section of this course
including; Domain Name Service (DNS) and Simple Mail Transfer Protocol (SMTP)
The image shows how the original data from the Application layer is ‘wrapped’ with extra
information from the layers below, which allow it to be sent to its destination.
Router
Laptop
Tablet
Attacker
Computer Printer
38
Packet capture tools are not only useful for IT professionals; they can also allow malicious
intruders to capture and examine network traffic. This may contain confidential information
and credentials that can be used to gain further access. Part of the solution is to prevent
unauthorized access to the network by using secure wireless passwords and by disabling un-
used network ports.
HTTPS
Cybersecurity Essentials:
Cryptography
39
The best protection against malicious use of packet capture tools is encryption. For example,
using HTTPS, the secure version of HTTP, will prevent packet sniffers from seeing the traffic
on the websites you are visiting. It is also important not to use applications that use insecure
protocols, such as File Transfer Protocol (FTP) which transfers the user name and password
as clear text. Like HTTP, there is a secure version of this protocol.
If you want to learn how cryptography protects data, Sophos offers the Cybersecurity
Essentials: Cryptography program.
40
Bits 0101010
Physical Layer
5. Application
4. Transport
Signal
3. Network
2. Data Link
1. Physical
41
We will now look in detail at layer 1 of the TCP/IP model, which is the physical layer.
Layer 1 connects directly to the network media. It converts the digital bits of the frame into
an appropriate signal which is placed on the “wire” for transfer from one host to another. A
process known as modulation is used to convert the digital bit stream to a signal that’s
suitable for the network.
The type of signal depends not only on the specific network technology but also on the
network media, for example, electrical signals are used on copper-based cables, light signals
are used on fibre-optic cables and radio signals are used on wireless networks.
Or
42
These days a user may choose either a wired or wireless method for connecting to a
network. The choice will require suitable network infrastructure devices, network interface
cards and network media that transmits signals across the network.
43
Connecting devices to a network using some form of cabled or wired connection provides
high speed, reliable connectivity. The cables used in networks can be divided into two
separate groups: copper and fiber-optic. Copper cables are typically used with homes and
offices.
The most popular type of copper-based cabling used in networks is known as Twisted Pair. A
twisted pair cable consists of 8 insulated copper wires. As shown in the figure above, each
colour-coded pair of wires are twisted together and then surrounded by a protective plastic
jacket. Over recent times, there have been numerous different variations of twisted-pair
cabling. In order to assist network installers with selecting the correct cable, the cabling
vendor’s have developed various grades which are known as Category (Cat) ratings. The
most common categories today are Cat 5e which supports a throughput of 1 Gigabit per
second (Gbps) and Cat 6a which handles up to 10 Gbps. The twisted pair cable is terminated
using RJ45 connectors also shown in the figure above.
Cybersecurity Essentials:
Wireless
44
These days many devices connect to a network using some form of wireless connection.
Sometimes wireless is used in situations where cabling is difficult or expensive, but generally
wireless is chosen for the convenience of mobility especially with devices such as laptops,
tablets and phones. Most of the wireless connections are provided using some form of radio
signal at the physical layer.
There are number of different wireless networks available to suit the requirements of
various types of devices.
If you want to learn about wireless networks, Sophos offers the Cybersecurity Essentials:
Wireless course.
WLAN
45
Wireless Local Area Network (WLAN) is used to connect two or more devices over a
relatively short range usually through an Access Point (AP).
The IEEE 802.11 standard known as ‘Wi-Fi’ is commonly used to provide network access for
devices in homes and businesses.
46
Wireless Personal Area Network (WPAN) is a relatively short-range network and is typically
used for connecting peripherals to devices, for example, interconnecting a headset with a
laptop. The most common mechanism used is Bluetooth.
5. Application
4. Transport
3. Network NIC Driver
0101010 NIC
2. Data Link
1. Physical
47
A Network Interface Card (NIC), also known as a network adapter or network card, is the
hardware component of a computer or other networking device which attaches the device
to the network. A NIC may be built into the system board of the network device or
alternatively it may be supplied separately in the form of a card or a module. Modules are
commonly used in network infrastructure devices such as switches.
The NIC and its associated driver provide the necessary hardware and software for both the
physical and data link layers for a particular network technology. You will often see them
advertised as Ethernet or Wi-Fi cards.
In the data link layer, the NIC and its driver assist with the addressing of the frames so that
the device can communicate with other devices on the same physical network.
At the physical layer, the NIC and its driver are responsible for converting each frame into
data bits. The NIC then functions as a transceiver to convert the data bits into signals which
are appropriate for transmission across the network media in use. For cabled networks the
signals can be electrical or optical, whilst for wireless networks, the signals will typically be
radio waves.
Since the NIC provides physical access to a networking medium, it must provide a suitable
port for connecting to the media. In the case of Ethernet, the port would typically be an RJ-
45 socket.
Hub
Physical Layer
48
To connect its workstations, printers and servers a network needs dedicated infrastructure
devices. Examples include hubs, switches and routers.
Early networks used devices known as hubs. Hubs receive the incoming signal on one port
and re-transmit a copy of the signal out on all the other ports. Hubs have now been replaced
by switches in most network installations. When these devices receive a signal, they rebuild
it before it is re-transmitted. This process ensures that any degrading of the signal is
removed. As a result, the use of hubs and switches allows the maximum distance between
network devices to be doubled
Attacker
Router
Physical Layer
Laptop
Tablet
Computer Printer
49
An area often overlooked is the physical security of the network. For example, if an attacker
is able to plug a device into a “live” network point then they could have full access to the
network.
• Prevent potential attackers from gaining access to your building by implementing good
physical security measures. For example, you might consider security cameras, access
control using proximity cards and security guards
• Make it difficult for attackers to find a “live” network point by securing wiring closets and
network infrastructure devices with door and cabinet locks. Also, make sure that cabling
isn’t accessible and that any unused network points are disconnected
Another option which can be used to protect access to both wired and wireless networks is
known as 802.11x Authentication. This mechanism requires a successful authentication
using login credentials before the network infrastructure device will forward frames through
the network port.
50
5. Application
Frames
4. Transport
3. Network
2. Data Link
1. Physical
51
Layer 2 of the TCP/IP model is the data link layer. It is the layer between the physical and
network layers and it is responsible for transferring data between two physically connected
nodes using structures called frames.
Common examples of networking technologies working at the data link layer are Ethernet,
Wi-Fi, Token Ring and Point-to-Point Protocol (PPP).
The data link layer includes physical addressing of devices. What is the name of the unique
address burned into the network card and required to send data directly from one network
card to another?
MAC Address
The name of the unique address burned into the network card and required to send data
directly from one network card to another is the Media Access Control (MAC) Address.
54
The slide shows a Wireshark capture of an HTTP web request. The data link layer (layer 2)
has been expanded and highlighted.
The data link layer adds physical addressing to the data. It appends both source and
destination MAC addresses in order to create a structure called a frame which it then passes
to the physical layer. The precise format of the frames depends upon the networking
technology in use.
In this capture you can see that Wireshark has determined that the layer 2 protocol is
Ethernet II. As well as source and destination MAC Addresses the frame also has a type field
which is used to indicate what data the frame contains. In this case, the payload of the
frame is an Internet Protocol (IPv4) packet.
This simulation will use the Wireshark network traffic captured earlier in the
course and analyze the data at layer 2
Read the information and follow the instructions to advance to the next step
Start
This simulation will use the Wireshark network traffic captured earlier in the course and
analyze the data at layer 2
Read the information and follow the instructions to advance to the next step.
Continue
5. Application
0101010
4. Transport
3. Network
2a. Logical Link Control
2. Data Link
2b. Media Access Control
1. Physical
66
• Logical Link Control (LLC) layer – this layer is responsible for creating the frames, physical
addressing, error checking, error correction and flow control functions
• Media Access Control (MAC) layer – this layer is responsible for controlling node access to
the network media
The advantage of this model is that the same LLC sub-layer can be used with a variety of
different networking technologies such as Ethernet and Wi-Fi because these technologies
are implemented at the MAC sub-layer.
In this activity you will determine the MAC address of the network
card installed in your computer using the ipconfig /all command
Data Link Layer
67
As explained, each device must have a network card in order to connect to a network. Each
network card has a unique address burned onto it which is required to send data to another
card. In this activity, we’ll use the ipconfig /all command to show the MAC address of the
network card installed in your computer.
Card is displayed
68
Here is the expected output from Activity 1. The MAC address of the network card
displayed.
Note that the actual MAC address displayed will be different for you.
84:34:97:00:00:0A
84:34:97 Identifies
Data Link Layer
the manufacturer
69
Also known as a hardware or physical address, the Media Access Control (MAC) address is a
unique identifier assigned and burnt into a network card. The Address is 48-bits long which
is normally presented as 6 pairs of hexadecimal digits as shown in the example below:
84:34:97:00:00:0A
The MAC address is assigned to the NIC by the manufacturer. To ensure that they are always
unique, each manufacturer is given a unique block of addresses by the Institute of Electrical
and Electronics Engineers (IEEE). The manufacturer then uses the assigned block for the first
24-bits (3 pairs of hexadecimal digits) and then allocates the remaining 24-bits in a way that
ensures that each NIC has a unique address.
To copy the MAC address to your clipboard, click in the button and use your keyboard to
select and copy. Once you have the answer, drag the button to the correct vendor.
Switch
Data Link Layer
Frame
from PC-A
to PC-C
Network switches, also known as multi-port bridges, are similar in function to hubs but with
more intelligence. They understand the frame format and, in particular, the source and
destination MAC addresses within the frames. Instead of sending the signal out on all ports
like a hub, the switch only sends it out on the port to a device with the destination MAC
address.
The forwarding decisions are made using a lookup table which holds MAC addresses and
their corresponding port number. The switch populates the table by examining the source
MAC address of frames when network devices communicate with each other.
When the network switch receives an incoming signal on port 1, it can determine that the
frame is addressed from A to C. It uses the lookup table to determine that the device with
MAC address C is connected to port 3 and so it re-transmits the signal on port 3 only.
If the switch has no record of the MAC address then it acts like a hub by broadcasting the
signal on all ports to ensure that the destination device receives the signal.
Most modern switches are able to store and forward frames. This means that a switch stores
a complete incoming data frame and checks its integrity before sending it out. Such switches
are important when incoming and outgoing speeds differ and provide the flexibility to
support a mix of Ethernet speeds.
Switch
Data Link Layer
Whitelist
Not on Whitelist
As described earlier, one of the main security issues on a wired network is how easy it can
be to plug-in a device and start using the network. One mechanism which can be used to
provide network access control and therefore deter attackers is MAC Address Filtering.
In this mechanism, the MAC address of the network device is used to determine whether
the device should have access to the network. Typically, the network administrator will
configure an approved MAC address list known as a whitelist on the switch. Any device
wishing to communicate on the network via the network switch must have its MAC address
on the approved list.
In the example, when PC-A attempts to transmit data across the network, the switch
determines that the incoming frame has a source MAC address which is not on the whitelist,
and so does not allow PC-A access to the network.
Whilst MAC address filtering can be by-passed by a determined attacker, it can be used to
protect against less determined individuals. For example, it could protect against an
employee trying to plug their home laptop without anti-virus software onto the office
network, which could present a serious security risk.
73
5. Application
Packets
4. Transport
3. Network
2. Data Link
1. Physical
74
The network layer of the TCP/IP model, sometimes referred to as the Internet layer, is
responsible for delivering the data across one or more networks.
In order to make successful delivery possible, it must add network addressing information.
Therefore, it adds both a Source and a Destination IP address to the data to form a structure
called a Packet. The Destination IP addresses in the packet are used by the source host and
any intermediate hosts, known as routers, to assist in selecting the most appropriate route
to the final destination. The precise format of the packet varies depending on the
networking technology in use.
Common examples of networking technologies working at the network layer are Internet
Protocol Version 4 (IPv4) and Internet Protocol Version 6 (IP v6).
We’ll now return to the simulation and view the Network Layer for the traffic
captured earlier in the course
Read the information and follow the instructions to advance to the next step.
Start
We’ll now return to the simulation and view the network Layer for the traffic captured
earlier in the course.
Read the information and follow the instructions to advance to the next step.
Continue
79
The slide shows the network layer (Layer 3) of the Wireshark capture expanded and
highlighted so that we can examine it more closely.
This shows Wireshark has determined that the Layer 3 protocol is Internet Protocol Version
4 (IPv4), and it is showing the structure of the IPv4 packet at this layer. You can see that the
IP packet comprises multiple fields including a Source IP Address, a Destination IP
Addresses, and a Protocol field which is used to indicate the data which the packet contains.
In this case, the payload of the packet is a Transmission Control Protocol (TCP) segment.
80
It may seem strange that when moving a piece of network data from one host to another,
the network stack requires both a MAC address at layer 2 and an IP address at layer 3. The
reason is as follows:
The MAC Address relates to the physical hardware. It is a unique address assigned by the
manufacturer and does not provide any information regarding the network on which the
associated host is located. This type of address is suitable for moving data from one host to
another within the same network. When moving data to a host on another network it lacks
the necessary information to route the data to the destination network. You can think of it
like a social security number in that it is uniquely tied to an individual person but it contains
no information that would help you find that person.
The IP Address is known as a logical address and it relates to the network. The IP address
allocated to a host contains information about both the network on which the host is
located and the host itself. This type of address can be used by layer 3 devices, such as
routers, to determine the network on which the destination host resides. It allows these
devices to intelligently forward the data towards that specific network. This type of address
is similar to a telephone number with a country code, an area code and an individual
number. The country code and area code assist in routing the call to the correct telephone
exchange and then the individual number is used to establish a successful connection.
MAC-R1 MAC-R2
IP-R1 IP-R2
Router
(Default Gateway)
81
Network routers, also known as gateways, are used to connect networks together.
These layer 3 devices are designed to intelligently move data packets from one network to
another.
Routers are both physically and logically connected to at least 2 different networks. The layer
1 physical connection is via network interface cards (NICs), cables and switches, whilst, the
layer 3 logical connection to each of the networks is through the IP addresses allocated to
the NICs.
In the slide, Network 1 is connected to the router with a network interface card with a MAC
address of MAC-R1, and is connected to Network 2 with a different network interface card
with a MAC address of MAC-R2. In Network 1 the router has been assigned a local IP
address of IP-R1, and in Network 2 a local IP address of IP-R2.
Switch 1 Switch 2
MAC-R1 MAC-R2
IP-R1 IP-R2
Router
(Default Gateway)
82
When a router receives a data frame it will extract the packet contained in the payload. It
will use the network addressing it contains to determine exactly how the data should be
forwarded next. The packet will then be placed into a new frame and transmitted for the
next leg of the journey. This may be to either the final destination host or to another router
for further forwarding.
The forwarding decisions are made using a routing table which contains a list of destination
networks and the associated ports which move the packets towards that network. Typically,
the routing table is populated by the router following communication with other routers.
The slide shows a network where the layer 2 functionality takes place on a separate device
from the router. It is possible to combine layer 2 and 3 functionality in one device and this is
common for home networks. These devices are referred to as Layer 3 switches.
Since routers work at layer 3, they are capable of joining together networks which use
different layer 2 networking technologies. For example, a typical home router might connect
an Ethernet network to a the Internet Service Provider (ISP) network using Asymmetric
Digital Subscriber Line (ADSL).
Although more intelligent, a key disadvantage of routers is that they are much slower than
network hubs and switches.
MAC-R1
Switch 1 MAC-A
IP-B
IP-A
MAC-R1
IP-R1
Router
(Default Gateway)
83
We’ll now look in more detail at how the routing process works.
Step1:
• In the slide, PC-A on Network 1 is sending data to PC-B on Network 2
• Layer 3, the network layer of PC-A generates a packet containing the data which is
addressed from IP-A to IP-B and passes the packet down to the data link layer
• The data link layer can only communicate with devices on the same physical network. It
cannot transmit the data frame directly to PC-B so instead creates a frame addressed to
MAC-R1, which is its local router and default gateway
• This frame is sent via the switch, which uses the MAC address to send it to the router
from which it can be forwarded onwards
MAC-B
Switch 1 MAC-R2 Switch 2
IP-B
IP-A
MAC-R1 MAC-R2
IP-R1 IP-R2
Router
(Default Gateway)
84
Step 2:
• On receipt of the data frame, the router will extract the packet contained in the payload
of the frame. It will use the network addressing contained in the packet to determine
exactly how the data should be forwarded next
• Because the router has a direct connection with the destination it can determine the
MAC address of PC-B. It is able to place the packet into a new frame addressed to MAC-B
• It then sends the frame to the switch, which uses the MAC address to forward it to the
final destination
MAC-R1 MAC-B
Switch 1 MAC-A MAC-R2 Switch 2
IP-B IP-B
IP-A IP-A
MAC-R1 MAC-R2
IP-R1 IP-R2
Router
(Default Gateway)
Step 1 using Frame 1 Step 2 using Frame 2
You can see from the figure above that whilst the packet travels the entire length from PC-A
to PC-B, the actual journey the packet takes is divided into 2 steps and each step of the
journey must use a different frame. In real-life, a packet will often have to pass through
many more than 2 steps in order to complete the journey from source to destination host.
IP-A
ARP Cache
IP-C ?
To transfer data within a network, devices must know the MAC address of the destination.
When a networking request comes down the TCP/IP stack to the data link layer, the
destination MAC address for the IP Address may not be known. In order to complete the
outbound frame, the data link layer must therefore discover the MAC address. We’ll now
look at how the Address Resolution Protocol (ARP) is used for this purpose.
In the example, PC-A wishes to transmit a data frame to PC-C. PC-A knows the IP address of
PC-C but not the associated MAC address. In order to resolve the MAC address of PC-C, PC-A
broadcasts an ARP Request to the entire network asking ‘Who has MAC-C?’
ARP is technically a layer 2 protocol, however it is included in this section because of the
support it provides for the network layer.
MAC-A
MAC-C
ARP Cache IP-C
IP-A MAC-A IP-A
IP-C 00:0a:95:9d:59:3c
PC-C sees the ARP Request from IP-A. It determines that it has the IP address of IP-C and
therefore replies directly to PC-A with an ARP Response. It can reply directly because the
original ARP Request contained the MAC address of PC-A. When PC-A receives the ARP
Response, it can address and transmit the data frame.
In order to reduce network traffic and improve performance, each PC has an ARP Cache held
in memory in which it stores any ARP information it has received. In the example above, PC-
C can add an entry for PC-A because of the information sent in the ARP Request and PC-A
can store an entry for PC-C because of the ARP Response.
When a PC needs to resolve the MAC address from an IP address, it will look in the ARP
Cache first before broadcasting an ARP Request. In order to keep the cache up-to-date,
entries only stay in the ARP Cache for a short period which is defined by the operating
system in use.
In this activity you will use arp command to view cached MAC to IP
address entries
Network Layer
88
In this activity you will use arp command to view MAC Addresses that have been resolved to
their IP Address and are held in the arp cache.
89
The figure above shows the expected output from Activity 2. The arp cache on your
computer displayed.
Note that the actual IP addresses and their corresponding MAC addresses will be different
for you.
MAC-A
MAC-C
ARP Cache IP-A
IP-C
90
An ARP Cache Poisoning Attack, also known as ARP Spoofing, can be undertaken by an
attacker with access to a network. The attacker sends specially crafted ARP Response
messages to a target PC. The “spoofed” ARP Response messages associate the attacker’s
MAC address with the IP address of second host on the network.
Whilst the first target machine holds the spoofed information in its ARP cache, any attempt
it makes to send a message to the second host will be sent to the attacker’s PC instead. It is
common for attackers to try to spoof the details of the network default gateway as this will
allow them to collect all traffic from the target PC which is destined for another network.
In the slide, the attacker on PC-D sends a spoofed ARP Response to PC-A which links the IP
address of PC-C with the MAC address of PC-D. PC-A will add this entry to it’s ARP Cache.
ARP is a very simple protocol without any authentication. Network hosts will automatically
cache details they receive regardless of whether they have requested them. This
vulnerability in the ARP protocol is exploited by this attack.
MAC-A
MAC-C
ARP Cache IP-A
IP-C
IP-C 00:0a:95:9d:59:4d
91
PC-A now has the spoofed ARP Response information in its cache. When PC-A wishes to
communicate with PC-C, it will generate a data packet addressed to IP-C but place it into a
frame with the destination MAC address of PC-D. If the attacker periodically sends additional
spoofed ARP responses then they can keep the spoofed entries in the ARP cache of PC-A
indefinitely.
Once, the attacker receives the message, they can choose to:
• Inspect the packets before forwarding them onto the intended destination to avoid
discovery
• Modify the data before forwarding it on
• Prevent communication between the two target hosts by not forwarding some or all of
the packets – this is known as a Denial-of-Service (DoS) attack
If the attacker wishes, they can poison the ARP caches of both PC-A and PC-C so that they
can see traffic in both directions.
There are a few mechanisms that can be used to mitigate such an attack:
• Use an ARP monitoring tool which looks for changes in the associations between IP and
MAC addresses
• Use encryption on the network. This does not prevent the attack but means that the
attacker cannot inspect or modify the network data
As you have seen the network Layer includes IP addresses and routing. There’s much more
to say about the practical aspects of IP and routing and we will cover this in detail in our
Cybersecurity Essentials: Networking 202.
93
5. Application
Segment/Datagram
4. Transport
3. Network
2. Data Link
1. Physical
94
Layer 4 of the TCP/IP model is called the transport layer and it sits between the network and
application layers. It divides long messages into smaller segments or datagrams which are a
suitable size for delivery across the network.
This layer also handles error-checking, error-recovery and flow control mechanisms. Flow
control is the process used to monitor and manage the rate of data transmission between
communicating nodes; it prevents a fast sending node from overwhelming a slower recipient
node with data.
The choice between dividing the messages into segments or datagrams will be covered later
in this section.
Once the segment or datagram has been created, it is passed down to the Network layer.
Main Requirement:
Data Integrity
Layer 4 uses Transmission Control Protocol (TCP)
Transport Layer
Main Requirement:
Fastest Delivery Layer 4 uses User Datagram Protocol (UDP)
95
The many different TCP/IP applications need a wide range of services from the network to
help them work successfully. Most TCP/IP applications, such as email and web, need the
underlying network to guarantee delivery with error checking so that they have the
necessary data integrity. Other applications, such as video and voice, need the underlying
network to provide the fastest possible delivery times with the minimum of delay.
These conflicting requirements are handled in the TCP/IP model by the transport layer
offering two different mechanisms called the Transmission Control Protocol (TCP) and the
User Datagram Protocol (UDP). We will look at the key differences between these protocols
in the next few slides.
96
Transmission Control Protocol (TCP) divides long application messages into smaller
structures called segments which are a suitable size for delivery across the network.
TCP provides connection-oriented and reliable communication. It is the most common type
of session provided by the transport layer because it uses acknowledgements and error
checking to ensure that no data is lost, duplicated or received out-of-order. Most
applications require this level of service to provide the necessary data integrity.
The segments have a system of flags that are used to influence the flow of data across a TCP
connection. Each flag is a single bit which can be set or left off. In the simulation you will see
the use of a flag to acknowledge data.
ACK
97
TCP has a special process for the establishment of a session called the TCP three-way
handshake.
Once established through the handshaking process, the session is used to transfer the
following messages. TCP sequence numbers are used to ensure that the data arrives in
correct order.
ACK
98
Once all the required data has been transferred, TCP has another process for terminating the
session which proceeds as follows:
1. The servers sends a TCP segment with the Finished (FIN) flag set to indicate that it will
send not further data
2. The client responds with an ACK segment
3. The client then sends it’s own FIN segment
4. Finally, the server acknowledges receipt with an ACK segment and the session is
terminated
We’ll now return to the simulation and view the transport layer for the network traffic
captured earlier in the course
Read the information and follow the instructions to advance to the next step
Start
We’ll now return to the simulation and view the transport layer for the network traffic
captured earlier in the course.
Read the information and follow the instructions to advance to the next step.
Continue
106
The User Datagram Protocol (UDP) divides data into structures called datagrams and
provides connectionless communication in TCP/IP networks. It is a “best effort” type of
session provided by the Transport layer for applications which don’t need or want the
overhead of TCP acknowledgements and session control. UDP lacks any kind of error control
and may lose data or deliver it in the wrong order.
Request
Response
Transport Layer
Response
Response
107
When using UDP the sender will not wait to make sure the recipient has received a
datagram - it will continue sending the following datagrams. There is no guarantee the
recipient will receive all the datagrams and no way to ask for any to be sent again.
The benefit of the absence of acknowledgements and error checking is that the computers
can communicate more quickly.
Reasons:
o Reduced server load compared to TCP
o It’s faster than TCP
o DNS queries generally fit into a single datagram
108
Compared to TCP, there are far fewer applications which use UDP, however, they still provide
important services as shown in the following examples:
Domain Name Service (DNS) generally uses UDP for name resolution queries. The reasons
for using UDP are as follows:
• The load on DNS servers can be reduced substantially because the servers don’t have to
keep track of each connection
• The reduced overhead makes the request/response faster
• DNS queries are generally small and easily fit inside a single UDP datagram. If DNS
needs to perform larger data transfers it may used TCP instead
Reasons:
o Timely receipt of information is the priority
o Data loss has a more minor impact on voice or video output than service delays
109
Session Initiation Protocol (SIP) uses UDP for voice and video data. For real-time services
such as voice and video, it is far more important to keep the stream of information coming
in a timely fashion than making sure every packet is received in the correct order. Data loss
usually only has a minor impact on the voice or video output and it is far better to have a
few milliseconds of silence or image loss than to have seconds of lag which would be
introduced waiting for missing data to be re-sent.
UDP is a protocol optimized for getting data packets to their destination in a timely fashion;
it’s meant for real-time services like VoIP where it’s important to keep the data stream going
We’ll now view the packet capture to see how DNS was used to resolve the name of the
sophostest.com web server
Read the information and follow the instructions to advance to the next step.
Start
We’ll now view the packet capture to see how DNS over UDP was used to resolve the name
of the sophostest.com web server
Read the information and follow the instructions to advance to the next step.
Continue
Switch
Transport Layer
Every TCP/IP application has a client process and a server process. The most common TCP/IP
server processes have a standard port number. A port number is a 16-bit number between 0
and 65535.
The port numbers from 0 to 1023 are called the “well-known” port numbers and are
reserved for specific TCP/IP applications. For example, HTTP web servers use port 80 and
DNS name resolution servers use port 53.
When the server process is launched, it binds the port number to the IP address to form a
TCP/IP Socket. For example; in the slide Server B is running an HTTP web server process and
the process “listens” for incoming requests on the following socket: TCP
129.35.99.38:80 LISTENING
The example shows the HTTP web client on Client A sending a request to the HTTP web
server on Server B. The TCP segment contains a destination port of 80 and a source port of
49152. The source port number is generated in a variety of ways depending on the operating
system. It is recommended that source ports use the range 49152 to 65535 which are
known as the Dynamic or Private ports.
When Server B receives the request, it is passed up the TCP/IP stack to the transport layer.
The transport layer sees the destination port of 80 and determines that it relates to the
HTTP web server process. It passes the request to the process in the application layer.
Line 1
Transport Layer
Line 2
Line 3
124
The netstat utility is used to display current TCP/IP network connections and the listening
ports and active connections on a network host.
In the figure above, the user has executed a netstat –an command on Server B referred to in
the previous slide.
The –a switch causes the utility to display the active connections and any listening ports. The
–n switch displays the IP addresses and port numbers in numerical format without any
attempt at name resolution.
SYN/ACK
SYN/ACK
BOT Target
SYN/ACK
SYN/ACK
SYN/ACK
125
A SYN Attack, also known as a TCP SYN Attack or a SYN Flood, is a type of Denial-of-Service
(DoS) attack. The attacker takes advantage of the TCP 3-way handshake by bombarding a
target system with specially crafted SYN requests with spoofed IP source addresses. The
attacker can automate the process by using scripts running from internet bots.
The target responds with a SYN, ACK and must keep resources allocated to the partially
opened connection until a timeout period defined by the operating system has expired. In
the meantime, many more SYN requests have been received by the target which eventually
becomes overwhelmed. Once the connection queues on the target system become
exhausted, it will become unresponsive to all requests, including legitimate ones, and it is
this that causes the denial-of-service.
126
The figure above shows the output from the netstat utility when a SYN attack is underway.
For an example of protection see: Sophos XG Firewall: How to prevent DoS and DDoS attacks
https://sophos.com/kb/123182
Application Layer
127
5. Application
Application Data
4. Transport
3. Network
2. Data Link
1. Physical
128
Layer 5 of the TCP/IP model is called the application layer and it sits at the top of the TCP/IP
stack above the transport layer. Remember that the TCP/IP application layer is the
equivalent of the top three OSI model layers called session, presentation and application.
Therefore, it is the responsibility of the TCP/P application layer to perform all the functions
performed by these OSI model layers.
• Application Layer – this layer handles interactions between any application requiring
network access and the network itself
• Session Layer – this layer initiates, manages and terminates the connections between
the local and remote applications. It also handles reconnection following an
interruption or timeout. These connections, or sessions, can be considered a persistent
link between the client and server application processes which are used by them to
exchange data over prolonged periods of time. This layer makes use of the sockets
formed in the transport layer discussed in the earlier section of this course.
Once the TCP/IP application layer has completed the above tasks it will pass the data to the
transport layer below it.
This final simulation will show the application layer HTTP request to the
sophostest.com website
Read the information and follow the instructions to advance to the next step
Start
This final simulation will show the application layer HTTP request to the sophostest.com
website.
Read the information and follow the instructions to advance to the next step.
Continue
The 1989 IETF document RFC 1123 defined the application layer and these
standardised protocols:
Application Layer
The TCP/IP application layer defines communication protocols and interface methods for any
application requiring network access.
The original Internet Engineering Task Force (IETF) document which defined the application
layer can be found in Request for Comment (RFC) 1123. The document defines a set of
communication protocols for use on the early Internet and many of these are still in use
today, including the following:
Since RFC 1123, was published in 1989, numerous other communication protocols have
been standardised in RFCs including some of the most popular on the Internet such as
Hypertext Transfer Protocol (HTTP), Post Office Protocol (POP3) and Session Initialization
Protocol (SIP).
The slide above shows a list of some of the most common communication protocols and it
includes their port numbers and a description of the service they provide.
Note that most of the protocols have a secure alternative which uses a different port
number.
In this activity you will use a telnet web tool to test connectivity to
an IP address and port
Application Layer
Continue
138
In this activity you will use a telnet web tool to test connectivity to an IP address and port.
A telnet client is included with Windows but the feature is not turned on by default. Control
Panel, Programs and Features can be used to turn on this feature, which can then be used
from a command prompt, for example:
telnet 4.2.2.2 53
139
This shows the expected output from Activity 3. The server with IP address 4.2.2.2 is not
listening on port 80 so the connection failed. The connection using port 53 is successful.
Financial Information
When the TCP/IP communication protocols such as FTP, SMTP and HTTP were originally
developed there was little or no consideration given to protecting the data while it travelled
across insecure networks such as the Internet. As a consequence, the data could easily be
captured, read and modified.
These days we live in a world where highly sensitive and personal data regularly needs to be
transferred over insecure networks. This information needs protection against loss, theft and
unauthorised modification because in the wrong hands, it could be used for crimes such as
identity theft or extortion.
The original TCP/IP communication protocols are not fit for this purpose so it has been
necessary to find alternatives which offer appropriate levels of data protection.
HTTPS
Cybersecurity Essentials:
Cryptography
141
In some cases, alternative protocols have been developed to provide encryption to protect
sensitive data travelling over insecure TCP/IP networks. For example, the TELNET protocol
that was used to provide remote logins has been replaced by the Secure Shell (SSH) protocol
which encrypts all the data transmitted between the hosts including usernames and
passwords.
A more popular approach has been to utilise the Transport Layer Security (TLS) protocol and
its predecessor the Secure Sockets Layer (SSL). These protocols can be readily added in the
TCP/IP application layer (more specifically the OSI presentation layer) to bolt-on secure
communication offering data privacy and integrity. This bolt-on approach means that a
highly secure connection can be achieved whilst leaving the underlying communication
protocols such as HTTP, SMTP and SIP completely unchanged, apart from the requirement to
use a different port number as shown in a previous slide.
As shown, the same payment form data has been captured using Wireshark. In the insecure
HTTP example, the credit card details are clearly visible in the form data. In the secure
HTTPS example, the credit card details have been protected in the encrypted application
data of the Secure Sockets Layer. The use of strong encryption makes the reading and
modification of the data by an attacker impossible.
If you are interested in the use of cryptography to protect data then we recommend our
Cybersecurity Essentials: Cryptography courses.
Use Windows utilities and packet capture tools to view network activity
Continue
Here are the skills you should be able to take away from this course.
If you feel confident that you have met these objectives, click Continue to complete the quiz.
Transport Frame
Network Bits
Physical Packet
Submit
143
Layer 3 NIC
Layer 2 Router
Layer 1 Switch
Submit
144
Submit
145
HTTPS 25
HTTP 53
DNS 80
SMTP 443
Submit
146
Enter the command that would display cached resolutions of IP addresses and their
corresponding MAC addresses
Submit
147
150
151
• 202: IP and Routing looks in detail at IPv4 addresses and the way these are used to route
packets. It also provides an overview of IPv6
• 203: Name Resolution looks at the types of names that are used for network devices and
the methods that can be used to resolve these to their IP address
The courses also highlight cybersecurity issues and ways to mitigate them.
Networking
101: Getting Started with Networking
201: TCP/IP Network Model
The courses in this series are designed for individuals with no prior knowledge of the topics.
Additionally, we have a number of courses that are being developed and will be made
available soon.
We also have a list of planned courses we would like to add to this series.
If you would like to suggest a topic for a course for inclusion or to provide any feedback on
this series then please email us at globaltraining@sophos.com
ipconfig /all
4
1 Command
2
arp -a
arp -a
arp -d *
arp -a
ping 4.2.2.2
10
arp -a
1 https://www.adminkit.net/telnet.aspx