Networks
A network is a connection of two or more computers in order to share resources and exchange data.
Benefits of a network
By creating a network of computers, you can:
- Share resources
- Centralise data or resources
- Enhance external security through access levels, enterprise management, etc
- Flexible acces
Drawbacks of creating a network
While networks have several benefits, there are also drawbacks to creating a network.
Some drawbacks include:
- Privacy concerns
- Implementation/maintenance cost (administration, hardware, etc)
- Security vulnerabilities (Easier to infect more devices once the network has been breached)
- Creates a singular point of failiure (Core networked components could bring down several machines)
Types of networks
Networks can be split into several types, being PAN, LAN, WAN.
Local Area Network
A Local Area Network (LAN) is a type of network that is confined to a limited geographical area. This doesn’t necessarily imply a small number of devices, a LAN can reach across a building or organisation.
LANs are locally owned, often by the organisation that uses the network.
Some examples of LANs include:
- Your home network
- School network
- Office network
- any other relatively geographically limited network
To create a LAN, each device (which will be referred to as a node), will connect to other nodes on the network.
Hardware of a LAN
NIC
A NIC (Network Interface Card) is a chip, often integrated into the motherboard or as an external dongle, that supplies a computer with the capability to connect to a network.
They contain a MAC (Media access control) address, which uniquely identifies a device on a local network.
Wireless Access Point
A wireless access point is a hardware device that is able to receive wireless communications from many clients at once.
It generally listens on the 2.4GHz or 5GHz bands, where 5GHz is preferred due to lower interference and higher bandwidth.
The WAP will be connected physically to the switch to connect the access point to the rest of the network. The WAP broadcasts the SSID freely, so devices that are listening for available WiFi connections can locate the network. Private networks can be created by using a WAP that doesn’t broadcast its WiFi SSID.
Switch
A switch is a network hardware device that utilises physical ethernet connections to connect many nodes together within a LAN. It will have an array of ethernet ports to allow many devices to connect.
A switch forwards frames to other devices within the local network, using the MAC address to identify devices.
When a device connects to the switch, its MAC address is collected into a table. The switch can use the table to find which device to send frames to.
Utilising the routing table means that data only travels where it needs to.
Note
Within the local network, a switch will use frames rather than packets. They are essentially the same, but is a distinction that the exam board likes.
Hub
A hub is essentially the same as a switch, however instead of intelligently routing packets to the correct MAC adress, it insteads forwards the data to all nodes conneceted to the hub.
Router
The router is a node on a network that directs packets across multiple networks. It allows multiple networks to connect to each other by routing packets to other networks utilising IPs to identify which network.
A router must:
- Be able to determine the next best route that a packet should take to get to the next leg of the journey
- Be able to switch a packet from inbound ports to outbound ports
Routers utilise routing tables to figure out the best way to navigate towards the the destination. The routing table contains information about what is connected to specific ports.
Routers utilise the Routing Information Protocol (RIP) to receive information regarding other networks that what it is directly connected to.
RIP can be used to also figure out how to get to a location with the fewest hops.
Cables
There are two types of cables:
- Fibre optics
- Copper
There are advantages and disadvantages to both.
Home router
Home routers are essentially composed of:
- A WAP
- A switch
- A Router
Network Communication
For devices to communicate on a network, they must use established standards to ensure the communication is smooth.
Protocols
A protocol is a set of standards that determine the rules, procedures and data formats that two devices must use in order to communicate with each other.
Utilising standard protocols promotes interoperability, since as long as two devices implement the same protocol, they will be able to communicate, no matter how different the devices are internally.
Handshaking
To declare a communication with another device, you will first start the communication by performing a handshake.
A handshake is essentially a declaration of the beginning of a communication link by authorising and validating identities, as well as confirming what protocols will be used.
The receiving device must send back a response packet confirming that the device has ‘agreed’ to the declaration so that the two devices can begin their communication.
There are some conditions that may be declared within the handshake.
Physical considerations can include:
- Whether the device is using a wired or wireless communication
- Whether data can be sent in parallel
- Sync vs async (wait for response / send response whenever)
- Copper wire or fibre optic
- Simplex vs half duplex vs ful duplex
Some logical considerations may be used as well:
- Bit rate
- Error detection methods
- Size of packets
- Packet ordering
- Rotuing
- Whether compression or encryption will be used during commnication
- Whether packets must be cryptographically signed and verified
Error detection
When packets are sent within a network, errors can occur which may force the packet to be resent.
Some causes for errors include:
- damaged cables
- corrupted data
- faulty node within the network
There are different ways of detecting an error within a packet.
Checksum
A checksum is a small fixed length hash that is generated based on the bits of the packet. Whenever there is even a small change in the data contained within the packet, the hash will completely change, therefore making it easyto ensure the packet is unmodified
Pros:
- Depending on the hashing algorithm, it is cryptographically secure
- Fast
- Small
Cons:
- The checksum being corrupted will force the packet to be resent always
Echoing
When a packet is received, a copy of the packet is sent back to the sender to confirm that whatever they received is the same as what was sent.
In the case that the packet is not the same, the packet must be resent.
Pros:
- Simple
- Detects 100% of errors
Cons: - Doubles all network traffic
- There is a chance of the resent packet also being corrupted, making teh check redundant
Parity bit
A parity bit is a single bit added to the end of a string of data to indicate whether there is an odd or even number of 1s in the data.
Parity bits can also be used to corect errors within the packet. This is done where some bits are allocated as redundancy. They contain enough information about the data stored within the packet to be able to recover some of the packet’s data if it was corrupted. The more parity bits allocated, the more data can be corrupted while still being recoverable
Connecting to a network
This section will go through the process of a simple request.
Connecting to a LAN
First, the device must join the local network. For this case, it will be done using a WAP.
The device must find the WAP by detecting its broadcast SSID and authenticating with the WAP.
The device can then negotiate a local IP address (192.168.x.x or 10.x.x.x) from the router using the MAC address to communicate at first.
After being assigned a local IP, the tablet can now communicate with the router.
Making a request
Note
From here on, the device is now a laptop typing laptop is easier than device When the laptop makes a request using a domain name, it has to find the IP associated with the domain.
It does this by first querying the router for which IP address the domain name is associated with; the router commonly acts as the client’s configured DNS resolver and may have a cached answer for frequently used names.
If the router or resolver does not have the record cached, recursive DNS queries (root → TLD → authoritative) up the DNS hierarchy (ISP → regional → authoritative) will be performed until the record is found. If the DNS record cannot be found, the DNS lookup fails (for example, NXDOMAIN) and the client receives a DNS error.
Once the IP address is known, the client constructs an IP packet with its private source address. When the packet leaves the LAN, NAT (Network Address Translation) rewrites the private source IP (and usually the source port) to the router’s public IP and an assigned port, and records that mapping so return traffic can be forwarded to the correct internal device.
The laptop sends a unicast frame to the wireless access point (WAP); the WAP forwards the encapsulated IP packet to the router. The router then forwards that packet to the next hop toward the destination according to its routing table — it does not create multiple identical copies under normal operation.
After several hops, the packet will reach the web server.
TCP/IP
The TCP/IP stack is the most common view of protocols used in networking.
The stack is composed of several layers where each layer utilises a specific protocol that is responsible for adding different information. Since each layer of the stack will use similar protocols, each input and output of each layer can be more predictable.
The receiver of a packet should use the same stack and protocls, therefore packets can be unwrapped in the correct manner.
The layers
The stack is composed of several layers:
| Layer | Associated protocols |
|---|---|
| Application | HTTP, HTTPS, FTP, SFTP, etc |
| Transport | TCP, UDP |
| Internet layer | IP |
| Link | Ethernet, ADSL |
How data is sent
The sender will begin with the application layer, where an appication will want to create a network request.
First, the protocol associated with the application will be identified.
The data that is to be sent is prepared and encrypted if it is used, and then it is sent to the transport layer.
The transport layer utilises TCP to receive data from the application layer, then the end to end connection is established with the receiving cmputer. The large chunks of data will be broken into smaller packets if necessary, and port numbers are added to the packet based on what ports the operating system has allocated the applicaiton. Then, the packets are handed off to the internet layer.
The internet layer will receive the packets from the transport layer, and the source and destination IPs are added onto the packet. The IP address and the port number are used to form a socket, which determneiss which applcatino will receive the data …. they will use to communicate.
The link layer will then receive the data from the internet layer, and append the MAC address of the next device that the packet will visit. It will also remove the previous node.
During transmission, the packet will visit several routers, where it will be shuffled between the internet and link layers between each hop so that the packet can be routed based on each router’s routing table.
Note
A good way of remembering this final part is basically the inverse of what happened before
Finally, once we have reached the destination device, the packet will get to the internet layer.
THe internet layer will then receive data from the link layer and removes routing information. The packet can then be given to the transport layer
The transport layer will use TCP to receive data from hte internet layer and reassemble the packets in the correct order.
TCP will acknowledge receipts of each packet to confirm that the received packets have actually been received.
TCP will also perform error detection of the received packets.
Any packets that were corrupted or missing will be re-requested from the sending machine.
Finally, data will ten be passed to the application layer.
The application will receive the data from the transport layer and decrypts the data if an encrypted protocol was used (https, sftp, etc).
Finally, the data can be presented to the user.
Types of network communications
There are two methods for devices to establish communication with each other.
Circuit switching
This was primarily used in analogue telephone lines.
Circuit switching involves creating dedicated lines between nodes on the network that data can be sent through.
This means that:
- There is a dedicated connection between two nodes
- The data is sent in order and received in order, therefore making reassembling not necessary
- Fixed bandwidth with no competition
- No need for data headers, routing, etc
However/; - High setup latency while the dedicated route is being established
- Has a singular point of failure that will stop communication
- Inefficient, full bandwith is allocated as long as the connection is open even when not necessary
- Poor scalability. Each node part of the route becomes inacccessible/blocked, so more connections require more nodes and circuits.
Packet switching
Packet switching is an alternative to circuit switching where data separated into packets and allocated a header. These packets can take their own route to the destination, so they can traverse anywhere through the network.
This means that traffic can be distributed dynamically throughout the network.
After the packets have been received, they can be reassembled into the complete data.
Packets are composed of:
- Source IP Address
- Destination IP Address
- Packet number
- TTL (Time to live)
- Payload
- Checksum
When a packet reaches a new router it:
- Recalculates the checksum and confirms integrity
- Decreases TTL
- Searches routing table for the exact MAC address to see if the destination is already known
- Otherwise, the table is searched for a network address derived from the destination IP, then forwarding the packet to that address.