type
status
date
slug
summary
tags
category
icon
password

Overview

Lab5主要做的是TCP协议之下网络层的事情
In past labs, you wrote a TCP implementation that can exchange TCP segments with any other computer that speaks TCP. How are these segments actually conveyed to the peer’s TCP implementation? As we’ve discussed, there are a few options:

TCP-in-UDP-in-IP

TCP的segment可以被携带在datagram的payload里面
Linux provides an interface (a “datagram socket”, UDPSocket) that lets applications supply only the payload of a user datagram and the target address, and the kernel takes care of constructing the UDP header, IP header, and Ethernet header, then sending the packet to the appropriate next hop.
也就是说这个接口把网络层、传输层、应用层的header全给构造完了,应用程序只用提供有效负载和目标地址就行了
内核确认每个这种socket都具有本地和远程地址和端口号的特有组合

TCP-in-IP

In common usage, TCP segments are almost always placed directly inside an Internet datagram, without a UDP header between the IP and TCP headers. This is what people mean by “TCP/IP.”

TCP-in-IP-in-Ethernet

在Linux核里面,Linux has to construct an appropriate link-layer (Ethernet) frame with the IP datagram as its payload. 核还必须找出下一跳的以太网地址,给出下一跳的IP地址。如果核心在这一步没法找出来的话,Linux系统就会广播这个请求 “Who claims the following IP address? What’s your Ethernet address?”
这次lab的目标:实现网络层接口,并把它放在之前实现的TCP/IP栈的最下面
Your code will produce raw Ethernet frames, which will be handed over to Linux through an interface called a TAP device—similar to a TUN device, but more low-level, in that it exchanges raw link-layer frames instead of IP datagrams.
 
Rustlings笔记CS144—Lab4
  • Giscus