Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ It's my favourite children's book with illustrations.

### Networking Protocols
- [Protocols](networking/protocols.md)
- [DHCP](networking/DHCP.md)
- [DHCP](networking/dhcp/DHCP.md)
- [Is DHCP a must for every subnet?](networking/dhcp/is-dhcp-a-must-for-every-subnet.md)

### Packet Analysis
- [Connection](networking/connection.md)
- [DHCP packet](networking/DHCP-packet.md)
- [DHCP packet](networking/dhcp/DHCP-packet.md)

### Networking utilities
- [`curl` and `ping`](networking/curl-and-ping.md)
Expand All @@ -42,6 +43,10 @@ It's my favourite children's book with illustrations.
- [UEFI](hardware/UEFI.md)
- [`ipmi`](hardware/ipmitool/ipmitool.md)

## Electronics
Basics
- [AC/DC currents](electronics/basics/1-AC-DC.md)

**Concepts**
- [Thurmal trip](hardware/ipmitool/thermal-trip.md)

Expand Down
30 changes: 30 additions & 0 deletions database/psql/commands/self-join-left-outer-join.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- https://pgexercises.com/questions/joins/self.html
-- Produce a list of all members who have recommended another member
-- How can you output a list of all members who have recommended another member? Ensure that there are no duplicates in the list, and that results are ordered by (surname, firstname).

select distinct m1.firstname, m1.surname
from cd.members m1
inner join cd.members m2
on m2.recommendedby = m1.memid
order by m1.surname, m1.firstname;

-- LEFT OUTER JOIN
-- https://pgexercises.com/questions/joins/self2.html
-- Produce a list of all members, along with their recommender
-- How can you output a list of all members, including the individual who recommended them (if any)? Ensure that results are ordered by (surname, firstname).

select m1.firstname as memfname,
m1.surname as memsname,
m2.firstname as recfname,
m2.surname as recsname
from cd.members m1
left join cd.members m2
on m1.recommendedby = m2.memid
order by m1.surname, m1.firstname;


-- A LEFT OUTER JOIN operates similarly, except that if a given row on the left hand table doesn't match anything, it still produces an output row. That output row consists of the left hand table row, and a bunch of NULLS in place of the right hand table row.

-- This is useful in situations like this question, where we want to produce output with optional data. We want the names of all members, and the name of their recommender if that person exists. You can't express that properly with an inner join.

-- As you may have guessed, there's other outer joins too. The RIGHT OUTER JOIN is much like the LEFT OUTER JOIN, except that the left hand side of the expression is the one that contains the optional data. The rarely-used FULL OUTER JOIN treats both sides of the expression as optional.
9 changes: 0 additions & 9 deletions database/psql/commands/self-join.sql

This file was deleted.

2 changes: 1 addition & 1 deletion database/psql/commands/simple-join-truncate-date.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- https://pgexercises.com/questions/joins/simplejoin2.html
-- How can you produce a list of the start times for bookings for tennis courts, for the date '2012-09-21'? Return a list of start time and facility name pairings, ordered by the time.
-- Truncate datae DATE_TRUNC('day', b.starttime) = '2012-09-21'
-- Truncate date DATE_TRUNC('day', b.starttime) = '2012-09-21'

select b.starttime as start, f.name
from cd.bookings b
Expand Down
11 changes: 11 additions & 0 deletions database/psql/commands/three-join.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Produce a list of all members who have used a tennis court
-- How can you produce a list of all members who have used a tennis court? Include in your output the name of the court, and the name of the member formatted as a single column. Ensure no duplicate data, and order by the member name followed by the facility name.

select distinct m.firstname || ' ' || m.surname as name, f.name as facility
from cd.members m
inner join cd.bookings b
on b.memid = m.memid
inner join cd.facilities f
on b.facid = f.facid
where f.name ilike '%tennis court%'
order by name, facility;
16 changes: 16 additions & 0 deletions electronics/basics/1-AC-DC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AC and DC
1) AC and DC can be converted to each other.
2) Charging the phone/laptop battery from the wall outlet converts the outlet AC into the phone battery’s DC.

- AC (Alternating current): Alternates/switches the direction the current is travelling many times every second.
- Wall outlet
- Big appliances (fridge, fan, air contditioner)

- DC (Direct current): Doesn’t change the direction. Always travels one way.
- Batteries (phone, laptop)

Direct current (DC) is one-directional flow of electric charge. An electrochemical cell is a prime example of DC power. Direct current may flow through a conductor such as a wire, but can also flow through semiconductors, insulators, or even through a vacuum as in electron or ion beams. The electric current flows in a constant direction, distinguishing it from alternating current (AC). A term formerly used for this type of current was galvanic current ([wikipedia](https://en.wikipedia.org/wiki/Direct_current)).

![electricity](https://upload.wikimedia.org/wikipedia/commons/3/38/Types_of_current.svg)

Reference: https://www.youtube.com/watch?v=r3MFuAdkHEM&list=PLah6faXAgguOeMUIxS22ZU4w5nDvCl5gs&index=2
1 change: 1 addition & 0 deletions hardware/ipmitool/ipmitool.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ IPMI is a standardized interface used for managing and monitoring servers and ot
| `ipmitool sdr` | (Sensor Data Repository) lists the server's hardware components with status (watts, voltage, percent & active status) |
| `ipmitool sdr list` | Lists the status of all sensors. |
| `ipmitool sdr elist` | Lists the status of all sensors with (error) status. |
| `ipmitool sel list` | Lists logs of error events from the System Event Log (SEL), logged by BMC |
| `ipmitool sel elist` | Lists logs of error events from the System Event Log (SEL), logged by BMC |
| `ipmitool bmc reset cold` | a cold reset of the Baseboard Management Controller (BMC) |

Expand Down
9 changes: 9 additions & 0 deletions networking/SFP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPF (Sender Policy Framework)

An SPF (Sender Policy Framework) record is a type of DNS (Domain Name System) record used to prevent email spoofing and to authenticate the email sender's domain. SPF allows the owner of a domain to specify which mail servers are authorized to send emails on behalf of their domain. When an email is sent, the recipient's mail server checks the SPF record of the sending domain to verify if the email originated from an authorized source.

### Key Points of SPF Records:
- DNS Record: SPF is implemented as a DNS TXT record in the domain's DNS settings.
- Authorized Mail Servers: It lists IP addresses or hostnames of servers that are allowed to send emails for the domain.
- Email Authentication: It helps validate the legitimacy of the sender's domain to prevent spoofing or phishing attempts.
- Evaluation: When an email is received, the receiving mail server checks the SPF record of the sender's domain to see if the sending server is authorized. If not, the email may be rejected or marked as spam.
30 changes: 30 additions & 0 deletions networking/VLAN-and-subnets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# VLAN and subnets

VLANs are primarily software-based. Subnets are more hardware-based. VLANs create logical networks that are independent of the physical network topology. Subnets create logical segments of a physical network that reflect the physical network topology.

<img src="https://www.pynetlabs.com/wp-content/uploads/2023/09/VLAN-Example.jpeg" width=1000>

| **Aspect** | **VLAN (Virtual Local Area Network)** | **Subnet (Subnetworks)** |
|------------------------|-------------------------------------------------------------|--------------------------------------------------------|
| **Purpose** | Segments a single physical network into multiple logical networks | Divides logical segments of a network based on IP address ranges and reduce broadcast traffic. |
| **Layer of Operation** | Layer 2 (Data Link Layer) | Layer 3 (Network Layer) |
| **Use Case** | Isolating traffic within the same physical infrastructure (e.g., separating departments, guest vs. employee traffic) | Efficient IP address allocation, network organization, and limiting broadcast traffic |
| **Key Benefit** | Reduces broadcast domains, improves security, and isolates traffic on the same physical network | Reduces broadcast domains, organizes networks, and optimizes IP address space |
| **Relation to Each Other** | VLANs can correspond to subnets, but are not the same thing. A VLAN can have its own subnet or share one. | Subnets can exist within VLANs or span across multiple VLANs. |


## VLAN (Virtual Local Area Network):
- **Purpose**: VLANs are used to segment a single physical network into multiple, logical networks. They allow for the separation of traffic on a switch (or set of switches) into different groups, which can improve security and reduce congestion.
- **Layer**: VLANs operate at Layer 2 (Data Link Layer) of the OSI model.
- **Use Case**: VLANs are often used in situations where you want to isolate certain types of traffic (e.g., separating employee traffic from guest traffic, or isolating different departments in a company) while still using the same physical infrastructure (such as switches).
- **Benefits**: VLANs reduce broadcast domains and can provide security by segregating traffic between different groups within the same physical infrastructure.

## Subnet (Subnetworks):
- **Purpose**: A subnet is a logical division of an IP network into smaller, manageable pieces. It defines a range of IP addresses within a network that can communicate directly with each other without needing to route traffic through an external router.
- **Layer**: Subnets operate at Layer 3 (Network Layer) of the OSI model.
- **Use Case**: Subnetting is often used to create smaller networks within a larger network for more efficient IP address allocation and to limit the scope of broadcast traffic. It also helps in organizing networks by geography, function, or security level.
- **Benefits**: Subnets reduce the size of broadcast domains, help manage network traffic, and provide better use of IP address space.
Key Differences:
- **Layer of Operation**: VLANs work at Layer 2, while subnets work at Layer 3.
- **Purpose**: VLANs are primarily for segmenting network traffic within the same physical infrastructure, whereas subnets divide an IP network into smaller, more efficient units.
- **Interrelation**: VLANs often correspond to subnets, but they are not the same thing. For instance, each VLAN can be associated with its own subnet, but you could also have multiple VLANs within a single subnet or multiple subnets within a single VLAN.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions networking/dhcp/is-dhcp-a-must-for-every-subnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Is DHCP a must for every subnet?

Not every subnet must have DHCP configured. DHCP (Dynamic Host Configuration Protocol) is a service that automatically assigns IP addresses to devices within a network. However, whether or not you configure DHCP for a subnet depends on the specific use case and requirements of the network.

## Options

1. Required:
- In large networks where devices frequently connect and disconnect (e.g., office environments with laptops, mobile devices), DHCP simplifies IP address management.

- Dynamic networks where IP addresses need to be automatically managed without manual configuration.

**1. Corporate Office Networks**
- Scenario: A large office building where employees regularly move between conference rooms, workstations, and different floors.
- Why DHCP?: Employees use laptops, tablets, and smartphones that frequently connect to and disconnect from the Wi-Fi network. Assigning static IP addresses to every device would be impractical. DHCP automates this process by dynamically assigning IPs from a pool.

**2. Public Wi-Fi Networks (e.g., Cafes, Airports, Hotels)**
- Scenario: A public Wi-Fi network serving hundreds or thousands of transient users each day.
- Why DHCP?: Users connect for short periods, and the devices frequently change. The network must automatically assign IP addresses to each new device without requiring manual configuration.

**3. Educational Institutions (e.g., Universities, Schools):**
- Scenario: A university campus where students and faculty connect their personal devices to the network.
- Why DHCP?: With thousands of students, professors, and staff members connecting devices (laptops, smartphones, etc.), manually configuring IP addresses would be overwhelming. DHCP enables automated IP management.

**4. Cloud and Virtualized Environments:**
- Scenario: In cloud environments or virtualized networks where virtual machines (VMs) are dynamically created and destroyed based on demand.
- Why DHCP?: New VMs often need IP addresses assigned on the fly. DHCP servers in the cloud handle this process without manual intervention,
ensuring efficient resource allocation.

**5. Residential Internet Connections:**
- Scenario: Home networks where multiple devices connect to the router (smartphones, smart TVs, gaming consoles, etc.).
- Why DHCP?: Home users typically do not want to configure static IP addresses for each device. DHCP in the home router automatically assigns IP addresses to new devices that connect to the network.

**6. IoT (Internet of Things) Networks:**
- Scenario: Smart homes or industrial IoT networks with numerous devices (e.g., smart thermostats, cameras, sensors).
- Why DHCP?: These devices often connect and disconnect from the network as needed. Using DHCP ensures that each device gets an IP address automatically without manual configuration.

**7. Large-Scale Events (e.g., Conferences, Concerts):**
- Scenario: Temporary networks set up for events where attendees connect to the event's Wi-Fi network.
- Why DHCP?: A high turnover of devices connecting to the network in a short period requires efficient IP management, which DHCP provides.


2. DHCP Not Required

- In networks where static IP addresses are preferred (e.g., servers, printers, or devices that need fixed IPs for consistency).
- Segments of the network where the number of devices is small and static configuration is feasible.

3. Mixed Configuration:

- Some subnets might have DHCP enabled for some devices, while other devices within the same subnet use static IP addresses.
- You can also limit the DHCP scope to assign IPs only within a certain range, allowing for static IPs outside that range.
6 changes: 3 additions & 3 deletions networking/glan-and-vlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ GLAN enhances network speed and performance, while VLAN improves network organiz

### VLAN (Virtual Local Area Network)

**Definition**: VLAN is a method of creating separate, logical networks within a single physical network infrastructure.
**Purpose**: VLANs segment network traffic, improve security, and enhance performance by isolating different segments of a network. They can group devices based on function, department, or application, regardless of their physical location.
**Technology**: VLANs are implemented using network switches and routers that support IEEE 802.1Q standard for tagging Ethernet frames to identify VLAN membership.
- **Definition**: VLAN is a method of creating separate, logical networks within a single physical network infrastructure.
- **Purpose**: VLANs segment network traffic, improve security, and enhance performance by isolating different segments of a network. They can group devices based on function, department, or application, regardless of their physical location.
- **Technology**: VLANs are implemented using network switches and routers that support IEEE 802.1Q standard for tagging Ethernet frames to identify VLAN membership.

## Key Differences

Expand Down