Network Fundamental
Network Fundamental
Chapter 1 : Introduction
types of network : Local Area Network (LAN), Wide Area Network (WAN), Internet and
Intranet.
To deliver the messages to desired end-devices, we use their unique postal code,
"IP address". (Internet Protocol)
In fact, IP addresses are 32-bit binary numbers, but for readability, we convert
them into "Dotted Decimal".
The Network portion represents a groups of common IP address, Host portion is added
to uniquely define each IP address within that group of IP addresses.
In order to know how long is network portion and host portion, we use "Subnet
Masks".
IP Classes :
Class A starts with '0', B starts with '10', C starts with '110', D start with
'1110', E start with '11110'.
Class A :
Subnet Mask : 255.0.0.0, thus the network portion ranges from 00000001 to 01111110
(i.e. 1 to 126)
It seems that 127.x.x.x is the highest assignable IP address, but such address is
reserved for loopback address.
Class B :
Subnet Mask : 255.255.0.0, thus the network portion ranges from 10000000.00000000
to 10111111.11111111 (i.e.128.0 to 191.255)
Class C :
Class C IP are assigned to all groups that do not meet the qualifications of Class
A n B.
Class D :
Subnet Masks is None, as there is no Host address, in other words, Network portion
takes up whole 32 bits.
As it must start with '1110', it ranges from 224 to 239 in the first octet. ( i.e.
11100000 to 11101111 )
Class E :
Since it starts with '11110', it ranges from 240 to 247 in the first octet ( i.e.
11110000 to 11110111 ).
the reason why we minus 2 : we exclude two cases, all '0's and all '1's, reserved
as "Network Address" and "Broadcast Address" respectively.
However, Class A has a 24-bit Host Address, some countries don't need 16.7 million
unique addreses.
We still can use Subnet Mask for this, namely all '1's for Network portion and all
'0's for Host portion.
For eg, 11111111 11111111 11111111 11100000 = 255.255.255.224 is the Subnet Mask
for / 27 classless notation.
Local Area Network, as defined, are used within a small region, eg. a building or a
campus.
In a LAN, the end devices (normally laptops) have common "Network Portion".
In other words, end devices having different "network portion" are considered to be
belonged to different networks.
Let's say we have LAN A and LAN B whose IP addr. are 10.10.10.x and 20.20.20.x
However, we can add a router in between, so as to route the IP packets and serves
as a "Gateway" for the LANs.
Especially when they have different " network portion ", the first LAN will be
connected to the default gateway of the router ( normally named as E0 ), and other
ports connected to other LANs, so that they are inter-connected.
And, there's not only one default gateway in each router, every LAN connected has
one.
For eg, LAN A is the first LAN connected, then the default gateway should be
"10.10.10.xx".
And all the end devices in LAN A should set it as the default gateway.
So we already knew what is the router and how does it work, but why there is such
thing?
What if the routers connects to a lot of LANs? What if there're a lot of routers?
A huge WAN that span over very large geographic area is built up by this.
Btw, when there's a lot of routers connected in between, it will automatically find
the best route.
These are all theoriotical things about it, let's see what it's like in reality.
Though I can't paste a pic here, though my desciptive essay is awful, I can simply
state the name of the ports.
As you can imagine, Ethernet Ports are connected to the LANs, Serial Ports are
connected to other routers ;
Console Port is connecting to the COM port of computer, acting like a terminal.
We use Black solid lines for straight-through Ethernet cables and red dashed lines
for serial connection.
( one more tip, ipconfig function displays IP address, subnet mask and default
gateway for all adapters )
And it is taken back when no longer needed. (when the host disconnect from the
network/LAN)
For a valid IP address, the host portion can be anything between 00...001 and
11...110.
Network Address is considered as Network ID, as the host portion is all '0's, we
can easily get the Network portion.
Broadcast Address is to "broadcast" messages to the end devices, and the host
portion is all '1's.
And the host address is normally what we used for communication, simply exclude
these two cases will do.
Basically, once the host is connected to the network, it requests the DHCP server
to provide related information, including IP address, subnet mask, defalt gateway,
DNS server, etc.
DHCP server is a software service that may run on router or another computer.
The disadvantages :
What happens if both Static IP address and Dynamic IP address are needed?
Servers like File server, network printer and DHCP server use Static IP Address ;
While computers and laptops (mobile devices) use Dynamic IP Address.
Then for Static IP address, allocate IP addresses outside the dynamic pool. (eg.
1.1.1.70 to 1.1.1.99)
Chapter 5 : Subnetting
We need to borrow n bits from the Host portion, which 2 ^ n ≥ no. of groups.
So we borrow 2 bits here, which means the first two bits of the host portion will
be 00, 01, 10, 11 in sequence.
Take note that, for each group, the first address is reserved for Network ID and
the last one is broadcast address.
When all the subnets are equally long, some subnets doesn't need that many, some
subnets need even more.
Like the interconnection between the routers actually only needs two hosts to
distinguish between them.
That leaves a lot of IP addresses unused, that's why we introduce the Variable-
Length Subnet Mask (VLSM) .
So it collects the number of host addresses needed for the subnets, and arrange
them in descending order.
For each subnets, determine n bits in host address where (2^n - 2) ≥ no. of host
addresses needed.
Then allocate a block of 2 ^n IP addresses to that subnet. Reserve the first and
the last address. U know what's it for.
So the way we replace a complex IP address with a simpler Domain Names is called
Domain Name System Service.
Firstly, when a domain name is entered into the web browser, a domain name query
("DNS query") is sent to a DNS server. Then, the DNS server returns the
corresponding IP address and the web brower accesses the IP address.
In short, DNS service is a translation between readable domain names and their
exact IP addresses.
A hidden benefit is that, IP addresses might change but domain names can remain the
same.
Obviously, there are countless websites, so the DNS servers must have a massive
database storing different types of resource records including name, address and
type of record.
Type of record :
- A stands for Address, a pretty normal end device address.
- MX stands for Mail Exchange, obviously, when u send an email message, u want all
the recipients see it.
- NS stands for Authoritative Name Server, it gives an answer to a DNS query.
- CNAME stands for Canonical Name, used for a single network address but multiple
ways to enter.
Name :
- Strings of characters seperated by dots, eg. www.sp.edu.sg
- the last word represents a Top-level Domain (TLD) :
- COM : Commercial websites opened to everyone
- NET : Network websites opened to everyone
- ORG : Non-profit organization websites opened to everyone
- EDU : Restricted to schools and educational organisations
- GOV : Restricted to the governments
- two-letter country codes like UK, SG, MY...
- example : www.yahoo.com
- www = a host name
- yahoo = second-level domain
- .com = TLD
In Windows Operating System, a function called nslockup can show the exact IP
address and DNS server used.
Also, when a computer connects to the network, the DHCP server sends a bunch of
info including which DNS server to use.
Hierarchy of DNS :
- firstly, from Root DNS servers, we get to know which Top-level Domain Server to
find, let's say TLD 6.
- then, from Top-level Domain Servers, TLD6, we get smth like "CompanyA.com".
- lastly, from Secondary level Domain servers, CompanyA.com Local DNS server, we
find the record of "mail.CompanyA.com"
When the DNS client makes a query, once the DNS server finds a matching result, the
server stores the returned address in its cache. If a match cannot be found, the
DNS server returns an error indicating the name is invalid.
If the same name is requested again, the server can return the address stored in
cache straightaway.
All the domain names have to be different, cuz it'll be terrible to see thousands
of fake google website.
Each domain registration becomes part of central domain registratin database, known
as the Whois database.
You might need to browse Yahoo webpage using Firefox, watching Youtube video using
Chrome and sending emails using Outlook at the same time.
But you only have one IP address for your laptop, how does it manage so many
incoming and outgoing requests ?
OR in other words, how did the IP addresses in the IP Packet find the correct
application or process?
In order to sort out the IP Packets, "to make Web Yahoo goes to Firefox, Web SP
goes to Fire fox, Skype goes to Skype, Email goes to Outlook, File goes to Bit
Torrent", we need to provide seperate data channels, using Transport Layer
Protocols.
Network Protocols :
There are many kind of different protocols, each performing certain networking
functions.
To put it simply, it reasonably divides the IP Packets into groups and layers the
groups.
But it allows each layer of network uses the protocols and software of the layer
below it.
And it also allows each layer communicates with the layer above it so that the
higher layer use the resource it provides.
There are two types of layered network models : OSI Seven Layer Model and TCP/IP
Model.
History Time!
In 1977, ISO created a committe to unify networks, they established the concept of
an "Open System".
They also defined an Interconnection Reference Model, which defines seven layers of
communication protocol.
And this "Open System Interconnection (OSI) Reference Model" is now accepted for
use in data communication networks.
When data is sent from the source host to the destination host, the data goes
through :
- encapsulation at the source host
- de-encapsulation at the destination host
The former is to add headers to the data and the other is to remove the headers.
(Packaging and Unpackaging)
( Each layer add one header in encapsulation, and the last one, physical layer,
convert them into bits. )
TCP/IP Model :
For Internet as well as other similar computer networks, a set of protocols known
as "Internet Protocol Suite" are developed.
Comparing the seven-layer model, TCP/IP Model are organised into 4 layers :
Actually, it combines Application Layer, Presentation Layer and Session Layer into
Application Layer ; Data Link Layer n Physical Layer into Network Access Layer.
Well, these two models sound equal, so in this module, we use both models.
The only reason for the Transport Layer being blank is that we are going to discuss
in details.
It is fast but unreliable, as the sending host does not expect for acknowledgement
from the receiving host.
TCP is less efficient than UDP as TCP has a much longer header (variable, from 20
to 60 bytes) than UDP (only 8 bytes).
If we are looking for reliability, use TCP ; If we are looking for speed, use UDP.
Internet Sockets :
the Sending application uses "Source Port" and Receiving application uses
"Destination Port".
And some port numbers are reserved for commonly used applications :
eg. web service - Port 80 ; File Transfer - Ports 20 and 21 ; Telnet - Port 23 ;
Email (SMTP) - 25 ; DNS - Port 53.
Registered Ports ranges from 1024 to 49151, it's used by end user applications as
ephemeral source ports.
Both Source Port and Destination Port fields ar available in TCP and UDP headers :
The sending process's port number becomes the Source Port number and Destination
Port number will indicate the recipient.
When the receiving host replies, the Source Port number and Destination Port number
are swapped.
Just take note that, it can be wired connection or wireless connection (Internet).
Command " netstat -a " on Windows computers checks what TCP and UDP Ports are
opened on the computers.
The firewall sometimes blocks the port number request, AKA the application will not
work successfully.
U might also want to block unused TCP and UDP Port numbers in ur firewall for a
better protection.
IPv4 uses 32 bits for addressing, providing 2^32 = 4.3 billions different IP
addresses.
Some IP addresses are reserved for special purposes, eg. Local Loopback IP
addresses : 127. x. x. x
Class D = 224. 0. 0. 0 to 239. 255. 255. 255 and Class E = 240. x. x. x - 254. x.
x. x
Though 3.7 billions sounds like a lot, world population is 7 billions, each person
may have multiple communication devices.
Thus a temporary solution is the sharing of IP addresses. (while the long term
solution is IPv6)
How do we share the IP addresses?
Public IP addresses are IP addresses that routers in the Internet will route.
Private IP addresses are IP addresses using in private networks only, and routers
will not forward packets destined for them.
Obviously, It means that Private IP addresses can only be used in a LAN, thus we
can use repetitive IP addresses since it's not connected to the Internet, just make
sure that we don't have repeating IP address in a single LAN will do.
Public IP addresses are IP addresses that can be assigned to Internet users by the
ISPs.
In other words, it includes all other available IPv4 addresses that are not
reserved for :
- local loopback
- private IP addresses
- Class D (multi-cast address)
- Class E (experiment address)
The whole point of NAT is that, the router connects a LAN to the Internet,
translates a private IP address to public IP address before forwarding to the
Internet, and translate reversely when it receives IP packets from the Internet.
The header contains 12 compulsory fields, two fields used by NAT are Source IP
address and Destination IP address.
When forwarding to the Internet, NAT, or the router modifies the Source IP Address
field ;
When receiving from the Internet, the router modifies the Destination IP Address
field.
You might expect some calculations to be carried out for the translation, but, no.
There are four types of NAT : Static, Dynamic, Overloading and Overlapping NAT.
Static NAT :
In the name, the translation of the private addresses are fixed, useful when a
device in the LAN needs to access the Internet.
Dynamic NAT :
The mapping of private-public IP addresses is dynamic, depending on the available
public IP addresses at that time.
Overloading NAT :
This is a very special type of NAT, where all the private IP addresses have the
same public IP address available for translation.
It happens when ur modem (ADSL, Cable, ONT) is connected to the Internet, the ISP
issues a single, temporary, public IP address to ur modem in which all ur laptops,
computers and mobile devices use the private IP addresses issue by DHCP.
When it receives an IP packet from the Internet, and the destination address will
be the sharing public address.
As all the devices in that LAN use one public address, how can the broadband router
tell which IP packet is for which device?
The answer is, use IP address + Port Number (Transport Layer) to differentiate the
IP packets.
So that the translation occurs between {Private IP Addr + Private Port} and {Public
IP Addr + Public Port}.
One thing to take note of, during the translation, the private port number changes
to public port number as well.
Like :
- HomeCam1 - {192.168.1.181 : 6001} <==> {Public IP address assigned : 5001}
- Web hosting - {192.168.1.200 : 80} <==> {Public IP address assigned : 80}
These are not random names, normally in a home network, there are three IP cameras
and one Web Server.
The Private IP addresses fo IP cameras and web server are configured manually,
though it's possible to use "DHCP Reservation" to assign IP addresses to the four
devices automatically, there's no obvious advantage in doing so.
The Port Numbers are chosen arbitrarily, while the port number of the Web Server is
80. ( port number for HTTP service )
Available IPv4 Addresses ( Classes A, B and C ) are around 3.7 billions and it's
insufficient for growth in Internet nowadays.
Although we've discussed how we use Public IP and Private IP to solve this, we also
mention that IPv6 is the ultimate solution.
IP addresses are assigned by IANA, through the Regional Internet Registries (RIRs).
IANA = Internet Assigned Numbers Authority, 5RIRs = AfriNIC, APNIC, ARIN, LACNIC,
RIPE NCC.
the Depletion of IPv4 address space has been the main reason for moving to IPv6.
It is anticipated that all five RIRs will run out of IPv4 addresses between 2015
and 2020.
The inventor of IPv4 must think that, hmmm, there's less than 4 billion population
in the world, how could it possibly run out?
And the solution isn't anything new to us, it just extends the length to 128 bits.
Now for sure, we no longer have to worry about whether it's enough to use, but here
comes another issue.
That is, if we are asked to write down all 128 bits, it'll take a lot of work.
It still looks very long, maybe we can delete all unnecessary zeros (except for
those hextets only have zero).
And actually, ":0:0" has no meaning, it's the same as "::", so we should replace
with the compressed representation "::".
IPv6 addresses also have Network Portion and Host Portion, but it doesn't needs
subnet mask to indicate the length of them.
Instead, they use prefix like "/64". (Actually, why not apply this to IPv4? Isn't
it much simpler?)
Unicast Address
- Global Unicast : Internet-rountable and globally unique, starts with "0010" or
"0011", eg. 2000 :: /3.
- Link-Local : it's for communication with local devices, not routable beyond the
subnet. eg. FE80 :: /10.
- Loopback : it's used for testing the configuration of TCP/IP on the local host,
and it's represented as ::1 /128 or simply ::1.
- Unspecified Address : it's all-0's address, cannot be assigned to an interface,
shows the device doesn't support the service.
- Unique Local (not discussed)
- Embedded IPv4 (not discussed)
Still, you can use the powerful command "ipconfig" to show IPv6 configuration in ur
laptop.
If u feel that IPv6 is similar to IPv4 and it's much better, then you are right.
But here comes a question, why on earth does IPv4 still exist?
The answer is pretty interesting, cuz there are still billions of existing devices
that only support IPv4.
So we are making troubles for ourselves now, as we have to find a way for IPv4 and
IPv6 to co-exist.
Tunnelling encapsulates the IPv6 packet inside an IPv4 packet, like digging a IPv6
tunnel in IPv4 soil.
Translation is very straight forward, it translates between IPv4 addresses and IPv6
addresses using NAT64.
Through translation technique, IPv6-only devices can communicate with IPv4-only
devices.
CONGRATULATIONS !!
THIS IS THE END OF THIS COURSE, BUT YOU HAVE A LONG WAY AHEAD OF YOU.
^-^
__
/> フ
| l
/ヽ _ ノ
/ |
/ ノ
│ | | |
/ ̄| | | |
| ( ̄ヽ__ヽ)__)__)
\二つ
へ /|
/∠ ∠ _/
/ │ / / ^
│ Z _,< / / \
● ⊃●
⊂ ⊂⊃〈 /
() へ | \〈
>ー 、_ ィ │ //
/ へ / ノ<| \\ \
ヽ_ノ (_/ │///
7 |/
>―r ̄ ̄`ー―_
Picachu ~
What's even more embarrased is, I firmly believe that an IPv6 address is 64-bit
long.
I've tried to change the answer of every qn except for that qn, yet I always got
one wrong.
Until the attempt 9 of 10, I was like, ok, it's try to change this.
And I was laughing at myself, like "How could it possibly be wrong? I'm just being
accurate".
Then it blows my mind when the see the grade is 10/10 instead of 6/10.