Automotive Ethernet_草稿

时间:2024-10-08 16:03:35

1. Network Topology

most of the case is star topology, switch at the center, connected with MCU

example 

2. standard ethernet vs automotive ethernet

This frame structure is identical for both Ethernet and Automotive Ethernet because both adhere to the same IEEE 802.3 standard.

VLAN is optional:

MAC:

physical address means MAC address, here is an example for Wifi adaptor 

first 3 bytes represent for manufacturer 

3. Internet

LAN:

router:

  • WAN: 
    • This port connects the router to the external network, typically the internet
    • Devices on the WAN side use public IP addresses to communicate
  • LAN: 
    • These are the ports (or wireless connections) that connect devices within your local network to the router, such as computers, smartphones, printers
    • Devices on the LAN side can share files between each other, use local printers, or access the internet via the WAN
    • Devices connected to the LAN side are assigned private IP addresses by the router's DHCP server
  • DHCP: 

注意:

  • router下面的LAN 是依靠MAC地址寻找到目标的设备的
  • Internet下面本质上就是一个个LAN

larger LAN:

Internet:

Internet本质上就是把上面的larger LAN 无限复制扩展,实现了任意电脑的互相连接

MAC:LAN下相互通讯依靠的是MAC

IP:

  • 跟LAN外部通讯依靠的是IP,这个分发/转发工作依靠router上的WAN口实现,这就是为什么router上总有一个颜色为蓝色的口,这就是向LAN外部传输的WAN口 【路由器先检查MAC,如果该LAN下没有就通过WAN口发出去】
  • 这也就是为什么需要配置DNS的IP地址,说白了只要有IP地址就一定能通过router最终分发到指定的设备,DNS 的作用就是把网址转化成IP地址
  • 只要有IP地址就一定能通过router最终分发到指定的设备,是不是就意味着router有它下面所有设备的MAC地址 【router1 有2345一共11个设备的MAC地址】

为什么router1知道可以通过router3能到达IP5 ?

所有的所有,就是一个public ip 和 private ip 之间的关系

先通过public IP address传输到该LAN,然后通过MAC address最终找到LAN下的该设备,这个好处是一个LAN可以公用1个public IP address,便于快速寻找到最优的传输路径。

不是每个router都配有自己独特的public IP address的,如果没有,他下面的设备就和上一级的router共用1个public IP address。 即先通过public IP address找到上级路由器,然后该上级路由器通过MAC最终找到该设备, IP + MAC 完美

路由表:路由表里面包含什么,路由器会跟另一个路由器交换路由表吗,存的下吗,这个行为有意义吗

路由器寻路算法: 

DHCP: Private IP address are usually assigned by your router via DHCP, whereas public IPs are assigned by ISPs(运营商)

DHCP: 

  • When setting up a DHCP server (often integrated into routers), network administrators define a range of private IP addresses (known as a DHCP scope) that the server can assign to devices on the network.

  • When a device connects to the network, it act as a client, it sends a DHCP request message (broadcast). The DHCP server responds with an available private IP address from the defined range along with other network configuration information (such as subnet mask, gateway, and DNS servers).

  • The assigned private IP address is leased to the device for a specific duration. If the device remains connected and needs to keep the address, it can renew the lease before it expires 【手机重连wifi,就会得到一个新的private IP address】

  • not every device has a public IP address
  • routers use a technique called Network Address Translation (NAT). NAT allows all devices with private IPs to communicate with the internet through the router's public IP.
  • When a device with a private IP sends a request to the internet (e.g., opening a website), the router translates the private IP to its public IP and keeps track of which device made the request. When a response comes back, the router forwards it to the correct device using the private IP.  【or MAC?】
  • that is why 192.168.1.1 will open the router config page, because your PC is under LAN, it can use private IP address to talk with other device
  • not every router has a public IP address,
  • Typically, an ISP will assign a public IP to the main router (or modem/router combo) that they provide or approve. Routers Behind Another Router (No Public IP)
  • what if I want to request a public ip address for the second router? Many ISPs only provide one public IP per account by default, but some may offer the option to purchase additional IPs for an extra fee, then configure your primary router in bridge mode,  In bridge mode, the first router acts as a pass-through device. configure your second router to use it. This can typically be done in the router's settings by entering the static IP address provided by your ISP.【问题是,如果用户希望第二个路由器也有public ip address,那他就不应该把他连在一个路由器后面,而是直接与外面的ISP网线相连,】

  • NAT: Network Address Translation, is a method used in networking that allows multiple devices on a local network to share a single public IP address when accessing the internet

  • Double NAT: connect a second router (Router B) to Router A. To avoid Double NAT without using a second router, consider using switches. Because router help the under device translate their private ip addres to router's own public ip address. switch wont. which can cause problems with certain services like online gaming, VPNs, and peer-to-peer applications

可以看到 网关(gateway),DHCP 和 DNS 的IP地址相同,也就是说router自己充当了DNS和DHCP的功能。 

  • gateway: the gateway is often the router or modem-router that connects the local network (LAN) to the internet
  • modem: It converts the digital signals from your computer or router into analog signals that can be transmitted over your ISP’s network (if it's a cable or DSL connection)
  • 如果是光纤,就会有一个“”光猫“ 硬件负责把路由器的电信号转换成光信号给光纤传输

cable internet:

墙的原理:

  • IP*:防火墙位于中国的互联网服务提供商(ISP)和国际互联网之间,因而可以通过封禁IP来阻止
  • DNS污染:让DNS服务器返回错误的IP地址

为什么VPN可以绕过: 

  • VPN服务器设置在国外,用户直接与VPN服务器联系,VPN服务器再代表我们去访问目标网站然后传输回来。这样就无法通过*网站的ip地址来阻止,即VPN服务器同时扮演了DNS服务器和流量转递两个角色
  • VPN服务器的ip地址是动态的,这样就无法同通过封禁VPN服务器的ip来阻止
  • VPN会加密传输内容,因而无法通过内容解析来判断是否是在访问被封禁的ip网站
  • 一些 VPN 服务采用分布式网络结构,用户之间相互作为节点,这意味着没有固定的服务器

routing table: 

  • it contains essential information used to determine the best possible route for forwarding data packets from the source to the destination
  • routers learn about new networks, detect changes, and update their routing tables accordingl

已知public ip是全世界独特的,而private ip只是在当前LAN下面是独特的,在不同的LAN之间是可以重复的

NAT:router 把你的private ip转化成 pubilic ip发出去,另一边把互联网回复信息的public ip自动转化为你的private ip准备发给你 

ARP:在局域网(LAN)中,路由器通过MAC地址找到具体的设备,而不是通过私有IP地址直接找到设备。 ARP 通过向LAN下所有的设备广播private ip address,对应的设备就会回复他的MAC地址是多少。 当然router也会缓存一张ARP表 【之所以要用MAC地址而不用private ip完成最终的传递,因为如果你的手机反复连接断开wifi,你手机被分配的private ip是在变化的】

每次设备更新private ip address,都会发送一个ARP 广播告诉所有人自己的ip 变了,router会更新ARP表。

当一个设备收到一个MAC地址是它自己,但IP地址不是它的私有IP的数据包时,设备通常会丢弃该数据包

  • 这就是为什么wifi断了以后会丢失,断网。 因为之前请求的数据,router虽然将返回的数据包按照MAC地址正确的发给了他,但是设备自身会因为private ip address不匹配主动丢弃

之所以要发明ip地址,而不是直接用独一无二的mac地址互相通讯

  • IP地址逻辑地址,可以通过**动态分配(例如DHCP)**进行管理。网络管理员可以根据网络的拓扑结构随时分配或更改IP地址,使得网络能够灵活扩展和重组。
  • IP地址采用了分层结构(如IPv4中的网络地址和主机地址),可以通过子网掩码来划分不同的子网,这使得路由器能够根据IP地址轻松地判断数据包应该被发送到哪个下一跳路由器,从而实现跨网络的传输。
  • IP地址使得网络具备了灵活性、扩展性和高效性,这是使用固定的MAC地址无法实现的

路由器在传出数据包时会将源MAC地址替换成自己的MAC地址

  • 因为跨越到网络B时,原始的MAC地址在网络B中不可达,因此需要替换为路由器的MAC地址,以便能够在新的网络中进行通信。
  • 这也就是为什么需要NAT和ARP技术,因为从外部收到的回复数据包已经没有最开始的MAC地址了。

data link layer 和  network layer 都有mac地址,data link layer的des mac 设为全FF即为广播

注意: LAN外面的server不会凭空发一个数据到你的电脑上。 也就说每次都是你的设备先通过router向外部发送一个请求,然后服务器回复一个数据包给你。那么自然router就知道这个目的ip的数据是你请求的

问题: 如果LAN下面同时有两个设备请求同一个目的ip,router怎么知道回复的信息是谁的?

  • To differentiate between multiple internal devices making requests to the same external IP, the router also modifies the source port number of each outgoing packet.(也就是说两台电脑发的时候端口号都是80,但router发出去的时候就可能是一个100,一个110了) This combination of the public IP address and a unique source port allows the router to track each individual connection.
  • The router maintains a NAT table that keeps track of all active connections. This table includes:
    • The private IP address and source port of each requesting device.
    • The public IP address of the router and the corresponding modified port used for each outgoing request.

安全证书:

为什么家里和公司的电脑可以都用这个一样的ip地址 192.168.0.1  因为这个是private IP地址,仅用于该router下的LAN的设备之间通讯,而家里和公司的电脑属于不同的LAN,自然private IP地址可以重复

4. Ethernet in OSI model

  • Tp layer: TCP/IP
  • N layer: IP address 
  • D layer: MAC address
  • P layer: twisted 

D layer: primarily responsible for enabling reliable data transfer between two directly connected devices over a physical network medium, handles MAC addresses, which are used to uniquely identify devices on the same local network

Reference/ self test: 

https://www.youtube.com/watch?v=HgZ5Dtm_CIo&t=3s&ab_channel=IntrepidControlSystems

因特网,以太网,局域网这些词到底代表什么,都是什么意思_哔哩哔哩_bilibili

p2成品_哔哩哔哩_bilibili

什么是nat 技术_哔哩哔哩_bilibili

一条视频讲清楚什么是ARP协议-ARP攻击又是什么_哔哩哔哩_bilibili