侯智晟
meowheckerouo@gmail.com
[TOC]
# Switch

How a beautiful device!!! XD
I love it so much
switch is helping out computer to connect to each other talk, hung up, chat and send data
we could use a cable to enter its body (Hey hey :smiling_imp:

Waht is going on inside of switch !!!!
It's good question
## Ethernet cable

it sends electrical signal going in and out of the port
## Switch Predecessor
the one that came before them is hub he's disguising and dump XD
the switch is smart but hub is not
Hub is big mouth XD
It will tell message to everyone who plugs it (broadcast)
## Packet tracer
Download cisco packet tracer
https://www.computernetworkingnotes.com/ccna-study-guide/download-packet-tracer-for-windows-and-linux.htm
## Hub

if when you sent a text to your friend, it didn't just go to your one friend it went to all your friends.
And then when your friend response back to you it only went to you but it went to all friend as well XD
that's stupid right?

ping message is used to see if other computer or server are up and can be reached


what did you do that XD

hub is idiot, he's got not brain
he job is repeat electrical signal whenever your computer sends down wires.
hub is going to go and send out to everyone.
## Switch Workflow
the switch can do all this magic because he has brain, he'll remember where they are
switch port interface, he store that information in something called the CAM(contents address memeory ) table
the switch don't know johnny as johnny.
the swtich know johnny as layer 2 Address


Information at PC 0

Information at switch
Switch is lay 2 device which only care about layer 2 information (it don't care other people

Information at PC 1

## Switch CLI
```
enable
# show mac-address-table
```

he just know PC 0 PC 1, but he didn't know PC 2
But doesn't matter, he has the brain .
He can learn it and store it, if PC want to ping or receive ping message from other PC
So, he learning where everyone is by learning their mac address. (CAM)
## Frame
ALL in the layer 2 message we called frame (switch,frame layer 2)
## wireless access point
they're basically doing the same job as the switch, but they more like the hub than switch

AP just an extension of the switch, SO we can use AP to connect to switch with an Ethernet cable.




That's why wireless connection more like the hub.
In fact, all the message are going to each device is not worst part with hub.
It's just a traffic jam collision all the time which is switch is great.
## Quiz

the answer is D
because ,Ethernet frame is created which would contain the source mac-address as that of PC1 and destination mac-address of PC2.
[reference link](https://www.networkshelf.com/how-does-a-switch-populate-cam-table/)

the answer is D
# Router
Router

Router connect us to the internet they also connect this to other networks
ARP
source MAC -> broadcast MAC(FFFF.FFFF.FFFF)

And then our ARP message are going to where


ARP Response



Router between the network has the map of how to the thing

## DNS Server





---
Now we get destination IP form the DNS server.
we can use http to get web response.

Request

Response

# TCP/IP & OSI
## Network model
The model we used to day is called TCP/IP, this is what every computer supports and has implement into their system the TCP/IP mode and they also call TCP/IP stack.
TCP/IP
The tradition view of TCP model
- application
- transport
- network
- data link
- physical
OSI
The view of OSI model
- application
- presentation
- session
- transport
- network
- data link
- physical
Quiz

ans:A
note:
WAP is wireless access point, this was kind of trickly one, because they do operate at layer 2, they also operate layer 1
Question is primarily at layer 2,So that primary focused on layer 2
So, we can select D option.

ans: A, C
## Life Example
Consider at the following figure!!
If Johnny want to buy the delicious coffee, how network help with Johnny.

Ok Now, he have to use transport layer to transport his packet, and this way he have two options.
One is TCP. another is UDP
Versus
tcp -> reliable
udp -> more fast
port 443 -> https
port 80 -> http

**Network layer**
deal with ip address and routers
**Data link layer**
We're deal with mac Address we're giving our switch direction to the next stop

the ip address information inside a new layer 2 header and he change the source and destination mac address

Quiz 1

Ans : a c e
B and D is impossible
B: Because delivery should be layer 4 to deal with, ensuring -> TCP
D: logical and physical addressing -> probably is layer 2
f: It is presentation layer 6

Ok this problem is fucking easy, if you know 3-way handshake
Obviously, the answer is B
## Application layer
The application layer is kind of the portal an interface for a program on the computer that need the network like the web browser or video game that you play online

## Presentation layer
Presentation layer is responsible for making it presentable
The two of the main thing you're going to be worried about is data format and encryption.
- Data format
- file type (like .pdf , .html, jpg, .xml ...)
- Encryption
> - SSL(security socket layer
Making sure our data that's being sent back and forth can't been seen by old hackers XD
That's done at the presentation layer so what the presentation layer is done with our data he's made it look pretty putting into the right form.

## Session layer
the data jump off the session is to open up the communication to start the conversation between your application and web server
- make sure things
- have been authenticated
- conversation is smooth
All the stuff still going through all the other layers and brunch of thing are happening.
It's manage all those different session on your computer
### protocol
#### L2 TP (layer 2 tunneling protocol
we'll see this a lot of vpn connection
#### RTCP (remote transport control protocol)
it's helps set up phone calls and speaking of the phote calls
#### h.245
h.245 which helps set up the video calls
#### socks
socks proxies also operate at this layer, when you're trying to hide yourself as a hacker XD.
## Transport layer
TCP is so reliable because TCP is kind of naggy XD
TCP (transport controls protocol)
It with strong emphasis on control because it want to control every bit of communication.
UDP
Do you know Why UDP is fast, because it doesn't care if you get the message.
It's doesn't wait for verification.
it just only send send send send send send XD
If we open youtube what happen will occur?
let us try it
TCP (video)

UDP(html.body)

### Port
FTP port : 21
SSH port : 22
RDP port : 3389
Port 59889 is ephemeral port.
## Quiz

TCP: FTP, HTTP, SMTP
UDP: DHCP, SNMP TFTP
TCP and UDP: DNS

Answer: C
# Network Design
## BAD Network :-1:
Now to find the bad network we don't have to look very far. just look in the house.
Basically, home network is suck. XD
A lot of businesses when they first start out their network look very similar to a home network. they make some big boo-boos some very big mistake.
### Home Network
In the home network, your route isn't just your router. It's also your switch your modem even your web

So, it's doing a lot of which is a horrible thing
Uh,I think you don't want one device doing everything. :laughing:
### Small Business

Hold on a second, if the switch out of the port, we have more thing to connect more computers or devices
We need more port to connect device to the network.

Hold on, what did you do !!!!!!!!!!
what did you do !!!!!
what did you do !!!!! :rolling_on_the_floor_laughing:
I am sure a lot of you know network that's probably scaring you

This is baddddddddddd
The problem is if the cable breaks, other switch will gone
A single point of failure, don't ever have those in your network ever :no_good:
Daisy chaining our switches together. Don't do that
So, how can we make it better?
## The 2-tier Network Design
Multilayer-Switch(L)
Multilayer-switch can deal with ip address and mac address, and it's blazing fast

### Distribute layer
Distribute layer's job is to distribute all the packet and all the frame through the network.

### Solve the single point of failure between the router and multilayer-switch
We can add one more distribute layer switch

man look at all that redundancy it's beautiful but it's expensive. ok this is ideal, a lot of companies aren't willing to pay that much for stuff.

## the 3-tier network Design
Core layer

He just fast. XD
He associate with low latency and high reliability.
it as the network backbone.


## 2-tier network design
it combines with the core layer with the attribute layer, and called it the collapsed layer.
the function of the core was collapsed into the distribution layer.
they have to do
- a bunch of the routing
- inter-VLAN routing
- access-control list
- network backbone
# Data Center Networks
## Concept
A data center is all about severs connect to things or the internet
Google data center

full of servers, routers and switchs
Pretty much any resource you access over the internet is going to be inside a data center
---
Do all companies have and use data center?
Ans: Yes
But not all in the same way
Example
Meowhecker.com is online through a website that lived on a sever
Offer server options
- You can build one room or one rack in your home or company
- Rent space in a data center (majority)
- Cloud

## Old Data Center Network Design
Rack
each of these racks would have a bunch of server
Tor switch is at top of the rack
### Virtualization
#### East-West traffic
With virtualization, our data center become more distributed which basically means that server can communicate with each other that we called east-west traffic.
But now, the problem is that we didn't design our network for east-west traffic
East-west traffic accounted for the majority of our traffic

it only can handle north south traffic(server-client), that is problem with this design.
## Spine-leaf design
We need something faster, something quicker
### leaf switch
They're still going to server the function of being the access layer for the server in those rack.
Each of leaf switch is connective to every spine switch
### spine switch
spine -> backbone
Spine (Backbone) is like you body support the entire network has to handle the most bandwidth, most packet going through it.
### Why is this better?
Because of
- We care about east west traffic (server-server)(70-80% of our traffic)
- It go to another server just only two hops, always and all the time.
Notice: these connection switch to switch is not layer 2.
leef switch and spine switch they're both layer three switch or multi-layer switches
We don't worry about any one of links be blocked by spanning tree which is loop prevention mechanism.

Layer three routing

Topology Network

## Quiz

leaf/spin node = leaf/spine switch
ANS: E
Because the leaf switch can't connect of each other.

Ans:B, E