代写Project 3: TCP Implementation
Project 3: TCP Implementation
Introduction
TCP serves many purposes: it provides reliable, in-order delivery of bytes, it makes
sure the sender does not send too fast and overwhelm the receiver (flow control), and
it makes sure the sender does not send too fast and overwhelm the network
(congestion control). It also aims to be fair: when multiple senders share the same
link, they should receive roughly the same proportion of bandwidth. In this project,
you will demonstrate your understanding of the TCP basics by implementing the TCP
protocol.
Be prepared: this is a single-person project, and your skills will be exercised. So start
early and feel more than welcome to ask questions. However, please note that the TAs
are not allowed to debug your code for you during their office hours. They cannot
touch your keyboard, and they will only spend a maximum of 10 minutes reading
your code. This helps them to assist more students effectively. Therefore, it is
recommended that you visit their office hours with specific questions instead of vague
statements like "my code doesn’t work." For debugging, logging or tools like
Wireshark1
can be helpful. There are many ways to do this; be creative.
TCP Recap
TCP is a transport layer protocol that enables different devices to communicate. As a
reminder the basic setup is the following.
You have an initiator (client) and a listener (server). The listener is waiting to receive
a connection from the initiator. After a connection is received, they perform a TCP
handshake to initiate the connection. Afterward, they can read and write to each other.
From the application layer, reads and writes to the socket are buffered before being
sent over the network. This means that multiple reads or writes might be combined
into a single packet or the opposite, that a single read or write to a socket might be
split into many packets.
To establish reliable data transfer, TCP must manage many different variables and
data structures. Here are some examples of the details you’ll need to track.
1 https://www.wireshark.org/
Let’s say we have sockets A and B, and that socket A wants to start sending data to
socket B. A will store the data in a buffer that it will pull from for sending packets.
Socket A will then create packets using data from the buffer and send as many as it is
allowed to send based on the congestion control algorithm used. As Socket B receives
packets, it stores the data transmitted in a buffer. This buffer helps with maintaining
the principle of in-order data transmission. B sends ACKs as responses to A to notify
A that various bytes have been received up to a certain point. B is also tracking the
next byte requested by the application reading from the socket, and when it receives
this byte, it will forward as much data in order that it can to the application buffer. For
example, if B is looking for byte number 400, it will not write any other bytes into the
application’s buffer until it receives byte number 400. After receiving byte number
400, it will write in as many other bytes as it can. (If B had bytes 400-1000 then all
would be written to the application buffer at the time of receiving the packet with byte
400. As packets are ACK’d, socket A will release memory used for storing data as
they no longer need to hold onto it. Finally, either side can initiate closing the
connection where the close handshake begins.
As both sides (initiator and listener) can both send and receive, you’ll be tracking a lot
of data and information. It’s important to write down everything each side knows
while writing your implementation and to utilize interfaces to keep your code module
and re-usable.
Project Specification
You are implementing the interfaces in tcpSock.py, such as case_socket and
case_close. Your code will be tested by us creating other Python files that will
utilize your interface to perform communications. The starter code has an example of
how we might perform the tests, we have a client.py and server.py which utilize the
sockets to send information back and forth. You can add additional helper functions to
tcpSock or change the implementation of the 4 core functions (socket, close,
read, and write). However, you cannot change the function signature of the 4 core
functions. Further, we will be utilizing grading.py to help us test your code. We may
change any of the values for the variables present in the file to make sure you aren’t
hard-coding anything. Namely, we will be varying the packet length and the initial
window variables.
Starter Code
The following files have been provided for you to use:
• packet.py: this file describes the basic packet format and header. You are not
allowed to modify this file.
• grading.py: these are variables that we will use to test your implementation;
please do not make any changes here, as we will replace them when running
tests.
• server.py: this is the starter code for the server side of your transport
protocol.
• client.py: this is the starter code for the client side of your transport
protocol.
• tcpSock.py: this contains the main socket functions required of your TCP
socket, including reading, writing, opening, and closing.
• backend.py: this file contains the code used to emulate the buffering and
sending of packets. This is where you should spend most of your time.
All the communication between your server and the client will use UDP as the
underlying protocol. All packets will begin with the common header described in
packet.py as follows:
− Identifier [4 bytes]
− Source Port [2 bytes]
− Destination Port [2 bytes]
− Sequence Number [4 bytes]
− Acknowledgement Number [4 bytes]
− Header Length [2 bytes]
− Packet Length [2 bytes]
− Flags [1 byte]
− Advertised Window [2 bytes]
All multi-byte integer fields must be transmitted in network byte order.
socket.ntoh and socket.hton and other related functions will be very
important for you to call. All integers must be unsigned, and the identifier should
be set to 3425. You are not allowed to change any of the fields in the header.
Additionally, packet length cannot exceed 1400 in order to prevent packets from
being broken into parts.
You can verify that your headers are sent correctly using wireshark or tcpdump.
You can view packet data sent including the full Ethernet frames. When viewing
your packet, you should see something similar to the below image; in this case, the
payload starts at 0x0035. The identifier - 3425 - shows up in hex as 0x0d61.
Implementation Tasks
1. TCP Handshakes - Implement TCP start and end handshakes before data
transmission starts and ends [1]. This should happen in the constructor and
destructor for case tcp socket.
2. Flow Control - You will notice that data transfer is very slow. That is because
the starter code is using the Stop-and-Wait algorithm, transmitting one packet
at a time. You can do much better by using a window of outstanding packets to
send on the network. Extend the implementation to: 1) Change the sequence
numbers and ACK numbers to represent the number of bytes sent and received
(rather than segments) 2) Implement TCP’s sliding window algorithm to send a
window of packets and utilize the advertised window to limit the amount of
data sent by the sender [2].
3. RTT Estimation - You will notice that loss recovery is very slow! One reason
for this is the starter code uses a fixed retransmission timeout (RTO) of 3
seconds. Implement an adaptive RTO by estimating the RTT [3].
4. Duplicate ACK Retransmission - another reason loss recovery is slow is that
the starter code relies on timeouts to detect packet loss. One way to recover
more quickly is to retransmit whenever you see triple duplicate ACKs.
Implement retransmission upon receipt of three duplicate ACKs.
For 325 students, you only need to implement Tasks 1 and 2; you will get extra
credits for implementing all 4 tasks. For 425 students, you will need to implement
all of them.
REMINDERS
o Submit your code to Canvas in a zip file
o If your code does not run, you will not get credits.
o Document your code (by inserting comments in your code)
o DUE: 11:59 pm, Friday, April 26th
.
请加QQ:99515681 邮箱:99515681@qq.com WX:codinghelp
- 高合丁磊准确分析市场,积极创新引领汽车发展新方向
- Ins拉群营销软件,Instagram引流工具,共同打造营销新辉煌!
- <启诺实时云会议管理系统>获得创新资金A档立项
- 2024“一带一路”瓜菜产业发展大会震撼启动 “新十年 新发展”,共迎国际盛会
- instagram多功能自动群发引流营销软件,ins出海营销必备神器
- Instagram自动登录 - ins群发工具/ig营销助手/ins引流神器/ig吸粉工具
- Instagram营销软件 - ins群发工具/ig营销助手/ins引流神器
- XCS30XL-4VQG100C: Enabling Efficient and Reliable FPGA Solutions for Embedded Systems | ChipsX
- 魔法商业的新纪元 科技魔法师心仪的WhatsApp工具是揭示市场趋势的时空传送门
- 中国膏药平台:传承千年,引领健康新风尚
- Instagram采集指定地区,ins接粉软件/ig打粉软件/ins私信软件/群发营销
- Telegram/TG群发加速引流器,电报/TG营销自动群发软件,TG/纸飞机营销加速器
- Ins批量筛选群发营销采集神器,Instagram营销工具,助你轻松营销!
- Ins/Instagram一键爆粉推广软件,ins群发采集利器强力推荐!
- WhatsApp群发云控软件,ws协议云控/ws协议号批量出售
- 宁夏银川机械租赁平台:便捷高效,助您事业腾飞
- 数据洞察TG-WS-LINE云控/自动注册机/筛料/群发炸粉:Line代筛料子揭示您业务中的关键信息
- 北京爱尔新力眼科:45岁患者选择摘镜手术 做更好的自己
- 幼儿教学设备网:开启智慧启蒙之旅的必备之选
- 一键智能,广告精准到位!商家用 跨境电商WhatsApp代拉群打造超级畅销品牌
- Ins引流推广软件,Instagram采集器一键助你博主打粉成功!
- ISLE 2024展会:洲明科技引领LED显示技术创新
- 中国抗体SM17治疗特应性皮炎(AD)之临床前结果刊登于国际科学期刊《Allergy》
- 打通通信瓶颈:精讲Telegram协议号在网络中的角色!
- instagram如何快速引粉营销,ins群发引流看这一编就够了!
- 数环通入选中国信通院《高质量数字化转型技术方案集(2023)》,积极推动企业数字化转型
- 从梦想到现实,我走过了一段曲折而又充满挑战的路。而在这段旅程中,WhatsApp拉群工具成了我实现生意喜悦变现的得力助手。
- 极空间私有云勇夺第一季度京东NAS网络存储行业双冠军
- WhatsApp拉群营销新法宝,你尝试过了吗?欢迎大家一起探讨使用心得
- 碧桂园服务紧急提醒!电动车一族必看!
推荐
- 苹果罕见大降价,华为的压力给到了? 1、苹果官网罕见大降价冲上热搜。原因是苹 科技
- B站更新决策机构名单:共有 29 名掌权管理者,包括陈睿、徐逸、李旎、樊欣等人 1 月 15 日消息,据界面新闻,B站上周发布内部 科技
- 如何经营一家好企业,需要具备什么要素特点 我们大多数人刚开始创办一家企业都遇到经营 科技
- 创意驱动增长,Adobe护城河够深吗? Adobe通过其Creative Cloud订阅捆绑包具有 科技
- 升级的脉脉,正在以招聘业务铺开商业化版图 长久以来,求职信息流不对称、单向的信息传递 科技
- 全力打造中国“创业之都”名片,第十届中国创业者大会将在郑州召开 北京创业科创科技中心主办的第十届中国创业 科技
- 丰田章男称未来依然需要内燃机 已经启动电动机新项目 尽管电动车在全球范围内持续崛起,但丰田章男 科技
- 智慧驱动 共创未来| 东芝硬盘创新数据存储技术 为期三天的第五届中国(昆明)南亚社会公共安 科技
- 老杨第一次再度抓握住一瓶水,他由此产生了新的憧憬 瘫痪十四年后,老杨第一次再度抓握住一瓶水,他 科技
- 疫情期间 这个品牌实现了疯狂扩张 记得第一次喝瑞幸,还是2017年底去北京出差的 科技