<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Yiwa</title>
  
  <subtitle>Yiwa</subtitle>
  <link href="http://blog.yiwa.ga/atom.xml" rel="self"/>
  
  <link href="http://blog.yiwa.ga/"/>
  <updated>2022-02-02T11:06:49.993Z</updated>
  <id>http://blog.yiwa.ga/</id>
  
  <author>
    <name>Yi wa</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>clash局域网共享失败</title>
    <link href="http://blog.yiwa.ga/2022/02/02/clash%E5%B1%80%E5%9F%9F%E7%BD%91%E5%85%B1%E4%BA%AB%E5%A4%B1%E8%B4%A5/"/>
    <id>http://blog.yiwa.ga/2022/02/02/clash%E5%B1%80%E5%9F%9F%E7%BD%91%E5%85%B1%E4%BA%AB%E5%A4%B1%E8%B4%A5/</id>
    <published>2022-02-02T09:54:51.000Z</published>
    <updated>2022-02-02T11:06:49.993Z</updated>
    
    <content type="html"><![CDATA[<h4 id="问题背景"><a href="#问题背景" class="headerlink" title="问题背景"></a>问题背景</h4><p>clash for windows开启Allow LAN后即将设备作为代理服务器为局域网中的设备提供代理服务。这种局域网共享的功能在很多代理软件中都存在。比如IOS端的Shadowrocket就可以在设置中打开代理共享，其余设备只需要设置好代理服务器的ip地址和端口号即可。可是clash for windows在开启Allow LAN后很多人Github上反应无法进行代理共享。</p><h4 id="原因猜测"><a href="#原因猜测" class="headerlink" title="原因猜测"></a>原因猜测</h4><p>由于无法进行代理共享并不是普遍情况所以排除软件本身的问题。然后就怀疑Windows防火墙是否没有开放相应端口。这里我的clash需要开放的端口为7890(端口号在clash for windows中查询)。在<a href="ms-settings:windowsdefender?activationSource=SMC-IA-4028544">Windows安全中心</a>中关闭了公用网络防火墙后发现代理可以成功共享。所以共享失败的原因应该是防火墙没有开放相应代理端口。</p><h4 id="防火墙开放端口"><a href="#防火墙开放端口" class="headerlink" title="防火墙开放端口"></a>防火墙开放端口</h4><p>由于关闭Windows防火墙并不是一件值得推荐做的事，所以只需要在防火墙上开放对应端口也可以实现代理共享。由于Windows的防火墙开放端口需要新建出站规则和入站规则两套</p><h5 id="入站规则"><a href="#入站规则" class="headerlink" title="入站规则"></a>入站规则</h5><ol><li>点击高级设置</li></ol><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/community/202202021833766.png" style="zoom: 67%;" /><ol start="2"><li><p>右击入站规则点击新建规则</p></li><li><p>设置要创建的规则类型为端口</p></li><li><p>设置此规则应用于TCP,应用于特定本地端口7890(端口号根据clash for windows中显示的而定)</p></li><li><p>设置允许连接</p></li><li><p>何时运用规则三个全选</p></li><li><p>名称随意</p></li></ol><h5 id="出站规则"><a href="#出站规则" class="headerlink" title="出站规则"></a>出站规则</h5><p>创建方法和入站规则一致。一定要创建出站规则，一定要创建出站规则，一定要创建出站规则。</p><h4 id="杀毒软件"><a href="#杀毒软件" class="headerlink" title="杀毒软件"></a>杀毒软件</h4><p>在这里解释一下为什么有的人不需要设置端口的开放就可以共享代理。有的杀毒软件会默认接管系统的防火墙，这些杀毒软件可能会自动改变防火墙的相关设置或开放端口。因为博主的电脑上只有Windows Defender所以就需要进行相关端口设置。</p>]]></content>
    
    
      
      
    <summary type="html">&lt;h4 id=&quot;问题背景&quot;&gt;&lt;a href=&quot;#问题背景&quot; class=&quot;headerlink&quot; title=&quot;问题背景&quot;&gt;&lt;/a&gt;问题背景&lt;/h4&gt;&lt;p&gt;clash for windows开启Allow LAN后即将设备作为代理服务器为局域网中的设备提供代理服务。这种局域网共享</summary>
      
    
    
    
    <category term="科学上网" scheme="http://blog.yiwa.ga/categories/%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91/"/>
    
    
    <category term="clash" scheme="http://blog.yiwa.ga/tags/clash/"/>
    
    <category term="科学上网" scheme="http://blog.yiwa.ga/tags/%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91/"/>
    
    <category term="局域网" scheme="http://blog.yiwa.ga/tags/%E5%B1%80%E5%9F%9F%E7%BD%91/"/>
    
  </entry>
  
  <entry>
    <title>修复error:unknown filesystem grub rescue</title>
    <link href="http://blog.yiwa.ga/2022/01/30/%E4%BF%AE%E5%A4%8Derror-unknown-filesystem-grub-rescue/"/>
    <id>http://blog.yiwa.ga/2022/01/30/%E4%BF%AE%E5%A4%8Derror-unknown-filesystem-grub-rescue/</id>
    <published>2022-01-30T09:33:19.000Z</published>
    <updated>2022-02-02T09:48:04.628Z</updated>
    
    <content type="html"><![CDATA[<h4 id="问题背景"><a href="#问题背景" class="headerlink" title="问题背景"></a>问题背景</h4><p>博主的电脑为Windows10+Manjaro双系统，在将Windows10版本由21H1升级为21H2的过程中出现了无法进入系统的情况，情况如下图。</p><img src="https://cdn.jsdelivr.net/gh/yiwa1/Picture-bed/linux/202201301759757.png" style="zoom:67%;" /><p>Google了一下才知道原来是找不到系统盘了，所以只要设置好启动路径就可以正常进入grub界面了。下面介绍如何进行相关设置。</p><h4 id="查看所有挂载盘"><a href="#查看所有挂载盘" class="headerlink" title="查看所有挂载盘"></a>查看所有挂载盘</h4><figure class="highlight powershell"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br></pre></div></td><td class="code"><pre><code class="hljs powershell">grub rescue&gt;<span class="hljs-built_in">ls</span><br></code></pre></td></tr></table></figure><p>该命令可以查看当前所有的盘符，每个人各不相同。博主的盘符如下。</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell">(hd0) (hd0,pst12) (hd0,pst11) (hd0,pst10) (hd0,pst9) (hd0,pst8) (hd0,pst7) (hd0,pst6) (hd0,pst5) (hd0,pst4) (hd0,pst3) (hd0,pst2)<br>(hd0,pst1)<br></code></pre></td></tr></table></figure><h4 id="找到安装系统的盘"><a href="#找到安装系统的盘" class="headerlink" title="找到安装系统的盘"></a>找到安装系统的盘</h4><p>从右至左依次输入一下命令查看是否是系统盘</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">ls</span> &lt;盘符&gt;/boot/grub<br></code></pre></td></tr></table></figure><p>比如博主第一个检查</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">ls</span> (hd0,pst1)/boot/grub<br></code></pre></td></tr></table></figure><p>尝试所有盘符直到显示的内容不再为error: unknown filesystem。尝试下来博主的系统盘为(hd0,pst7)。</p><h4 id="设置路径"><a href="#设置路径" class="headerlink" title="设置路径"></a>设置路径</h4><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">set</span> root=&lt;系统盘符&gt;/boot/grub<br><span class="hljs-built_in">set</span> prefix=&lt;系统盘符&gt;/boot/grub<br></code></pre></td></tr></table></figure><p>博主的路径设置</p><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell"><span class="hljs-built_in">set</span> root=(hd0,pst7)/boot/grub<br><span class="hljs-built_in">set</span> prefix=(hd0,pst7)/boot/grub<br></code></pre></td></tr></table></figure><h4 id="加载模块"><a href="#加载模块" class="headerlink" title="加载模块"></a>加载模块</h4><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell">insmod normal<br>normal<br></code></pre></td></tr></table></figure><p>将相关模块加载进内核并正常启动，这样就可以看到你的grub界面了，选择相应系统进入即可。</p><h4 id="彻底根除"><a href="#彻底根除" class="headerlink" title="彻底根除"></a>彻底根除</h4><p>原本以为可以不用再担心了，可在更新完系统重启时又出现了这个error，此时博主内心无数草泥马狂奔。</p><img src="https://cdn.jsdelivr.net/gh/yiwa1/Picture-bed/linux/202201301844057.png" alt="小草" style="zoom:67%;display:block;margin:0 auto;" /><p>Google了一下找到了良方。进入Linux系统，在terminal中依次输入以下命令即可。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">sudo update-grub<br>sudo grub-install /dev/sda<br></code></pre></td></tr></table></figure><p>这样就再也看不到这个error了。</p>]]></content>
    
    
      
      
    <summary type="html">&lt;h4 id=&quot;问题背景&quot;&gt;&lt;a href=&quot;#问题背景&quot; class=&quot;headerlink&quot; title=&quot;问题背景&quot;&gt;&lt;/a&gt;问题背景&lt;/h4&gt;&lt;p&gt;博主的电脑为Windows10+Manjaro双系统，在将Windows10版本由21H1升级为21H2的过程中出现了无法进</summary>
      
    
    
    
    <category term="Linux" scheme="http://blog.yiwa.ga/categories/Linux/"/>
    
    <category term="启动异常" scheme="http://blog.yiwa.ga/categories/Linux/%E5%90%AF%E5%8A%A8%E5%BC%82%E5%B8%B8/"/>
    
    <category term="Windows" scheme="http://blog.yiwa.ga/categories/Windows/"/>
    
    <category term="更新" scheme="http://blog.yiwa.ga/categories/Windows/%E6%9B%B4%E6%96%B0/"/>
    
    
    <category term="Linux" scheme="http://blog.yiwa.ga/tags/Linux/"/>
    
    <category term="Windows" scheme="http://blog.yiwa.ga/tags/Windows/"/>
    
    <category term="双系统" scheme="http://blog.yiwa.ga/tags/%E5%8F%8C%E7%B3%BB%E7%BB%9F/"/>
    
    <category term="grub" scheme="http://blog.yiwa.ga/tags/grub/"/>
    
    <category term="Windows更新" scheme="http://blog.yiwa.ga/tags/Windows%E6%9B%B4%E6%96%B0/"/>
    
  </entry>
  
  <entry>
    <title>计算机网络-CS144</title>
    <link href="http://blog.yiwa.ga/2022/01/22/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%20CS%20144/"/>
    <id>http://blog.yiwa.ga/2022/01/22/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%20CS%20144/</id>
    <published>2022-01-22T09:48:10.000Z</published>
    <updated>2022-01-23T07:47:04.867Z</updated>
    
    <content type="html"><![CDATA[<h2 id="Computer-Network-CS-144"><a href="#Computer-Network-CS-144" class="headerlink" title="Computer Network CS 144"></a>Computer Network CS 144</h2><h3 id="Related-terms"><a href="#Related-terms" class="headerlink" title="Related terms"></a>Related terms</h3><ol><li>bi-directional byte stream（双向字节流）</li><li>TCP （传输控制协议）</li><li>http （超文本传输协议）</li><li>Network Address translation（网络地址转换）</li><li>rendezvous rely servers（集合中继服务器）</li></ol><h3 id="1-1-Network-Application"><a href="#1-1-Network-Application" class="headerlink" title="1-1 Network Application"></a>1-1 Network Application</h3><blockquote><p>HTTP（超文本传输协议</p></blockquote><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/HTTPsimpleModel.png" width="100%" style="margin-lerf:10%"  />    <p>basic model： client sends a request by writing to the connection, the server reads the request, processes it, and writes a response to the connection, which the  client then reads.</p><blockquote><p>Bit Torrent</p></blockquote><p><em><strong>What is bit torrent?</strong></em> </p><p><em><strong><u>Bit Torrent is a program that allows people to share and exchange large files. In Bit Torrent a client requests documents from other clients. Bit Torrent breaks files up into chunks of data called pieces.  When a client downloads a complete piece from another client, it then tells other clients it has that piece so they can download it  too. These collections of collaborating clients are called swarms.</u></strong></em>  </p><p>simple model:. When a client wants to download a file, it first has to find something called a torrent file. Usually, you find this using the world wide web and download it using, you guessed it, HTTP. This torrent file describes some information about  the data file you want to download. It also tells Bit Torrent about who the tracker is for that torrent. A tracker is a node that  keeps track (hence the name) of what clients are members of the swarm. To join a torrent, your client contacts the tracker, again, over HTTP, to request a list of other clients. Your client opens connections to some of these clients and starts requesting  pieces of the file. Those clients, in turn, can request pieces. Furthermore, when a new client joins the swarm, it might tell this  new client to connect to your client. So rather than a single connection between a client and one server, you have a dense graph  of connections between clients, dynamically exchanging data. </p><blockquote><p>Skype</p></blockquote><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/SkypeWithComplication.png" width="100%" style="" />    <p>NAT: <em><strong><u>if you’re  behind a NAT then you can open connections out to the Internet, but other nodes on the Internet can’t  easily open connections to you.</u></strong></em>  </p><p>simple mode:It does so using something called a rendezvous server. When you log into Skype, your client opens connections to a network of control servers. In this case,  client B opens a connection to the rendezvous server. This works fine because the server isn’t behind a NAT and client B can open connections out without any  problems. When client A calls client B, it sends a message to the rendezvous server. Since the server has an open connection to client B, it tells B that there’s a call  request from A. The call dialog pops up on client B. If client B accepts the call, then it opens a connection to client A. Client A was trying to open a connection  to client B, but since B was behind a NAT, it couldn’t. So instead it sends a message to a computer that client B is already connected to, which then asks client  B to open a connection back to client A. Since client A isn’t behind a NAT, this connection can open normally. This is called a reverse connection because it  reverses the expected direction for initiating the connection. Client A is trying to connect to client B, but instead client B opens a connection to client A.  </p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/SkypeWithMoreComplication.png" style="" width="100%" />   <p>simple model: Skype introduces a second kind of server, called a relay. Relays can’t be behind NATs. If both client A and client B are behind NATs, then the communicate through a  relay. They both open connections to the relay. When client A sends data, the relay forwards  it to client B through the connection that B opened. Similarly, when client B sends data, the  relay forwards it to client A through the connection client A opened.</p><h3 id="1-2-Layer-Internet-Model"><a href="#1-2-Layer-Internet-Model" class="headerlink" title="1-2 Layer Internet Model"></a>1-2 Layer Internet Model</h3><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/202109252117571.png" style="margin-left=10%" width="100%" />   <blockquote><p>Link Layer</p></blockquote><p>The Internet is made up of en1d hosts, links and routers. Data is delivered hop-by-hop over each  link in turn. Data is delivered in packets. A packet consists of the data we want to be delivered,  along with a header that tells the network where the packet is to be delivered, where it came  from and so on.</p><p>Link Layer: <u>The Link Layer’s job is to carry the data over one link at a time.__</u></p><p>Example: Ethernet,WiFi and 5G</p><blockquote><p>Network Layer</p></blockquote><p>packets: </p><table><thead><tr><th>data</th><th align="left">header contains “to” and from “address”</th></tr></thead></table><p>Network Layer:<u>The network layer’s job is to deliver packets end-to-end across the Internet from the source to the destination.</u></p><p>The Network hands the datagram to the Link Layer below, telling it to send the datagram over the first link. In other words, the Link Layer is providing a <em>service</em> to the Network Layer. Essentially, the Link Layer says: “if you give me a datagram to send, I will transmit it over one link for you.  </p><p>At the other end of the link is a router. The Link Layer of the router accepts the datagram from the link, and hands it up to the Network Layer in the router. The Network Layer on the router examines the destination address of the datagram, and is responsible for routing the datagram one hop at a time towards its eventual destination.  It does this by sending to the  Link Layer again, to carry it  over the next link. And so on until it reaches the Network Layer at the destination.  </p><p>We Must Use Internet Protocal(IP)</p><p>In the internet, the network layer is special: When we send packets into the Internet, we must use the Internet Protocol. It is the Internet Protocol, or IP, that holds the Internet together</p><ul><li><p>IP makes a best-effort attempt to deliver our datagrams to the other end. But it makes no promises</p></li><li><p>IP datagrams can get lost, can be delivered out of order, and can be corrupted. There are no guarantees.  </p></li></ul><blockquote><p>Transport</p></blockquote><p>The most common Transport Layer is TCP. TCP makes sure that data sent by an application at one end of the Internet is correctly delivered – in the right order to the application at the other end of the Internet. If the  Network Layers drops some datagrams, TCP will retransmit  them, multiple times if need-be.  </p><p>Example: TCP UDP</p><blockquote><p>Application</p></blockquote><p>There are of course many thousands  f applications that use the  Internet. While each application is different, it can reuse the Transport Layer by using the well-defined API from the Application Layer to the TCP or UDP service beneath.  </p><p>How it works</p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/202109252251820.png" style="margin-left=10%" width="100%" />       <p>When a web client requests a page from a web server, the web client sends a GET request. This is one of the commands of the hypertext transfer protocol, or http. http dictates that the GET command is sent as an ASCII  string, along with the URL of the page being requested. As far as the Application Layer is concerned, the GET request is sent directly to its peer at the other end – the web server Application . The Application  doesn’t need to know how it got there, or how many times it  needed to be retransmitted. At the web client, the Application  Layer hands the GET request to the TCP layer, which provides the service of making sure it is  reliably delivered. It does this using the services of the  Network layer which has the job of breaking the data into packets, each with the correct destination address and in turn uses the services of the Link Layer.  </p><h4 id="summary"><a href="#summary" class="headerlink" title="summary"></a>summary</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/202109252305791.png" style="" width="100%" />  <img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/202109252308033.png" style="" width="100%" />      <h4 id="7-layer-OSI-Model"><a href="#7-layer-OSI-Model" class="headerlink" title="7-layer OSI Model"></a>7-layer OSI Model</h4><h3 id="1-3-IP-service"><a href="#1-3-IP-service" class="headerlink" title="1-3 IP service"></a>1-3 IP service</h3><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/DataHeader.png" style="" width="100%" />    <p>IP datagrams consist of a header and some data. When the transport layer has data to send, it hands a Transport Segment to the Network layer below.   The network layer puts the transport segement inside a  new IP datagram. IP’s job is to deliver the datagram to the other end. But first, the IP datagram has to make it over the first link to the first router. IP sends the datagram to the Link Layer that puts it inside a Link frame, such as an Ethernet packet and ships it off to the first router.  </p><h4 id="IP-Property"><a href="#IP-Property" class="headerlink" title="IP Property"></a>IP Property</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/IPServiceProperties.png" style="" width="100%" />   <p>The IP service can be characterized by four properties listed here. It sends Datagrams from end host to end host; it is unreliable, but makes a best-effort to deliver the datagrams. The network maintains no per-flow state associated with the datagrams.</p><p>properties</p><ol><li>The IP service model provides a service which includes the routing to the destination. </li><li>IP is unreliable. IP makes no promise that packets will be delivered to the destination. They could be delivered late, out of sequence, or never delivered at all. It’s possible that a packet will be duplicated along the way, for example by a misbehaving router. The key thing to remember is that IP is unreliable and makes no guarantees.</li><li>It won’t drop datagrams arbitrarily just because it feels like it.</li><li>IP is an extremely simple, minimal service. It maintains no state at all related to a  communication. We say that a communication service is “connectionless” because it doesn’t start by establishing some end to state associated with the communication. In other words, when we  make a Skype call lasting several minutes and consisting of many IP datagrams, the IP layer maintains no knowledge of the call, and simply routes each datagram individually and independently of all the others.  </li></ol><h4 id="IP-Header"><a href="#IP-Header" class="headerlink" title="IP Header"></a>IP Header</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/IPDAandIPSA.png" style="" width="100%" />    <p>The header contains the IP address of the destination, which we abbreviate here as “IP  DA” for IP destination address. The forwarding decision at each router is based on the IP DA. The datagram header also contains an IP source address, or “IP SA”, saying where the packet came from, so the receiver knows where to send any response.  </p><blockquote><p>forwarding table</p></blockquote><p>each router contains a forwarding table that tells it where to send packets matching a given destination address. The router doesn’t know the whole path – it simply uses the  destination address to index into its forwarding table so that  it can forward the packet to the next hop along the path  towards its final destination. Hop by hop, step by step the  packet makes its way from the source to the destination  using only the destination address in the datagram.  </p><h4 id="Reasons-Why-IP-is-simple"><a href="#Reasons-Why-IP-is-simple" class="headerlink" title="Reasons Why IP is simple"></a>Reasons Why IP is simple</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/ReasonsIPSimple.png" style="" width="100%" />  <p>​    </p><ol><li>To keep the network simple, dumb and minimal. Faster, more streamlined and lower cost to build and maintain. It was believed that if the network is kept simple with very features and requirements, then packets could be delivered very quickly, and at low cost. The thinking was that a simple network could be made to run very fast using dedicated hardware. And given that the  network is implemented by a large number of routers  scattered throughout the network, if they could be kept simple then are likely to be more reliable, more affordable to maintain and will need to be upgraded less often.</li><li>The end to end principle: Where possible, implement features in the end hosts.The basic idea is to place as much intelligence as possible at the end points.This can have several advantages, such as making sure the feature is implemented correctly for the application, and it is easier to evolve and improve a feature if it is implemented in software on end computers rather than  baked into the hardware of the Internet. </li><li>Allows a variety of reliable (or unreliable) services to be built on top. If IP was reliable – in other words if any missing packets were retransmitted  automatically – then it would not be ideal for some services. For example, in real time applications like a video chat, there might be no point in retransmitting lost data, because it might arrive too late to be useful. Instead, the application might choose to show a few blank pixels or use the pixels from the frame before. By  not providing any reliability guarantees, IP lets the application choose the reliability service its needs.</li><li>Works over any link layer: IP makes very few assumptions about the link layer. IP makes very little expectation of the Link layer below – the link could be wired  r wireless, and requires no retransmission or control of congestion.  </li></ol><h4 id="other-IP-service"><a href="#other-IP-service" class="headerlink" title="other IP service"></a>other IP service</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/IPServiceDetails.png" style="" width="100%" />    <ol><li>IP tries to prevent packets from looping forever. This is most likely to happen when the forwarding tables are changing and they temporarily get into an inconsistent state. Rather than try to prevent loops from ever happening – which would take a lot of complexity - IP uses a very simple mechanism to catch and then delete packets that appear to be stuck in a loop. To do this, IP simply adds a hop-count field in the header of every datagram. It is called the time to live, or TTL field. It starts out at a number like 128 and then is decremented by every router it passes through. If it reaches zero, IP  concludes that it must be stuck in a loop and the router drops the datagram. </li><li>IP will fragment packets if they are too long. IP provides some header fields that we will see in a minute to help the router fragment the datagram into two self-contained IP datagrams, while providing the information the end host needs to correctly reassemble the data again.</li><li>IP uses a header checksum to reduce chances of delivering a datagram to the wrong destination.IP includes a checksum field in the datagram header to try and make sure datagrams are delivered to the right location.</li><li>Allows for new versions of IP. There are two versions of IP in use today: IPv4, which is used today by over 90% of end hosts. It uses the 32bit addresses you are probably familiar with. Because we are running out of IPv4 addresses, the Internet is in a gradual transition to IPv6, which uses 128 bit addresses instead.</li><li>IP allows new fields to be added to the datagram header. This is a mixed blessing. On the one hand, it allows new features to be added to the header that turn out  to be important, but weren’t in the original standard. On the other hand, these fields need processing and so require extra features in the routers along the path, breaking the goal of a simple, dumb, minimal forwarding path. In practice, very few options are used or processed by the routers.</li></ol><h4 id="IPV4-Datagram"><a href="#IPV4-Datagram" class="headerlink" title="IPV4 Datagram"></a>IPV4 Datagram</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/IPV4Datagram.png" style="" width="100%" />    <ol><li> The Protocol ID, that tells us what is inside the data field. Essentially, it allows the destination end host to demultiplex arriving packets, sending them to the correct code to process the packet. If the Protocol ID has the value  “6” then it tells us the data contains a TCP Segment, and so  we can safely pass the datagram to the TCP code and it will be able to parse the segment correctly. The Internet Assigned Numbers Authority (IANA) defines over 140  different values of Protocol ID, representing different  transport protocols.</li><li>The Version tells us which version of IP – currently, the legal values are IPv4 and IPv6.</li><li>The Total packet length can be up 64kBytes  including the header and all the data.</li><li>The Time to Live field helps us to prevent packets accidentally looping in the network forever. </li><li>Sometimes a packet is too long for the link it is  bout to be sent on. The Packet ID, Flags and Fragment Offset all help routers to fragment IP packets into smaller self-contained packets if need-be.</li><li>The Type of Service field gives a hint to routers about how important this packet is.</li><li>The Header Length tells us how big the header is — some headers have optional extra fields to carry extra information.</li><li>a checksum is calculated over the whole header so just in case the header is corrupted, we are not likely to deliver a packet to the wrong desination by mistake.</li></ol><h3 id="1-4Life-of-Packet"><a href="#1-4Life-of-Packet" class="headerlink" title="1-4Life of Packet"></a>1-4Life of Packet</h3><h4 id="three-way-handshack"><a href="#three-way-handshack" class="headerlink" title="three way handshack"></a>three way handshack</h4><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/threeHandShake.png" style="" width="100%" />    <p>The first step of handshake is when the client sends a “synchronize” message to the server, often  called a SYN. The second step is when the server responds with a “synchronize” message that also  acknowledges the clients “synchronize”, or a “synchronize and acknowledge message”, often called  a SYN-ACK. The third and final step is when the client responds by acknowledging the server’s  synchronize, often called an ACK. So often the three way handshake is described as “synchronize,  synchronize and acknowledge, acknowledge”, or “SYN, SYN-ACK, ACK”.</p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/TCPport.png" style="" width="100%"/>      <p>TCP port</p><p>Recall that the network layer is responsible for delivering packets to computers, but the transport  layer is responsible for delivering data to applications. From the perspective of the network layer,  packets sent to different applications on the same computer look the same. This means that to open  a TCP stream to another program, we need two addresses. The first, an Internet Protocol address,is the address the network layer uses to deliver packets to the computer. The second, the TCP port,  tells the computer’s software which application to deliver data to. Web servers usually run on TCP  port 80. So when we open a connection to a web server, we send IP packets to the computer running the web server whose destination address is that computer’s IP address. Those IP packets have TCP segments whose destination port is 80.</p><p>router</p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/RouterFunction.png" style="" width="100%" />  <p>​    </p><p>But how do those IP packets get to their destination? We don’t have a direct wire connecting my  client to the server. Instead, my client is connected to an intermediate computer, a router. This router is itself connected to other routers. IP packets between the client and server take many “hops,”  where a hop is a link connecting two routers. For example, since my client is on a WiFi network, the first hop is wireless to the WiFi access point. The access point has a wired connection to the broader Internet, so it forwards my client’s packets along this wired hop. A router can have many links connecting it. As each packet arrives, a router decides which of its links to send it out on. Routers have IP addresses, so it’s also the case that it might not forward a  packet but rather deliver it to its own software. For example, when you log into a router using TCP,  the IP packets are destined to the router’s own IP address</p><p>forwarding table</p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/forwardingtable.png" style="" width="100%" />       <p>A forwarding table consists of a set of IP address patterns and the link to send across for each pattern</p><p>When a packet arrives, the router checks which forwarding table entry’s pattern best matches the  packet. It forwards the packet along that entry’s link. Generally, “best” means the most specific  match. The default route is the least specific route. It matches every IP address. If,when a packet arrives, there isn’t a more specific route than the default route, the router will just use the default one.</p><h3 id="1-5-packect-switching"><a href="#1-5-packect-switching" class="headerlink" title="1-5 packect switching"></a>1-5 packect switching</h3><p>packet switching</p><p>Independently for each arriving packet, pick its outgoing link. If the link is free,send it. Else hold the packet for latter.</p><p>Packet switching is the idea that we break our data up into discrete, self-contained chunks of data. Each chunk, called a packet, carries sufficient information that a network can deliver the packet to its destination. So let’s say we have a source and a destination, and a network of packet switches  A, B, and C between them. When A receives a packet for the destination, it sends it along the link to B. When B receives a  packet for the destination, it sends it along to C. When C  receives a packet for the destination, it sends it to the  destination. In the simplest form of packet switching, each packet is routed separately and independently. For example,  let’s say there’s another switch connected to B, called D.  Immediately after sending a packet to C, B can send the next packet to D. Or, if the next packet were also to the  destination, it would send two packets back-to-back to C.</p><p>Here’s one example of how packet switching can work: each packet contains an explicit route, specifying the IDs of each packet switch along the way. We call this “self routing” or “source routing,” because the source specifies the route. When the source sends a packet, it puts in the packet A, B, C,destination. It then forwards the packet to A. A looks  inside the header and sees the next hop is B. So it forwards the packet to B. B sees the next hop is C, and C sees the last  hop is the destination. It turns out the Internet supports  source routing, but it’s generally turned off because it raises big security issues. People owning routers don’t want you telling them how to send packets, because maybe you can trick them to sending them somewhere they shouldn’t, such  as secure computers.</p><p>One simple optimization, and what the Internet mostly does today, is to place a small amount of state in each switch which tells it which next hop to send packets to.</p><p>packet switch type</p><p>In the Internet there are several different types of packet switches. Some of them are called routers or gateways, while others are called Ethernet switches. </p><p>packet switching properties</p><p>Packet switching has two really nice properties. The first is that a switch can make individual, local decisions for each  packet. It doesn’t need to keep extra state on the packets its seen or whether two packets go to the same destination.  Even if many packets are part of some larger transfer or protocol, the switch doesn’t need to know or care. The switch doesn’t need to know that some packets are a Skype  call, others are a web request, and others still are a  firmware update for your computer. It just forwards packets. This greatly simplifies the switch.</p><p>The second is that it lets a switch efficiently share a link between many parties. For example, consider a wireless router in a home with two people browsing the Internet on their laptops. If one person is reading a page,  then the other person can download a file at the full speed  of the link. If the first person starts loading a new web page,  the link can be shared between the two of them. Once the download completes, the first person can use the full speed of the link.</p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/SwitchAndFlow.png" style="" width="100%" />       <p>Because each packet is self-contained, a switch doesn’t need to know about groups of packets, or flows of packets. Imagine if every switch had to keep track of every single web connection passing through it. This would require a huge amount of state that would be hard to manage! Instead, treating each packet independently means the switch can be much simpler to build, manage, and  troubleshoot. </p><p>The switch doesn’t need to worry about adding or removing this per-flow state. Imagine if every time you wanted to load a web page, you had to communicate with every switch along the path to set up state so your request would work. This could make things much slower. Instead, you can just send packets and the switches forward them appropriately. </p><p>The switches also don’t need to <em>store</em> this state. Because switches have to be fast, they’d need to store this state in very fast memory, which is expensive. This lets switches focus on doing one thing, forwarding packets quickly. </p><p>Finally,it means switches don’t have to worry about failures. Imagine, for example, what happens when you start a web request but then your tablet runs out of energy. The switch is going to keep the per-flow state for the request, but if one of the nodes that created the state fails, the switch needs to know how to clean up after it. Otherwise you can have millions, billions of dead flows eating up your memory. With packet switching, a switch has no per-endpoint state. If your tablet dies, the switch doesn’t care, it just means that it stops receiving packets from it. In this way the switch is more functionally independent of the computers sending traffic through it.</p><img src="https://cdn.jsdelivr.net/gh/Yiwa1/Picture-bed/note/ComputerNetwork/EfficientSharingOfLinks.png" style="" width="100%" />    ]]></content>
    
    
      
      
    <summary type="html">&lt;h2 id=&quot;Computer-Network-CS-144&quot;&gt;&lt;a href=&quot;#Computer-Network-CS-144&quot; class=&quot;headerlink&quot; title=&quot;Computer Network CS 144&quot;&gt;&lt;/a&gt;Computer Network </summary>
      
    
    
    
    <category term="计算机网络" scheme="http://blog.yiwa.ga/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/"/>
    
    <category term="笔记" scheme="http://blog.yiwa.ga/categories/%E7%AC%94%E8%AE%B0/"/>
    
    <category term="计算机网络" scheme="http://blog.yiwa.ga/categories/%E7%AC%94%E8%AE%B0/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/"/>
    
    
    <category term="计算机网络" scheme="http://blog.yiwa.ga/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/"/>
    
    <category term="计算机基础" scheme="http://blog.yiwa.ga/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/"/>
    
  </entry>
  
</feed>
