Introduction部分代码示例:struct sockaddr_in serv;int Socket_bind(char hostname, unsigned short int hostUDPport){int s;struct timeval timeout={0,10};s=socket(AF_INET,SOCK_DGRAM,0);bzero(serv,sizeof(serv));serv.sin_family=AF_INET;serv.sin_addr.s_addr=inet_addr(hostname);serv.sin_port=htons(hostUDPport);int Socket_Buf_Size=641024;setsockopt(s,SOL_SOCKET,SO_RCVBUF,(const char)Socket_Buf_Size,sizeof(int));setsockopt(s,SOL_SOCKET,SO_SNDBUF,(const char)Socket_Buf_Size,sizeof(int));setsockopt(s,SOL_SOCKET,SO_RCVTIMEO,(char)timeout,sizeof(struct timeval));return(s);}发送端中这三个参数分别表示每帧中数据的大小以及RTT就是等待的时延,以及回退N步的N在接受端中表示帧大小,修改的时候两边都要统一RequirementCS/ECE 438: Communication Networks Spring 2017Machine Problem 3Reliable Congestion ControlDue: Friday, Apr 28, 11:59pmPlease read all sections of this document before you begin coding.In this MP, you will implement a transport protocol with properties equivalent to TCP.You have been provided with a file called sender_main.c, which declares the functionvoid reliablyTransfer(char hostname, unsigned short inthostUDPport, char filename, unsigned long long int bytesToTransfer)This function should transfer the first bytesToTransfer bytes of filename to the receiver athostname: hostUDPport correctly and efficiently, even if the network drops or reorders someof your packets.You also havereceiver_main.c, which declares the functionvoid reliablyReceive(unsigned short int myUDPport, chardestinationFile)This function is reliablyTransfer’s counterpart, and should write what it receives to a file calleddestinationFile.Your job is to implement these two functions, with the following requirements:• The data written to disk by the receiver must be exactly what the sender was given.• Two instances of your protocol competing with each other must converge to roughly fairsharing the link (same throughputs +/- 10%) within 100 RTTs. The two instances might not bestarted at the exact same time.• Your protocol must be somewhat TCP friendly: an instance of TCP competing with you mustget on average at least half as much throughput as your flow.• An instance of your protocol competing with TCP must get on average at least half as muchthroughput as the TCP flow.• All of the above should hold in the presence of any amount of dropped or reordered packets.All flows, including the TCP flows, will see the same rate of drops/reorderings. The networkwill not introduce bit errors.• Your protocol must get reasonaC代写 CS/ECE 438 Communication Networks Spring 2017调试SQL课程设计bly good performance when there is no competing traffic, andpackets are not artificially dropped or reordered. Aim for at least 33 Mbps on a 100 Mbps link.CS/ECE 438: Communication Networks Spring 2017• You cannot use TCP in any way. Use SOCK_DGRAM (UDP), not SOCK_STREAM (TCP).The test environment has a ≤ 100 Mbps connection, and an unspecified RTT – meaning you’llneed to estimate the RTT for timeout purposes, like real TCP.Appendix – NOTES : Same as the notes of the previous assignments, plus:• The MTU on the test network is 1500, so up to 1472 bytes payload (IPv4 header is 20 bytes,UDP is 8bytes) won’t get fragmented. You can sendto() larger packets and the sockets library’sUDP will handle fragmentation/reassembly for you. It’s up to you to reason out the benefitsand drawbacks of using large UDP packets in various settings.• You can use the provided main files to be sure your program runs with the right interface, orwrite your own. Executable names: reliable_sender and reliable_receiver. Asingle run of “make” (with no arguments) inside your mp3 directly should build both binaries.• Be sure you have a clean design for implementing the send/receive buffers. Trying to figureout where to get the data to resend an old packet won’t be fun if your send window’s bufferdoesn’t have a nice clean interface.• Input files on the autograder are READ-ONLY. In your program, please open file with readmode only.• Input files on the autograder are general binary data, NOT text.Appendix – Replicating the Test EnvironmentYou can use the same basic test environment described in MP1. However, the network performancewill be ridiculously good (same goes for testing on localhost), so you need to limit it. The autograderuses tc. If your network interface inside the VM is eth0, then run (from inside the VM) the followingcommand:sudo tc qdisc del dev eth0 root 2>/dev/nullto delete exising tc rules.sudo tc qdisc add dev eth0 root handle 1:0 netem delay 20ms loss 5%followed byCS/ECE 438: Communication Networks Spring 2017sudo tc qdisc add dev eth0 parent 1:1 handle 10: tbf rate 100Mbitburst 40mb latency 25mswill give you a 100 Mbit, ~20 ms RTT link where every packet sent has a 5% chance to get dropped.Simply omit the loss n% part to get a channel without artificial drops.You can run these commands on just the sender; running them on the receiver as well won’t makemuch of a difference, although you’ll get a ~40 ms RTT if you don’t adjust the delay to account for thefact that it gets applied twice.转自:http://ass.3daixie.com/2019011414390059.html
讲解:C CS/ECE 438 Communication Networks Spring 2017SQL
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 打卡日期:2019/03/23 90天打卡累计天数:53/90 #亲爱的孩子,我要接纳你、相信你,和你共同成长# ...