美文网首页
讲解:CBOK categories、c++、c++、Compu

讲解:CBOK categories、c++、c++、Compu

作者: kuijinzhong | 来源:发表于2020-01-12 11:44 被阅读0次

2019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 1/8Praccal2: (UG only) Reliable Transport with SelecveRepeatProgramming PraccalDue Friday by 17:00 Points 100Adapted from Kurose & Ross - Computer Networking: a top-down approach featuring the InternetCBOK categories: Abstraction, Design, Data & Information, Networking, ProgrammingForewordThis practical requires thought and planning. You need to start early to allow yourself time to think of what andhow to test before modifying any code. Failing to do this is likely to make the practical take far more time than itshould. Starting the practical in the final week is likely to be an unsuccessful strategy with this practical.TaskImplement reliable transport protocol using Selective Repeat in C by studying and extending an implmentation ofGo Back N running on a network simulator.BackgroundYouve been hired by Net Source, a company specialising in networking software to build Selective Repeat codefor their network emulation tool. They have an existing implementation of Go-Back-N that interfaces with theiremulator. Their programmer, Mue, who was working on an implementation of the Selective Repeat protocol hascaught the flu and the implementation must absolutely be finished in the next week. As the code isnt finished,Mue hasnt completed testing yet. Mue is an experienced C programmer and there is nothing wrong with the Csyntax or structure of the code that Mue has written. So you dont have to correct any C syntax errors, your job isto finish the code, correct any protocol errors and test it.Although you are not required to use this code, they expect much of this code is reusable and only somemodifications are needed to change Go-Back-N to Selective Repeat. Your boss realises youre not a C expert, butat least youve programmed in Java or C++ before so youre the closest they have as an expert. Their last Cprogrammer has written a C hints for Java and C++ programmers sheet which explains what you need to knowabout C that is different than Java and C++. Shes confident that if you stick to the sheet, anything else you needto add or change would be the same if you wrote it in Java or C++.System OverviewTo help isolate and demonstrate the behaviour of the sender and receiver, you have a simulation system at yourdisposal. The overall structure of the environment is shown below:2019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 2/8There are two hosts (A and B). An application on host A is sending messages to an application on host B. Theapplication messages (layer 5) on host A are sent to layer 4 (transport) on host A, which must implement thereliable transport protocol for reliable delivery. Layer 4 creates packets and sends them to the network (layer 3).The network transfers (unreliably) these packets to host B where they are handed to the transport layer (receiver) and if not corrupt or out of order, the message is extracted and delivered to the receiving application(layer 5) on host B.The file gbn.c has the code for the Go Back N sender procedures A_output() , A_init() , A_input() , andA_timerinterrupt() . gbn.c also has the code for the Go Back N receiver procedures B_input() and B_init() . Atthis stage, only unidirectional transfer of data (from A to B) is required, so B does not need to implementB_timerinterrupt() . Of course, B will have to send packets to A to acknowledge receipt of data.Go Back N SowareInterfaceThe routines are detailed below. Such procedures in real-life would be part of the operating system, and would becalled by other procedures in the operating system. In the simulator the simulator will call and be called byprocedures that emulate the network environment and operating system.message is a structure containing data to be sent to B. This routine will be called whenever the upper layerapplication at the sending side (A) has a message to send. It is the job of the reliable transport protocol to insurethat the data in such a message is delivered in-order, and correctly, to the receiving side upper layer.This routine will be called whenever a packet sent from B (i.e., as a result of a tolayer3() being called by a Bprocedure) arrives at A. packet is the (possibly corrupted) packet sent from B.This routine will be called when As timer expires (thus generating a timer interrupt). This routine controls theretransmission of packets. See starttimer() and stoptimer () below for how the timer is started and stopped.1 void A_output(struct msg message)1 void A_input(struct pkt packet)1 void A_timerinterrupt(void)1 void A_init(void)2019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 3/8This routine will be called once, before any other A-side routines are called. It is used to do any requiredinitialization.This routine will be called whenever a packet sent from A (i.e., as a result of a tolayer3() being called by a A-sideprocedure) arrives at B. The packet is the (possibly corrupted) packet sent from A.This routine will be called once, before any other B-side routines are called. It is used to do any requiredinitialization.The unit of data passed between the application layer and the transport layer protocol is a message, which isdeclared as:That is, data is stored in a msg structure which contains an array of 20 chars. A char is one byte. The sendingentity will thus receive data in 20-byte chunks from the sending application, and the receiving entity should deliver20-byte chunks to the receiving application.The unit of data passed between the transport layer and the network layer is a packet , which is declared as:The A_output() routine fills in the payload field from the message data passed down from the Application layer.The other packet fields must be filled in the a_output routine so that they can be used by the reliable transportprotocol to insure reliable delivery, as weve seen in class.These functions implement what the sender and receiver should do when packets arrive.The Emulator SowareInterfaceThis section will describe the functions of the emulator code that you will be using in your implementation. Do notedit the emulator code.The procedures described above implement the reliable transport layer protocol and are the procedures that youwill be implementing.The following emulator procedures can be called by the reliable transport procedures you write. They areexplained here so you know how they fit in. They are not part of the reliable transport implementation and theseroutines work correctly.1 void B_input(struct pkt packet)1 void B_init(void)struct msg { char data[20];};struct pkt { int seqnum; int acknum; int checksum; char payload[20];};�1 void starttimer(int calling_entity, double);2019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 4/8Where calling_entity is either A (for starting the A-side timer) or B (for starting the B side timer), and increment isa float value indicating the amount of time that will pass before the timer interrupts. As timer should only bestarted (or stopped) by A-side routines, and similarly for the B-side timer. To give you an idea of the appropriateincrement value to use: a packet sent into the network takes an average of 5 time units to arrive at the other sidewhen there are no other messages in the medium. You are free to experiment with different timeout values;but when handing in, the timeout value must be set to 15.0Note that starttimer() is not the same as restarttimer() . If a timer is already running it must be stopped before itis started. Calling starttimer() when the timer is already running, or calling stoptimer() when the timer is notrunning, indicates an error in the protocol behaviour and will result in an error message.The emulator code is in the file emulator.c .Use the emulator header file to refere to the definitions of the emulatorfunctions. You do not need to understand or look at emulator.c ; but if you want to know how the emulator works,you are welcome to look at the code.The starttimer() call should occur immediately after the tolayer3() call that sends the packet being timed.Where calling_entity is either A (for stopping the A-side timer) or B (for stopping the B side timer).Where calling_entity is either A (for the A-side send) or B (for the B side send). Calling this routine will cause athe packet to be sent into the network, destined for the other entity.Where calling_entity is either A (for A-side delivery to layer 5) or B (for B-side delivery to layer 5). Withunidirectional data transfer, you would only be calling this when calling_entity is equal to B (delivery to the Bside).Calling this routine will cause data to be passed up to layer 5.Download the following 4 files and examine the code in gbn.c with the description above and your knowledge ofGo Back N to make sure you understand how the program fits together:emulator.cemulator.hgbn.cgbn.hTo build the program use the command:Running the simulated networkThe emulator is capable of corrupting and losingCBOK categories作业代做、c++课程设计作业代做、c++程序语言作业调试、代写Computer Netwo packets. It will not reorder packets. When you compile and runthe resulting program, you will be asked to specify values regarding the simulated network environmentFor example1 void stoptimer(int calling_entity)1 void tolayer3(int calling_entity, struct packet)1 void tolayer5(int calling_entity, char[20] message)1 $ gcc -Wall -ansi -pedantic -o gbn emulator.c gbn.c$ ./gbn----- Stop and Wait Network Simulator Version 1.1 --------122019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 5/8Number of messages to simulateThe emulator will stop generating messages as soon as this number of messages have been passed down fromlayer 5.LossYou are asked to specify a packet loss probability. A value of 0.1 would mean that one in ten packets (onaverage) are lost.CorruponYou are asked to specify a packet corruption probability. A value of 0.2 would mean that one in five packets (onaverage) are corrupted. Note that the contents of payload, sequence or ack field can be corrupted.Average mebetween messages from senders layer5You can set this value to any non-zero, positive value. Note that the smaller the value you choose, the fasterpackets will be generated.TracingSetting a tracing value of 1 or 2 will print out useful information about what is going on inside the emulation (e.g.,whats happening to packets and timers). A tracing value of 0 will turn this off. A tracing value greater than 2 willdisplay all sorts of messages that detail what is happening inside the emulation code as well. A tracing value of 2may be helpful to you in debugging your code. You should keep in mind that real implementors do not haveunderlying networks that provide such nice information about what is going to happen to their packets!Take a moment to experiment with the simulated environment and look at the events that occur. Trysending a few packets with no loss or corruption. Does the protocol work properly? Try with just loss.Try with just corruption.SelecveRepeatOnce you have inspected Go Back N and understand how the implementation works, you need to study carefullyhow Selective Repeat (SR) differs from Go Back N. Consider how GBN and SR respond to ACKs, timeouts, newmessages, etc on both the sender and the receiver side. In what cases is their behavior the same and in whatcases is it different.Enter the number of messages to simulate: 10Enter packet loss probability [enter 0.0 for no loss]:0Enter packet corruption probability [0.0 for no corruption]:0Enter average time between messages from senders layer5 [ > 0.0]:10Enter TRACE:282019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 6/8When you have considered the similarities and differences, you should be able to identify what changes you willneed to make to the existing GBN implementation in order to implement SR. Copy the gbn.c file to a file calledsr.c and copy gbn.h to sr.h. Design your changes and then implement those changes in your sr.c file.The implementation of Selective Repeat should be identical to that described in the textbook (Section: Principlesof Reliable Data Transfer)When you have completed your selective repeat implementation you can compile it with:Some TipsCompiler flagsWhen you recompile the program. Using the -ansi -Wall -pedantic flags will give you useful warnings if you aredoing something that is likely to be wrong (like using = rather than ==, or misusing a data structure). If you getany warnings, fix them before submitting. Warnings indicate that there is something wrong, even if the programcompiles. If you cant work out the warning, ask on the discussion board.Code - Compile - Test - RepeatMake one change at a time and devise a test case to check that your addition actually works. For example, if youwanted to check that B was responding correctly to an out of order packet, send a few (say 2) packets with a lossprobability of .2 and see how B responds. If none of the packets are lost, then increase the loss probability untilyou get a case where one of the packets is lost and a packet arrives out of order so you can see Bs response.Be sure to commit your changes to svn or they wont be testedOnce youre confident you have the selective repeat protocol working, or if you are really stuck on what is wrong,submit to websubmission system. A test script will run a series of tests specifically designed to identify whetherthe protocol is behaving as expected. If your corrected program does not pass one of the tests, The test script willstop at that point and show you the expected output of the test and your output. By comparing the two you shouldbe able to work out at least one thing that the protocol is still doing incorrectly.The testing script we run is not a program with high-level reasoning abilities, its possible that you might dosomething unexpected that will trick it. Inspecting the output should allow you to identify whether the problem iswith your implementation or just an unexpected output.What you C is what you getThis programming assignment is in the C language. Most networking system code and many networkedapplications are written in C, so we consider it important that you have at least seen C and can do some basicreading and debugging in the language. The code is given and the syntax of C and Java are very similar/same asare the basic structures (if/then, loops, etc), so we do expect that third year students can accomplish this. Themain C concepts that you may not have come across in Java will be accessing structures and handling pointers.We have provided a C hints (https://cs.adelaide.edu.au/users/third/cn/Practicals/Chints.html) sheet which explainswhat you need to know that is different than Java. Unless you are familiar with C, please stick to our hints. Itseasy to get memory manipulation wrong in C and it can be quite difficult to debug. The code has been carefully1 $ gcc -Wall -ansi -pedantic -o sr emulator.c sr.c2019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 7/8Practical 2: Selective Repeat (If your submitted code hangs, crashes or does not compile you will get anautomatic zero. Marks on the rubrics for each tests is allocated for a full and correct implementationonly and there are no partial marks) (1)structured so that you do not need to make use of pointers. If you are experienced with C, you can use pointers, ifyou are not experienced with C, then stick to static arrays as the GBN implementation does. The hint sheet givesyou the easy/clear way of doing the things. Remember that the given code is correct C, so you can use the givencode as examples for how to manage the arrays and structures. If you do have any questions still after looking atthe examples, please dont hesitate to post questions (even code fragments) on the discussion board.Handing InYou will need to use SVN to store your practical files (refer to the SVN notes for setting up your repository for thispractical). The handin key for this practical is2019/s1/cna/srYou can submit and automatically mark your assignment by following this link(https://cs.adelaide.edu.au/services/websubmission/) to the web-submission system.The websubmission script will expect a sr.c file to be found in your repoistory.Each submission to the marking link after the second submission will result in a 1 mark reduction fromthe available 100 marks.If your submitted code hangs, crashes or does not compile you will get an automatic zero. Marks on therubrics for each tests is allocated for a full and correct implementation only and there are no partialmarks for a given test.The marks assigned by mark submission link are provisional. You are responsible for writing a workingimplementation and for testing your implementation. Any errors discovered during review will reduce your markfor that functionality. Were not hiding anything, but it is possible that you might create an implementation that hasan error not exercised by mark submission link.PLEASE NOTE: the changes you make to sr.c must not add, remove or change any comments printedwhen the trace level is set to 2 or 3. You can, and should, add comments about what is happening in yourcode at other trace levels to assist in debugging.2019/4/29 Practical 2: (UG only) Reliable Transport with Selective Repeat Programming Practicalhttps://myuni.adelaide.edu.au/courses/45382/assignments/105568 8/8Total Points: 100.0Criteria Ratings Pts5.0 pts5.0 pts10.0 pts10.0 pts10.0 pts10.0 pts30.0 pts20.0 ptsbasic functionality 5.0 ptsFull Marks0.0 ptsNo Marksbasic functionality with full window 5.0 ptsFull Marks0.0 ptsNo Markslost ACK/timeouts 10.0 ptsFull Marks0.0 ptsNo Markshandles corrupted packets 10.0 ptsFull Marks0.0 ptsNo Markshandles corrupted ACK 10.0 ptsFull Marks0.0 ptsNo Marksdelivering previously buffered packets 10.0 ptsFull Marks0.0 ptsNo Markshandles lost packet, duplicate packet, duplicate ACK 30.0 ptsFull Marks0.0 ptsNo Markshandles mixed events, window management and high message volumes 20.0 ptsFull Marks0.0 ptsNo Marks转自:http://www.7daixie.com/2019050556937822.html

相关文章

  • 讲解:CBOK categories、c++、c++、Compu

    2019/4/29 Practical 2: (UG only) Reliable Transport with ...

  • C++核心编程

    title: C++核心编程 categories: [C++] tags: [编程语言] date: 2021/...

  • STL核心编程

    title: STL核心编程 categories: [C++] tags: [编程语言] date: 2021/...

  • [C++] Types and Value categories

    Each C++ expression (an operator with its arguments, a li...

  • C++_day06

    C++核心编程 主要针对C++面向对象编程技术做详细讲解,探讨C++中的核心和精髓 1. 内存分区模型 C++程序...

  • 理解C++虚函数

    title: 理解C++虚函数date: 2018-11-11 15:31:26categories:- 概念理解...

  • C++牛逼资料指南

    C++个人博客指南 http://www.forz.site/categories/找工作最牛逼的https://...

  • C++ 变量

    title: c++之变量tags: 语言工具-c++categories: c++date: 2019-02-1...

  • 类和对象

    title: c++之类和对象tags: 语言工具 c++categories: c++date: 2019-02...

  • 继承

    title: c++之继承tags: 语言工具 c++categories: c++date: 2019-02-2...

网友评论

      本文标题:讲解:CBOK categories、c++、c++、Compu

      本文链接:https://www.haomeiwen.com/subject/inmiactx.html