Uploaded by hussain28022002

network-model

advertisement
Lecture1 - Network Model and Packets
0. Intrduction - Networking
What is a Network?
Networks are simply things connected.
In computing, network is connected devices, from 2 to billions.
Devices could be anything, laptops, mobile, traffic lights, cameras.
These devices communicate sharing data.
What is an Internet?
Internet is a giant Network, consists of many many smaller networks
interconnected.
For A device to communicate in a network to communicate with a device on
another network, it will take help from a middle device (that connects two
networks) to be a messenger for the communicatiuon to take place.
Small networks are known as 'private networks'.
Networks that connects these multiple small networks are called 'Public
Networks' aka Internet.
1. Protocols AND Model
What are Protocols?
Set of rules for the devices, different in architecture, to communicate and
trasnmit data.
MAchines using different hardware and software to communicate.
There are various networking protocols each have its own purpose.
What are Models?
Models are used to represent how networks function.
Standardises and communications between computers and devices.
There are two most commonly used models OSI and TCP/IP model.
Breakdown OSI
1. Physical Layer: Easiest and lowest layer. It references the physical components of
the hardware. Devices used electrical signals to transfer data between each
other in binary. For e.g. ethernat cables.
2. Data link layer: It focuses on physical addressing of the transmission. It adds a
MAC(Media Access Control) address of the recieving endpoint whenever the
data above is send down. NIC(Network Interface Card) works on 2nd layer which
has its own hard coded MAC address. It can be spoofed. When information is
sent across a network, it's actually the physical address that is used to identify
where exactly to send the information.
3. Network Layer: Devices such as routers work on this layer. Routing of data
happens here. Simply determing the most optimal path for the data to be sent.
Everything is dealt with IP addresses here. Routers work on layer 3 as they are
capable of working as a third layer of the OSI model.
4. Transport layer: The transport layer protocols ensure that packets arrive in
sequence and without error, by swapping acknowledgments of data reception,
and retransmitting lost packets. This type of communication is known as “end-toend.” Transport layer protocols at this level are Transmission Control Protocol
(TCP) and User Datagram Protocol (UDP).
5. Session layer: Session layer creates a connection to the computer where the data
is destined for. As the connection is established, a session is created. This layer
synchronises the two computers. Then it will divide the data into smaller chunks
with a sequence number added to each chunk. If the connection is lost only the
chunk which weren't able to send will be sent again. Sessions are unique so data
cannot travel over differnt sessions.
6. Presentation layer: Here standardisation takes place. It performs translation
between the data represented local on the computer and the data which is sent
accross the network and is process independent. e.g a text data or an image
converted into bit stream which is sent accross the network. Presentation layer is
responsible for integrating all formats into a standard format for efficient and
effective communication. Security feature such as data encryption, HTTPS also
occurs here.
7. Application Layer: Application layer is the layer in which protocols and rules are in
place to determine how the user should interact with data sent or received.
Applications such as email clients, browsers, or file server browsing software
which provide a friendly, Graphical User Interface (GUI) for users to interact with
data sent or received as well as protocols such as DNS (Domain Name System),
FTP, HTTP and SMTP. It works almost exclusively with applications, providing an
interface for them to use in order to transmit data. When data is given to the
application layer, it is passed down into the presentation layer.
Breakdown TCP/IP
1. Network Interface layer: Physical layer and Data link layer (OSI model)
2. Network Layer : Same as above
3. Transport layer : Same as above
4. Application layer : Application, Session and presentaion layer (OSI model)
What are Model layers and Protocol layers
OSI model has 7 layers with each layer defines a specific function in a networking
environment.
TCP/IP on the other hand has 4 layers, it is comparatively staright forward and
simple to understand as well as which is used in modern days.
Every layer on the model has a specific function and they work on top of one
another.
Each layer has its own protocols running on it.
These protocols are often conceptualized in a model consisting of a series of
layers, each of which deals with one functional aspect of the communication.
Each layer serves the one above it.
for e.g Application layer doesn't need to know how to connect to the host and
send data or identify the host.
Encapsulation and de-encapsulation
The entire packet(data and header) is sent down to lower layer which then add
its own header treating the recieving packet as payload. This goes on till the last
layer. This is called encapsulation.
As data is passed down to the lower layer, more information related to the layer is
added to the data. It keeps repeating till the last layer and data is trasmitted to
the other computer.
De-encapsulation happens when data is recieved by other computer and it
breaks down the information into simpilar pieces taking away the header and
sending it above to the upper layer. It happens in reverse order.
Starting at the physical layer and working up until it reaches the application layer,
stripping off the added information as it goes.
The process of encapsulation and de-capsulation is very important as they give
us the standardised method for sendind data. This means all the transmission will
follow the same methodology, allowing any device on the network to send data
to any other device and be sure that it will understand, regardless what hardware
or software it uses.
2. Frames
Hub - Works on layer 1
Switch - Works on layer 2
Frames - chunk of 0s and 1s aka paketized data
Frames contains data from applications.
Frames are generated in NIC when data is sent to NIC(layer2).
Sent to the Network.
Frames are broken on network card and data is sent above.
3. MAC addresses
Its a physcial address hard coded to a NIC card attached to the device which
allows it to communicate over the network.
48 bit address. 12 hexa values. 6 pairs of hexa value. Each value is 4 binary
number.
First half, 3 pairs is known as OEM(Original Equipment Number) identifier.
The other half is hard coded ID number on a NIC.
They are used to address the frame to a particular computer which we want the
data to send.
On a network, if you need to send a data frame to a computer, we will add two
MAC addresses to the frame.
One is the Source MAC which is our NIC address and the Destination address
where the data is going to be recieved.
One other thing which is added to the frame is a CRC(cyclic redundancy check),
it verifies if the data is good or corrupted. If corrupted it will be sent again.
On the other hand where the frame is recieved, the NIC will check the MAC
address of destination, if its for the device, the NIC will strip the extra information
(MAC addresses and CRC) and send the data above.
However if the MAC address not for the device, the frame will disappear.
4. Broadcast and Unicast
When you want to send the a frame data to a specific address, the destination
MAC address is added along with the source and data. This is called UNICAST.
When you don't know the MAC address or when you want every device on the
network to view your packets. A broadcast i sent. 'FF.FF.FF.FF.FF.FF' is a
broadcast address.
5. IP addressing
IP addressing are also called Logical addrressig.
They are used to identify a particular network.
The first three numbers in a IP address is called a neetwork ID.
The last number will be different for each device connected to the network.
They aren't fixed for any network card. It can change accordingly.
If we want to communicate to a device on another network with different
Network ID, we use Routers.
Routers work on layer3 of OSI model.
Routers connect two or more smaller networks to communicate with each other.
For communication to take place, we will add another extra information in our
frame. That information is called IP addresses. Source and Destination both.
Within our frame, if we remove MAC and CRC, we get an IP packet. Packet sits
within a frame.
Now to semd the packet to the destination IP. The computer will put the frame
around the IP packet, it will contain the source MAC address of the computer and
destination MAC address of the router also known as default gateway.
The default gateway or router will recieve the frame and strips away the frame
stuff leaving the packet.
The router has a built in routing table which routes the incoming traffic to other
routers or the device based on the network information.
The router will get the MAC address of the device and add around the IP packet
as the destination MAC and the router MAC as the source.
IP packet never change during the whole commuincation. Frame does couple of
times.
6. Packets and Ports
Once you recieve the packet, the computer doesn't know where the data should
be sent.
The piece of data should sent where? so it can crumbled up to form something
human readable.
To deal with where and which appllication should the data arrive at, we added an
extra information in the IP packet called port number.
There is destination port number(where the server is listening to the connection)
and the source port number(where we are starting the connection from).
Port numbers are unique to individual applications that are used all over internet.
For e.g. port 80 is used to define web pages of the server the computer is
communicating with.
There are 65535 port numbers, 1024 are reserved so we can't use these port
numbers for return listening port.
For the data to get in a human readavle format, TCP and UDP connections are
used and session layer above which make sure all the data is trasnfered as they
got sequence number attached to it.
As the data is recieved the computer sends an acknowledgement packet to
confirm the recieving of the packet.
7. Walkthrough of OSI and TCP/IP
In layers 7,6 and 5, the data is simply referred to as data. The port number are
added to the data to point out which process needs the data in the system.
In the transport layer the encapsulated data is referred to as a segment or a
datagram (depending on whether TCP or UDP has been selected as a
transmission protocol). Each piece is has a sequence number added so when the
data is collected at he recieving end, it knows where ro be placed.
At the Network Layer, the data is referred to as a packet. When the packet gets
passed down to the Data Link layer it becomes a frame, and by the time it's
transmitted across a network the frame has been broken down into bits.
8. Headers of IP packet
An IP header is header information at the beginning of an Internet Protocol
packet.
An IP packet is the smallest message entity exchanged via the Internet Protocol
across an IP network.
IP packets consist of a header for addressing and routing, and a payload for user
data.
Download