networking in general - sharmasadhna/mylearnings GitHub Wiki
subnetmask: has to be different
192.168.
n/working ==> connect devices so they can tx/rx data... Modes of transfer and way of connection can be anything
lan / wan ==> just network connected devices in a area...
ex: devices in a nw in between floors/building is lan...also devices in nw across nearby buildings is also lan. devices connected in nw across cities/globe is wan (wide network)
2 technologies for networking
-
wired == ethernet == uses switches
-
wireless == wifi == uses router/Wifi Access points
Sometimes we have 1 device acting as both switch and router ==> ex: In home
2 technologies to transfer data:
-
copper cable == old == uses electric signals == cheap == data loss chances are more == likely used in home or short distance n/w
-
fiber cable == new == uses light signals == expensive == data loss chances are less == likely used in large n/w/ enterprises solutions Ex: In Germany internet service providers are still using copper cables and that's why internet speed is low different types of copper and fiber optic cable type exists.
MAC and IP address:
MAC address is unique to each nw card on a device, ex: In laptop for ethernet card and wifi card different MAC address are available. We cannot change this address/ in built in the device while manufacturing
IP address: Assigned by device owner either manually or through DHCP
OSI Model --> Do not think as some technology but compare it to analogy of a process involved bw writing a letter (application layer), and sending it to the destination. It's a model how each step fit in the network stack when a data is sent across the network stack. It's just a reference model not all the protocols can clearly be divided into each layer, ex: http webbrowse protocol can not be divided into application/presentation/session layers (kind of include all these 3 in itself and internally uses others at other layers)
The exact steps in process may changes based on many factors, like no of letters/big packet/confedentiality/send within city or globe etc...
Please donot throw sausage pizza away
physical, dataLink Transport Session Presentation Application
In general: --------Upper layers starts here---------------
- Application ex: ftp, web browzing
- presentation ==> Data needs to be in proper file formats, ex: Image and Video formats
- session ==> tracks application processes--> includes remote procedure calls and service requests --> creating session between local and remote HOST ----Upper layers ends here------They have lot of data from USer, but sending this lot of data can be a problem over network, a. one application will hog all the resources b. If the network connection is lost, all data will be lost
----Lower layers starts here---------------
- transport ==> this is important, here the information from above get divided into data... each data will then be assigned with unique header. to send these data to different machines in a nw ==> use port no;s in the header of data. transport using TCP/UDP protocol, with port no(ex: 80 for webserver, 22 for ssh) it knows where to send the data on the other side of HOST, where someone is listening to that port. If TCP is used, reader can request sender to resend the data
- network ==> to send data b/w network, adds the IP address of src and dst in header, adds routing. After adding this header (data+head from transport+head from nw) =packet
** transport(with port number) and N/w(with source Ip and dest IP) together ensures data goes to right location.
- datalink ==> adds another header &or may be a trailer also . Header depends on type of protocol to use for data transfer, IN case of ethernet header contains MAC address ... trailer for error correction. After this data block is now called frame. get's the frame delivered from hop to hop (many routs)
Ex: when I do adb push and my device and laptop connected to switch over ethernet... laptop will add its and device's +IP(n/w layer)+MAC(datalink layer) as headers. Ofcourse, before adb push i should do adb connect == > transport layer adds the port no + nw/ layer add IP address
- Physical layer: copper cable/fiber cable
https://www.youtube.com/watch?v=y9PG-_ZNbWg&t=10s
Wireless subsystem: https://topic.alibabacloud.com/a/linux-wireless-basic-knowledge-mac80211-cfg80211_1_16_30172412.html https://stackoverflow.com/questions/21456235/how-nl80211-library-cfg80211-work
https://mitulmodi.wordpress.com/2012/03/21/android-wifi-architecture-wext/
Subnetting explained
- by Berry Smith:https://www.youtube.com/watch?v=gOOPP-ceToc
- Nice article: https://www.freecodecamp.org/news/subnet-cheat-sheet-24-subnet-mask-30-26-27-29-and-other-ip-address-cidr-network-references/?msclkid=ead0ac82ac3111ec80bbaf7c11962b92
Just a note: when want to communicate machine A and B:
-
On machine A for an interface run ip addr show: it will show
<IP>/<subnet>
. Here,<subnet>
means the IP on the machine B to communicate should have starting bits same to this IP. i.e -
for example If A have 172.17.0.1/16, then B's IP should have <172.17>.x.x (starting 16 bits same) or if A IP is 172.17.0.1/24 then B's IP should be 172.17.0.x (starting 24 bits same)
-
Making subnet 24 is better then 16, so less of IP's can be wasted concept of CIDR s(Classless Inter-Domain Routing) explained in article linked above. So whenver you trying locally to communicate make subnet of 24 or more (can be 27 or anything less than 32) instead of 16 to save IP's. ex: when we tried HOST with Target communication, If Traget IP was 192.168.31.16/16, we setup our HOST interface with 192.168.31.2/24