CL - Notes
CL - Notes
19/4 Friday
Content Page
1 - Introduction to Computer Networks 2
1.1 Local Area Networks (LANs) and Wide Area Networks (WANs) 2
1.2 Network Categories 2
1.3 Network Topologies 2
2 - Data Transmission in Computer Networks 3
2.1 Connecting Devices 3
2.2 Network Cables for Wired Network Transmission 5
2.3 Wireless Data Transmission 7
2.4 Network Security 9
2.5 Build a Simple Network 10
3 - Basic Concepts of the Internet 11
3.1 Internet Protocol (IP) Address 11
3.2 Domain Name System (DNS) 12
3.3 Uniform Resource Locator (URL) 12
3.4 Web Hosting 14
4 - Application of Computer Networks 15
4.1 e-Commerce 15
4.2 e-Learning 15
4.3 e-Government 16
4.4 e-Entertainment 16
4.5 Internet of Things (IoT) 16
4.6 Big Data 17
5 - Era of Artificial Intelligence 17
5.1 Artificial Intelligence is Everywhere 17
5.2 How Artificial Intelligence is Changing the World 17
5.3 From Blockly to Python 17
5.4 Python Development Environment 18
5.5 Text-to-Speech (TTS) 18
6 - Super Translation Gadget 19
6.1 Translation Device 19
6.2 Variables 19
6.3 Keyboard Input 20
7 - Smart Assistants 20
7.1 Virtual Assistants 20
7.2 Speech Recognition 21
3.3 Smart Light 21
3.4 Natural Language Processing Technologies 22
1
1 - Introduction to Computer Networks
1.1 Local Area Networks (LANs) and Wide Area Networks (WANs)
LAN (Local Area Network) WAN (Wide Area Network)
➢ In a computer network, data is sent and received by different devices. The role of the devices
are decided by the network structures.
➢ There are two main categories of LANs:
Description Share the same resources and privilege Centralized administrative system
without a centralized administrative (server) is present.
system. → Connect and make requests The server shares files and resources
directly with one another to clients connected to it
2
Limitations of some of these topologies
➢ Ring: failure of a single node or link can disrupt the entire network.
➢ Bus: suffer from reduced bandwidth and increased latency as data must pass through each
node in the ring.
➢ Mesh: requires a large number of connections and can be expensive to implement and
maintain.
➢ Star: failure of the central hub can result in the entire network becoming inaccessible.
The NIC is like a special part of your toy telephone that helps it send and receive messages to other
toy telephones or computers. It converts your voice or messages into special signals that travel
through the wires or air, and it listens for signals from others and turns them into words or messages
you can understand. It's like a little helper inside your toy telephone that lets it talk to others and
understand what they're saying.
➢ Hub: connection point of different devices in the same LAN. Data entering a hub is forwarded
to all devices connected to it.
➢ Switch: connects different devices within the same LAN and directs data to targeted devices
based on their MAC address. Besides, package buffering in the switch prevents data collision.
3
Hub Switch
Network Speed Same network speed for each port Each port has specifically allocated
network speed
Bridge
Router
➢ Link between LANs or a LAN and a WAN and finds the shortest path to the destination for
data packets.
➢ Router can connect LAN to the Internet → commonly found nowadays
Similarity Difference
Both can convert different types of Home routers are all-in-one with multiple functions.
networking signals E.g. wireless network hosting
Both can link between LANs Home routers handle less data
Both can link a LAN to the Internet Home routers have lower efficiency in processing data
Firewall
Access Point
4
Modem
➢ Device used to convert between analog signals (telephone lines or television cables) and
digital signals (computers)
➢ Provided to users by Internet Service Providers (ISP) for Internet connection.
Dial-up Modem
➢ Most traditional type. Converts between digital and analog signals, so that data can be
transmitted through a telephone line.
➢ As dial-up modems only support a maximum transmission speed of 5 Kilobits per second →
mostly replaced by other types
Cable Modem
➢ Makes use of coaxial cables that transmit cable television signals to provide Internet access.
➢ For Internet service using cable modems, the bandwidth is shared with the entire building →
network speed vary throughout the day
➢ Transmission speed: can go over 100 Mbps
➢ Optical network terminal (ONT) that converts between light signals and electrical signals to
transmit and receive data in an optical fibre network
➢ Allow users enjoy high-speed Internet connection.
➢ Contains pairs of wire twisted together → reduce electromagnetic interference (EMI) and
crosstalk (noise from nearby wires)
➢ Mainly two types of twisted pair cables:
5
Unshielded Twisted Pair (UTP) Cable
➢ Consists of four pairs of wire twisted together, e.g. Cat5 and Cat5e cables (for network)
○ Maximum transmission speed of an unshielded Cat5 cable: 100 Mbps
○ Maximum transmission speed of an unshielded Cat5e cable: 1 Gbps
➢ To connect a cable to a device, a connector is used. (RJ45)
➢ To increase the coverage of twisted pair cables, we can use a repeater to connect them tgt.
➢ STP cables are similar to UTP cables, except that they are enclosed by a metal shielding.
➢ STP cables offer more protection from EMI and crosstalk → more expensive
Coaxial Cable
➢ Contains a conducting copper wire core surrounded by insulating materials and braided wires
that is enclosed by a plastic tube cover
➢ Commonly used in computer networks with bus topology.
➢ Silica tube that carries light beams using total internal reflection
➢ High transmission speed and can serve long transmission distances as the amount of data loss
is small. An optical transceiver is used to convert between optical signals (transmission) and
electrical signals (computer use).
Advantage Disadvantage
6
2.3 Wireless Data Transmission
Wi-Fi
Frequency 3.7 / 5 GHz 2.4 GHz 2.4 GHz 2.4 / 5GHz 5 GHz
Wi-Fi 6 is the latest standard for Wi-Fi networks. It has larger bandwidth, which enables users to
upload and download data at a higher speed. It allows more users to connect to a Wi-Fi hotspot at the
same time, supporting high-speed wireless Internet access in densely populated areas.
A Dual Band Router can support both 2.4 GHz and 5 GHz Wi-Fi signals simultaneously. Nowadays,
as many computer-related wireless devices, e.g. bluetooth earphones and wireless mice, use the 2.4
GHz frequency, they might interfere with one another. Hence, 5 Ghz Wi-Fi is created. Although its
geological coverage is smaller, it has a higher network stability.
5G is the fifth generation of cellular network technology. It adopts the newest data transmission
modes that allow a much faster data transmission (10 Gbps). It has larger capacity and lower latency
and can connect a lot of devices at once. This helps facilitate the application of augmented reality
(AR) and virtual reality (VR) technologies and development of smart cities.
7
Satellite Communication
Bluetooth
Zigbee is a network standard commonly used in low-powered devices. It helps connect Internet of
Thing (IoT) or smart home devices like sensors, light bulbs and switches.
8
2.4 Network Security
Encryption
➢ Wi-Fi networks protected by Wired Equivalent Privacy (WEP) can be cracked within minutes
→ introduce security protocols, e.g. encryption, to enhance the security of Wi-Fi networks.
➢ Wi-Fi Protected Access (WPA) is a security protocol addressing the weakness of WEP.
○ Adopts the Temporary Key Integrity Protocol (TKIP), which encrypts data using a
changing key, making it more difficult to crack.
➢ A newer and more complex version of WPA, WPA2, is also commonly used nowadays.
➢ Service Set Identifier (SSID) is a customisable name given by users to a Wi-Fi network.
➢ To protect your home Wi-Fi network, you can disable the SSID broadcast of the Wi-Fi
network, so the network cannot be scanned by devices automatically to prevent unwanted
access.
➢ Avoid using public Wi-Fi hotspots for private purposes, e.g. online banking and stock trades.
➢ Anyone can connect to public networks, hackers may hack into the network and monitor
traffic going through the network.
➢ 3G/4G are considered more secure, only the user and the telecommunication provider will be
using the network, but still have security risks.
9
2.5 Build a Simple Network
Key:
1. Connect the computer and the LAN port of the wireless router with a network cable
2. Connect the WAN port of the wireless router and the modem/another router with a network
cable.
10
3 - Basic Concepts of the Internet
3.1 Internet Protocol (IP) Address
➢ When data is transmitted across computer networks, the addresses of the data source and
destination are appended to the message. These addresses are called IP addresses.
➢ IP address: changeable numerical address used to identify a device in a network.
➢ When a device connects to the Internet, an IP is assigned by the Internet Corporation for
Assigned Names and Numbers (ICANN) through your ISP.
IPv4
➢ 32-bit. Formed by four 8-bit numbers (octet) that are separated by a period.
➢ Range: 0.0.0.0 to 255.255.255.255 (Decimal).
➢ No. of available addresses: 232
IPv6
➢ As IPv4 addresses are going to be used up → IPv6 is introduced as the successor protocol
➢ 128-bit. Formed by 8 16-bit numbers that are separated by a colon.
➢ Range: 0:0:0:0:0:0:0:0:0 to ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (hexadecimal)
➢ No. of available addresses: 2128
1
special code that helps computers on a network know which part of an IP address belongs to the network and
which part belongs to the individual computer. It's like a tool that separates and organizes the addresses so that
the computers can communicate with each other correctly.
11
3.2 Domain Name System (DNS)
➢ Host Name: www (indicating the specific device under the network)
➢ Third-Level Domain: edb/google/youtube (indicating the domain network)
➢ Second-level domain: com/org/gov (indicating organization)
➢ Top-level Domain: hk/cn/jp (indicating country)
https://www.hku.hk:80/about/pm.html
Location
12
Examples of Location
➢ /computer
○ Folder name
➢ /computer/information_techn
○ Refers to a folder called “information_techn” under the folder “computer”
➢ /index.html
○ File name, if the file name is not specified in the URL, it will look for it by default
➢ Hypertext Transfer Protocol (HTTP) is used by the World Wide Web (WWW) to transfer
hypertext web pages.
➢ When a user uses a web browser to browse a website, the browser acts as an HTTP server on
the destination domain. The HTTP server responds to these commands and transfers the
required web pages to the browser.
➢ HTTPS is a more secure version of HTTP, which makes use of Transport Layer Security
(TLS) encryption. It encrypts data during the transmission process to ensure confidentiality,
reliability and privacy of communication between clients and servers. It is commonly used in
trading and transmission of private information on the Internet.
FTP
SMTP
➢ Simple Mail Transfer Protocol (SMTP) regulates mail sending from mail servers
➢ Mail servers rely on SMTP to distribute mail to different mail servers.
IMAP/POP3
➢ Internet Message Access Protocol (IMAP) and Post Office Protocol - Version 3 (POP3)
regulate mail receiving in mail servers.
➢ IMAP: mail will be retained in the mail server after it is received.
➢ POP3: mail server will delete the mail after its first receipt.
13
Operation of different protocols
To make a website, you will have to design the web pages and host them on a web server!
➢ Free web hosting service providers provide web design tools and templates and allow users to
host web pages for free. E.g. Wix and Squarespace.
➢ Allow users to host web pages on their servers with advanced features, e.g. customizable
domain name and e-commerce functionality.
Home Server
➢ Host a website at home using a home server by having the appropriate router settings,
registering a domain and installing a web server software.
Free Web Hosting Service Paid Web Hosting Service Home Server
14
4 - Application of Computer Networks
4.1 e-Commerce
Online Shopping
➢ People can purchase different types of products on the Internet, including computer software,
mobile phone applications, and physical goods such as books, etc.
e-Payment
Octopus Card
Credit Card
Video Conferencing
➢ Facilitate home office, e.g. Zoom and MIcrosoft Teams → conduct video conference
4.2 e-Learning
➢ Electronic classroom resources are uploaded onto an e-platform to facilitate effective and
interactive learning. E.g. tablets,smartphones → conduct activities and get feedback
15
Mass Open Online Course (MOOC)
➢ Make knowledge affordable and easy to access and encourage people from different
backgrounds to learn. Many well-known institutions (e.g. Harvard and MIT) offer courses on
MOOC providers like edX and Coursera → for free, only pay if get certificate
4.3 e-Government
e-Channel
4.4 e-Entertainment
Online Games
Streaming
16
➢ Every photo and every post on the Internet is recorded and combined into the database of big
data. Through analyzing and reading the records, we can build a more advanced society by
improving the practices in different fields, e.g. commerce, medical services and research.
○ Companies learn about the interest & needs of customers by analyzing their browsing
or shopping records and attract them by providing relevant information like ads.
○ Medical staff can speed up diagnosis and devise effective treatment plans.
○ Give accurate weather forecasts, and predictions of extreme weather like typhoons.
○ Investors can make better investments to maximize their profit.
➢ With IoT, data can be collected through wearable devices, e.g. smartwatches.
➢ Potential Risks of invading personal privacy.
➢ AI and automation may gradually replace some occupations which consist of simple,
repetitive tasks and do not require creativity, e.g. waiters, drivers and accountants.
➢ No matter how clever and efficient the AI becomes, humans can still outperform it for our
creative thinking and empathy.
➢ AI can also bring new career opportunities for humans, e.g. AI engineers.
➢ Visual programming allows us to write programs by arranging visual elements, which makes
reading and writing programs easier.
➢ Textual programming offers more flexibility for programming, you can specify the duration
for showing the icons by adding a parameter to the function.
17
Using Google Colab
➢ print(“Hello World!”)
Sequence
Importance of Syntax
➢ Make code concise and readable for easier learning and understanding.
➢ Function library with abundant resources, e.g. graph-tool.
➢ Makes use of AI. Convert text to natural and fluent speech as if a real human is speaking.
➢ Many applications and system provide a TTS function → convenient
import tts
import time
tts.say(“Hello World”)
time.sleep(2)
➢ Import Library → allow us to use the text-to-speech on the Google Cloud Platform
➢ time.sleep → pause; If X import → X execute
print(“Hello World!”)
18
Adding Intonation
import cloudtranslation
chloudtranslation.translate(“how are you”)
6.2 Variables
x = “Hello World”
print (x)
Declaration of Variables
➢ We must declare the name of any variable that we are going to use.
○ Only sart with English letters (A-Z, a-z) or an underscore (_)
○ Only English letters, numbers and underscore can be used. “Whitespace” or other
symbols must not be included.
19
○ We cannot use “keywords / reserved words” as variable names. E.g. import, if, class,
and names of defined functions.
➢ “Hello” → String
➢ nickname,lastname → Variable
7 - Smart Assistants
7.1 Virtual Assistants
➢ Virtual assistant is a kind of AI software that provides users with different services and
supports. Simply give instruction → Complete various tasks.
➢ AI has promoted the development of numerous chatbots. They use conversation models to
perform tasks like answering questions from users, providing advice, etc.
➢ Applied in various industries, e.g. customer service, sales and education.
➢ Usually use the technologies of speech recognition and Natural Language Processing.
○ Speech Recognition: recognize user’s speech
○ NLP: analyze the speech and understand its structure and meaning
Responses Make adjustments based on users’ intention Can only make fixed responses
and feedback, resulting in more human-like based on predefined statements
responses
20
7.2 Speech Recognition
➢ We can identify the voices of different people because a human’s voice generates different
pitches (frequencies) and volumes (amplitude), forming a unique wave.
➢ Such features can be captured by machines through digitalization.
➢ After training and learning, a machine can identify the digital wave of each word → detect
pattern → identify words → “speech-to-text”’.
import cloudspeech, display
print(“Recording…”)
cloudspeech.record(5)
print(“Stop recording”)
display.showWaveform()
➢ Since our sound wave is analog data, the computer converts this analog data into digital data
with the two steps of discretization and quantization.
import cloudspeech
print(“Say something…”)
text = cloudspeech.recognise()
if text == None:
print(“Sorry I can’t hear you.”)
else:
➢ Since the cloud speech service has not received any speech, it cannot return any string and the
final value of variable text is None (None is not a string).
➢ Data validation must be performed before the variable value is displayed.
➢ Hence, we need conditional statements.
Relational Operators
➢ == → Equal to
➢ != → Not equal to
Indentation: Very important syntax → shows the logical structure of program by indicating branch to
which the statements belong.
➢ Nowadays, we can control the lighting in our homes simply by picking up our smartphone
and tapping a button on the screen or giving a simple voice instruction.
➢ A smart home can be created with the help of technology.
21
import display
text = input(“Turn your light:”)
if text == “on”:
display.showImage(“light_bulb_on.png”)
if text == “off”:
display.showImage(“light_bulb_off.png”)
Nested Conditional Statement: Place one or more conditional statements into a branch of another
conditional statement.
IDE can usually help us detect syntax errors and indicate them by error messages. However, we must
test the logical flow of our program repeatedly in order to correct logic errors.
22