Network Fundamentals
Network Fundamentals
A network refers to two or more connected computers that can share resources such
as printer, data, application or combination of these resources.
PAN
Protocols
Protocols are rules that govern how device communicate and share information
across a network. For example:
Internet Protocol [IP]
Hyper Text Transfer Protocol[HTTP]
Simple Mail Transfer Protocol[SMTP]
Topologies
A network topologies refers to how the network devices are interconnected, including
physical topology and logical topology.
• Physical Topology: Describe the physical layout of your network. Like Star or Bus or
Mesh.
• Logical Topology: Describe how communication appears from the perspective of
the connected users. This covers how data will flow between nodes and if any
redundancy path available or multiple path to reach destinations.
Network Architectures
A Host/Node refers to any device that is connected to a network using network
address.
Host/Node can request data – basically Client
Host/Node can provide data – basically Server
Host/Node can do both request as well as provide data – referred as Peer.
The two host below communicate using hardware and MAC addresses. Hub operates on
the physical layer of the OSI model.
Below network is actually one collision domain and one broadcast domain.
Switch divides the collision domain of hosts but broadcast domain remain same. Below
network shows 3 collision domain and 1 broadcast domain.
Ethernet is a contention-based media access method that allows all hosts on a network to share the
same bandwidth of a link. It is scalable (e.g. Fast Ethernet to Gigabit Ethernet) and used on both
Data-link layer and Physical.
Collision Domain: It’s an Ethernet term that refers to a particular network scenario wherein one device
sends a packet out on a network segment, thereby forcing every other device on the same physical
network segment to pay attention to it. This can cause collision, if two device on one physical
segment transmit at the same time. Collision comes from the world of half-duplex Ethernet
For e.g. Single Lane – One at a time.
Broadcast Domain: Broadcast domain refers to a group of devices on a network segment that hear all
the broadcasts sent on that network segment
For e.g. Office Intercom system.
Carrier Sense Multiple Access/Collision Detection (CSMA/CD): Protocol that helps devices share the
bandwidth evenly without having two devices transmit at the same time. It was created to
overcome the problem of collision.
When collision occurs on Ethernet LAN, following happens:
a. Jam signal informs all devices that a collision occurred.
b. Collision invokes a random back off algorithm
c. Each device stops transmitting until back off time expires
d. All host have equal priority to transmit after the timer expires.
Collision Domain: A collision occurs when two devices send a packet at the same time
on the shared network segment. The packets collide and both devices must send the
packets again.
Broadcast Domain: A broadcast domain contains all devices that can reach out at the
data link layer by using broadcast.
Ethernet Networking – Half Duplex an Full Duplex
Session Layer [L5]: Keeps different application data separate [Dialog Control]
Responsible for the establishment of connection, maintenance of session, and
ultimately terminating session between devices. Session communication falls
under one of three categories: Simplex, half-duplex, and full-duplex.
Transport Layer [L4] – Heart of OSI
It segment and reassemble data into data stream. Provide end-to-end transport service and can
establish a logical connection between sending host and destination host on internetwork. Ports
being used at transport layer. TCP and UDP works on transport layer. TCP is connection oriented
and UDP is connectionless.
The term reliable networking can be used at the transport layer. It means that acknowledgement,
sequencing and flow control will be used.
Network Layer [L3] – Manage device addressing, tracks the location of the device on the network and
determine the best way to move data. It provide the routing service within the internetwork. Two
types of packets are used at network layer:
- Data Packet : Routed protocols like IPv4 or IPv6 (Logical Addressing)
- Route Packet : Routing protocols like RIP, EIGRP, OSPF etc [Choose suitable path from source to
destination]
Data-Link Layer [L2] – Provide physical transmission of the data and handles error notification,
network topology, and flow control. It’s responsible for actual unique identification of each device
that resides in network. It formats the message into pieces, each called a data frame and add
customize header of source and destination hardware address. It is divided into two sub-layer:
- Media Access Control (MAC) – How packets are placed in media [FIFO]
-Logical Link Control (LLC) – Identifying network layer protocol and then encapsulating them
(Ensure protocol like IP can function regardless of what type of physical technology is being used).
Physical layer [L1] : It does two things – It send bits and receive bits [Bits comes in
value of 1 or 0s] over physical channel. This layer where you identify DTE [Data
Terminal Equipment] and DCE [Data Control Equipment]. DCE is usually located at
service provider while DTE is attached device most often accessed via modem or
CSU/DSU [Channel Service Unit/Data Service Unit]
OSI Layer PDU Function Devices
Application Message/Data Provide User Interface
Presentation Message/Data Present Data –
Translation,
Encryption,
Compression
Session Message/Data Keep different
application data
separate
Transport Segments End-to-End connection Firewall
Network Packets Data Delivery [Routing] Routers and Layer3
Switch
Data-Link Frames Access to Media Layer 2 Switch and
[Framing] Bridge
Physical Bits Physical Topology Hub and Repeaters
[Binary Transmission]
Encapsulation and Layered Communication
As data is passed from the user application down the virtual layers, each layer adds a
header containing protocol specific information to that layer. These headers are called
Protocol Data Units[PDUs], and the process of adding these headers is called
Encapsulations. Lower layers perform encapsulation, generally.
PDUs
As data is received on receiving device, each layer communicates with the corresponding
layer. Each Layer stripped away it’s header information before being sent up to the
upper layer. This process is called decapsulation.
Port number and Sockets
Both TCP and UDP provides a mechanism to differentiate applications (or services)
running on the same host, through the use of port numbers. This allows multiple
services to operate simultaneously on the same logical address such as Telnet,
Email, HTTP etc..
Port range from 0-65535 are used by both TCP and UDP.
First 0-1023 ports have been reserved for widely used known services
Port ranging from 1024-49151 are referred to as registered ports and are allocated by
the IANA upon request.
Port ranging from 49152 – 65535 cannot be registered and considered Dynamic. (For
some operating systems dynamic port starts from 1024 and higher)
Connection-Oriented Session
TCP employs a three-way handshake to form a connection. Control messages are
passed between the two hosts as the connection is set up:
An established state indicates that data transfer can occur. The communication
becomes bidirectional, regardless of which initiated the connections. Connections
are identified by the sockets of both source and destination host and data specific
to each connection is maintained in a Transmission Control Block (TCB).
TCP Segmentation and Sequencing
TCP will not only segment data into smaller pieces for transport, but will also assign a
sequence number to each segment. Note that this sequence number identifies the
data (bytes) within the segment rather than the segment itself.
Data is sequenced and acknowledged in groups, dictated by the TCP Window Size of
the receiving host. Window Size can never exceed the maximum segment size
(MSS) which is 536 bytes by default.
Receiving Host informs Sender how many bytes it is permitted to send, before waiting
for an acknowledgment. This window size is dynamically changed to provide a
measure of flow control, preventing buffer congestion.
A window size of 0 instruct sender to send no further data indicating congestion.
Transmitting segments with flow control
Flow control prevents a sending host on one side of the connection from overflowing the
buffers in the receiving host.
TCP Sliding Window & Flow control
Sliding window mechanism falls into one of the four categories
a. Bytes that have already been sent and acknowledged
b. Bytes that have been sent but not acknowledged
c. Bytes that have not yet been sent, but the receiving host is ready for
d. Bytes that have not yet been sent, and the receiving host is not ready for.
Sender Receiver
TCP header provides a PSH (PUSH) flag to accommodate data to be sent immediately,
regardless if the TCP window has been filled. PSH flag can be used in conjunction with
URG(urgent) flag, which allows specified data to be prioritized over other data.
TCP also utilizes the RST (Reset) flag to address half-open connection, sending RST
message will force the remote host to reset the TCP connection and returned to closed
state.
TCP Header
TCP header is comprised of 12 required fields and has a maximum size of 160bits
(20bytes).
Source Port and Destination Port – 16bit field [0-65535] identifies services on the
sending host and application on receiving host.
Sequence Number and Acknowledgement Number – Sequence number are used to
identify the data bytes in a stream and acknowledge is used to acknowledge
sequence number.
Data Offset/Header Length – Indicates where the data begins in a TCP segment. Min.
header length should be 20bytes and max 60bytes.
Reserved – 6 bits in size and always set to 0
Control bits- have flags like ACK, SYN, PSH, RST, URG, and FIN flags.
Window – 16bits in size and use for flow control. Identifies the number of data that
receiver is able to accept.
Checksum – used for error checking, and is computed using both TCP segment and IP
header. Receiving host will discard the segment if it fails the checksum calculations.
Urgent Pointer – Use to identify the last byte of prioritize traffic in segment, when
URG flag is set.
Padding – Ensure that TCP header ends on 32 bit boundary, and is always set to Zeros.
UDP Segment
16 bits 13 bits
32 bits
32 bits
Version – Version of IP. In our case it is IPv4 (Binary value of IPv4 will be 0100).
Internet Header Length(IHL) – Specifies the length of the IP header min. 20bytes and
maximum 60bytes. So the value will always start with 5 (5*4=20 – which is the
minimum requirement) however this value may change.
RFC 2474 (which was released in December 1998) reserved the first six bits of the DS (or IPv4 ToS) field for the
Differentiated Services Code Point (DSCP), and RFC 3168 reserved the last two bits for Explicit Congestion
Notification.
Let's start with an IP priority of 1, or
0b001 in Binary. The entire ToS field
would then be 001 00000, assuming
that the unused 5 bits are zero. The
DSCP can be interpreted by
resegmenting to 001000 00, where
001000 = 8 is the DSCP value.
Total Length - Identifies the total packet size include both IPv4 header and payload. Header
min. size is 20bytes with no payload and maximum with payload is 65535.
An IPv4 packet that is larger than MTU size of a link must be fragmented. By default, MTU for
Ethernet is 1500bytes.
Time to Live – Limits the lifetime of the packets. It’s 8 bit field so the max value is 255 (2^8).
When router forward packets, it will decrement the TTL value by one. Once reach zero,
packet is dropped.
Protocol – Identifies the next upper layer header like TCP, UDP, HTTP used. For eg. 1 is ICMP, 6
is TCP, 17 is UDP, 88 is EIGRP, 89 is OSPF etc..
https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
Header Checksum – Used to error check IPv4 header. Receiving host will discard the
packet if it fails the checksum calculation. For e.g. If you receive a parcel which is
not intended for you (you will check the name and address on parcel), you will
reject the parcel.
Source IP address and Destination IP address – 32-bit IP address identify the sending
host and the receiving host. The value of both these fields can be changed, if the
packet is forwarded using NAT.
Identification Field (16 bits), Flag field (3 bits), and Fragment offset field (13bits) –
These 3 fields are used when a packet must be fragmented. Each fragment of the
packet is marked with the same identification number and Fragment offset allows
the destination host to reassemble the fragment in the proper order.
Flag field dictate 2 conditions –
Don’t Fragment (DF) – Indicates packet cannot be fragmented. If a packet exceeds a
link’s MTU size and this flag is set, then the packet is dropped. An ICMP error
message is sent to the source host.
More Fragments (MF) – All fragments have this bit set to one, except for the last
fragment, where the bit is set to zero. This allows the destination host to know
that it has received all fragments.
Suppose a router receives an IP packet containing 600 data bytes and has to forward
the packet to a network with maximum transmission unit of 200 bytes. Assume
that IP header is 20 bytes long. What are fragment offset values for divided
packets?
Solution – Datagram here is 600bytes and the IP header is of 20bytes i.e. actual data
will be 600-20=580bytes).
Now we cannot forward 600bytes of packet because our MTU is limited to 200bytes.
So we have to fragment this packet in order to forward it to the network.
200 bytes = 20bytes of header + 180 bytes of data
So we can fragment 580bytes/180bytes = 3.2 so to round off we would need 4
fragments.
Packet 1=180+20 MF will be 1
Packet 2=180+20 MF 1
Packet 3=180+20 MF 1
Packet 4= 40+20 MF 0
Fragment offset will be calculated using scale of 8. i.e.
We don’t have packet before packet 1 so we will consider as a starting point and place
0 value.
For packet 2, we do have packet 1 – 180/8= 22.5
For packet 3, we do have packet 1 and packet 2 – 180+180/8= 45
For packet 4, we do have packet 1, 2, and packet 3 – 180+180+180/8=67.5
Routing table used in Router
Router use the logical address in a network layer to determine the next hop router to
forward the packets. It can use access list to control security on the type of packets that
are allowed to enter or exit.
Layer 3 device provide connections between VLAN and QOS for specific network traffic
Ethernet Frame
Ethernet Frame is a data link layer protocol data unit. In other words, a data unit on
an Ethernet link transports an Ethernet frame as its payload (actual data).
Preamble and SFD are added by physical layer. It’s purpose is to synchronizes
communication on the network. Preamble [56bits (8*7)] consist of 101010.. Followed
by SFD but SFD last value is always 1 because it indicates a valid frame is about to
begin.
Preamble and SFD are not considered part of the actual frame or calculated as part of
the total frame size.
Source and Destination Mac address – Ethernet uses 48-bit MAC hardware address to
identify who is to receive the frame and the host originating the frame.
EtherType/Length and Payload – Provides a different function depending on the
standard. With 802.3 or Ethernet II , EtherType/Length field identifies the length
of the payload/Data.
Minimum frame size for Ethernet is 64 bytes (512bits), frame smaller than 64bytes will
be discarded. Required field in an Ethernet header add up to 18 bytes , thus frame
payload must be a minimum of 46bytes and max 1500 bytes.
If payload doesn’t meet this minimum, payload is padded with 0 bits until the
minimum is met.
By default, max frame size is 1518bytes [1500 +18] or 1522 [1500+4+18]bytes with
802.1Q(VLAN) tag. Some devices supports jumbo frames of 9216 bytes.
Frame Check Sequence [FCS] or Cycle Redundancy Check(CRC) field is used for error
detection. A frame with an invalid CRC will be discarded by the receiving device.
This field is a trailer and not a header.
Ethernet Address a.k.a MAC/Hardware address
MAC/Hardware address is used to uniquely identify a host within a local network. Ethernet uses
48bits(6 bytes) MAC address as its hardware address. It is often hardcoded on physical network
interface.
MAC address is often represented in hexadecimal. First 6 hexadecimal digits(3 bytes) identify the
manufacturer of the physical network interface commonly referred as OUI (Organizational Unique
Identifier) and the last 6 digits(3 bytes) identify the host itself also referred as Host ID.
Here are some OUI of well known manufacturer
Hypen in Windows
Colon in Linux
Period in Cisco
Univeral or Local Bit [U/L]
Address can either be universally administered addresses (UAA) or locally
administered address (LAA). If the bit is 0, the address is UAA and if it is 1, the
address is LAA (set by administrator).
Scalability limitation of Layer 2 hardware addresses are mitigated using logical addressing.
Logical Addressing
Logical addressing is a function of the Network layer of the OSI model, and provides a
hierarchical structure to separate networks. Logical addresses are configured either
manually or dynamically on the network interface and changed freely.
Logical address contains two components:
1. Network ID – Identifies which network a host belongs to.
2. Host ID – uniquely identifies the host on that network.
Internet Protocol
IP provides two fundamental network layer service:
3. Logical Addressing – Provides unique address that identifies both the host, and the
network the host exists on.
4. Routing – Determine best path to a particular destination network.
During the 1990s, companies began adding OSI, TCP/IP, or both to their enterprise
networks. However, by the end of the 1990s, TCP/IP had become the common choice,
and OSI fell away.
A slightly different four-layer original version of the TCP/IP model exists in RFC
1122, but for the purposes of both real networking, uses the five-layer model.
TCP/IP Application Layer - TCP/IP application layer protocols provide services to the
application software running on a computer. The application layer does not define
the application itself, but it defines services that applications need.
TCP/IP Transport Layer - TCP/IP application layer protocols provide services to the
application software running on a computer. The application layer does not define
the application itself, but it defines services that applications need.
TCP/IP Network Layer - The application layer includes many protocols. The transport layer
includes fewer protocols, most notably, TCP and UDP. The TCP/IP network layer includes a
small number of protocols, but only one major protocol: the Internet Protocol (IP). In fact, the
name TCP/IP is simply the names of the two most common protocols (TCP and IP) separated
by a /.
TCP/IP Data-Link and Physical Layer - TCP/IP application layer protocols provide services to the
application software running on a computer. The application layer does not define the
application itself, but it defines services that applications need.
Dynamically
Learned MAC
Dynamic MAC address
are removed from table
every 5 mins of
inactivity – This proess
is called aging.
Switches operate at layer 2 devices where they only learn mac-addresses. If PC1 wants
to send some data to PC3 then it uses ARP (Address Resolution Protocol)
ARP is used to discover the layer 2 address (MAC address). ARP consist of two
messages:
1. ARP Request is broadcast – sent to all host on network because address is unknown
2. ARP Reply is unicast – Sent only to one host.