首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写CSEN 331、代做 C++程序语言
项目预算:
开发周期:
发布时间:
要求地区:
Programming Assignment CSEN 331 Wireless & Mobile Networks
General Guidelines
➢ Programming projects are individual assignments; each student should write his/her own code.
➢ This assignment should be written only in C programing language.
➢ Each project requires a demo, during which the student should explain how the code
works.
➢ Demos are part of the grade. The student will only receive full credit if the demo has proper results.
➢ In addition to the demo, each student should submit the source code, input/output files, and a README.txt file containing instructions on how to compile and run your source code.
➢ The program should be turned in on or before the deadline; demo must be performed on or before the deadline but after the program files have been turned in.
➢ Here are a couple of useful links to point you to the right direction for an Introduction to Socket Programming
http://beej.us/guide/bgnet/
https://www.youtube.com/watch?v=Emuw71lozdA
1. Client using UDP protocol for sending information to the Access Point (AP)
One client connects to one Access point.
The frame is recognized in UDP payload by two fields which contain identifiers:
Start of frame identifier .... 0XFFFF End of frame identifier ..... 0XFFFF
After the start of frame, the IEEE 802.11 frame is included and then the End of frame identifier will be attached, see Fig.1 in chapter 1.3.
For the FCS (Frame Check Sequence) calculation use the following function which will output FCS result for each frame sent by AP (Access Point) or client, see section 1.2.
CSEN 331 Programming Assignment
1
1.1 Operation:
a) Transmit:
For each frame which is transmitted by client or AP (Access Point) the FCS should be calculated
based on the function in chapter 1.2, and then in the FCS field of IEEE 802.11 frame inserted, the whole IEEE 802.11 frame will be included in the UDP payload field.
The client should start an ack_timer at the time the frame is sent to the AP (Access Point)), if the response related to request message (See below the list of expected response messages from AP) for each frame has not been received during ack_timer period by client before expiration of timer, then client should retransmit the frame that was sent before and restart the timer.
The timer can be set at 3 seconds (recommended) and a retry counter should be used for resending the frame. If the response for the frame does not arrive before the timeout, the client will retransmit the frame and restart the ack_timer, and the ack_timer should be reset for a total of 3 times.
If no response was received from the server after resending the same frame 3 times, the client should generate the following message and display on the screen,
“Access Point does not respond”.
b) Receive:
For each frame which is Received by client or AP (Access Point) the FCS should be re-calculated and compared with the FCS received field of IEEE 802.11 frame, if it is correct then the received frame will be accepted and according to the request message the response will be generated and sent to the client, else should AP generate an error message and display on the screen.
Note: For all frame exchanges between mobile client/AP and between AP/mobile client should use Checksum verification for transmitted and received frames (function in chapter 1.2).
List of request/response messages
The table 1 contains the list of messages:
Client
Access Point
Association Request Probe Request
RTS (Request To Send) Data
Association Response Probe Response
CTS (Clear To Send) ACK (Acknowledge)
Error Message, to be generated when no proper response for each frame after 3 times timer expires.
Table 1. List of request/response messages
CSEN 331 Programming Assignment
2
1.2. Checksum function for calculation of transmitted and received frames:
The following function for frame checksum calculation will be used, you will include this function in your code.
This FCS calculation function should be added in your code: #include
#include
#include
#include
#include
/*
* Takes in an input string and generates a 32-bit checksum hash value of type uint32_t
* This function is internally called by the function getCheckSumValue(); so not to be called directly by
developer
* Input type: String
* Output type: uint32_t */
uint32_t generate32bitChecksum(const char* valueToConvert) { uint32_t checksum = 0;
while (*valueToConvert) {
checksum += *valueToConvert++; checksum += (checksum << 10); checksum ^= (checksum >> 6);
}
checksum += (checksum << 3); checksum ^= (checksum >> 11); checksum += (checksum << 15); return checksum;
}
/*
* This function can be called by the developer to generate a 32-bit checksum directly from the pointer to your
frame structure
* The function is independent of the contents/data types used in your frame structure
* It works based on the bits in your structure
* IMPORTANT NOTE & Hint: For accurate results, you must use __attribute__((packed)) while creating your
Frame structure
* to avoid additional padding bytes which occur in C language structures
* Input: Pointer to the frame structure, the size of the frame structure, number of bytes to skip from the start
and end (for crc calculation)
* Providing example input for reference: uint32_t checksum = getCheckSumValue(&yourFrame,
sizeof(yourFrame), bytesToSkipFromStart, bytesToSkipFromEnd)
* Hint: bytesToSkipFromEnd is provided (for instance) since the CRC computation should not include the FCS
field of the payload
* Output: uint 32 bit final Check Sum value */
uint32_t getCheckSumValue(const void *ptr, size_t size, ssize_t bytesToSkipFromStart, size_t bytesToSkipFromEnd) {
const unsigned char *byte = (const unsigned char *)ptr;
// binaryString[] is a logical representation of 1 byte. Each character in it represents 1 bit.
// Do not confuse with the size of character in C language (which is 1 byte). This is just a representation. char binaryString[9]; // One additional character for the null terminator
binaryString[8] = '\0'; // Null terminator definition
CSEN 331 Programming Assignment
3
char *buffer = malloc(1); // Allocates space for an empty string (1 byte for the null terminator) buffer[0] = '\0'; // Initializes an empty string
for (size_t i = 1; i <= size; i++) { for (int j = 7; j >= 0; j--) {
int bit = (byte[i - 1] >> j) & 1;
binaryString[7 - j] = bit + '0'; // Converts bit to character '0' or '1' }
buffer = realloc (buffer, strlen(buffer) + strlen(binaryString) + 1); // Resizes buffer to fit the concatenated result
strcat(buffer, binaryString); }
buffer[strlen(buffer)-(bytesToSkipFromEnd*8)] = '\0';
memmove(buffer, buffer + (bytesToSkipFromStart*8), strlen(buffer) - (bytesToSkipFromStart*8) + 1); //+1 for null terminator
// printf("\nGenerated string: %s\n", buffer);
// printf("\nSize of generated string in bytes: %zu\n", strlen(buffer)/8);
uint32_t checkSumValue = generate32bitChecksum(buffer). free(buffer); // Freeing memory allocated by malloc.
return checkSumValue;
}
CSEN 331 Programming Assignment
4
1.3 Frame Format:
UDP Payload which will contain IEEE 802.11 frame:
Bytes: 2 2346 (Maximum) 2
Start of Frame ID
Payload
End of Frame ID
Bytes2 2 6 6 6 2 6 0-2312 4
Bit 0 Bit 15
bits2 2 4 1 1 1 1 1 1 1 1
Figure 1: UDP Payload which will contain IEEE 802.11 frame
Frame Control
Duration ID
Address 1
Address 2
Address 3
Sequence Control
Address 4
Pay load
FCS
Protocol version
Type
Sub type
To DS
From DS
More Frags
Retry
Power More
WEP ManaIgEemEeEn 80D2a.1ta1 frame.
t
order
CSEN 331 Programming Assignment
5
1.4 Procedure:
Initially client and server will set the following fields based on frame type and sub-type:
Set Protocol version: Current protocol version is 0. More Fragment: 0
Retry: Disabled
Power management: Disabled
More Data: 0
WEP: 0
Order: 0
Sequence Control: 0000
Address 4: Bridge address set to 000000000000
To DS and From DS fields: Set these fields for each frame you send properly:
• Data From client to AP
ToDS, To AP (Infrastructure Network) =1
From DS, From AP (Infrastructure Network) =0
• From AP to client:
ToDS, To AP (Infrastructure Network) =0
From DS, From AP (Infrastructure Network) =1
FCS (Frame Check Sequence): use the function mentioned in chapter 1.2. All the above fields should be set properly for each frame type and sub
type.
1. Client sends Association Request:
Set properly the fields for IEEE 802.11 frame in chapter 1.3. AP will fill in the sub type properly.
Set type = 00
Set sub type = 0000
Set Duration ID =0
Address 1 field: Final receiver address MAC address (example: AABBCCDDEEDD)
Address 2: Originator Address, (example:1245CCDDEE88) Address 3: Access point address (example: AABBCCDDEEDD)
Client will calculate FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
CSEN 331 Programming Assignment
6
2. AP (Access Point) sends Association Response to Client:
Recalculate FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
The received AP compares recalculated and received FCS values, if they are equal then will proceed with the following steps:
AP will set the subtype properly.
Set type = 00
Set sub type = 0001
Set Duration ID =XXXX <<< set any two Bytes Hex value to the user, this will be the association ID
Address 1 field: Final receiver address MAC address (example: 1245CCDDEE88) Address 2: Originator address, is AP (example: AABBCCDDEEDD)
Address 3: Access Point address (example: AABBCCDDEEDD)
All fields should be set properly.
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Calculate for this new frame the FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
3. Client sends Probe Request:
Client will fill in the type and sub type properly. Set type = 00
Set sub type = 0100
Set Duration ID =0
Address 1 field: Final receiver address MAC address (example: AABBCCDDEEDD) Address 2: Originator Address, AP (Access point address)
(example: 1245CCDDEE88)
Address 3: Access point address (example: AABBCCDDEEDD)
The client will fill in the Address 2 field with its own MAC address.
Set properly the fields for IEEE 802.11 frame in chapter 1.4. FCS (Frame Check Sequence): use the FCS function in chapter 1.2.
4. AP (Access Point) Response sends Probe Response to Client:
Prior to sending response the AP will recalculate the FCS of the received Probe Request frame by using the FCS function in chapter 1.2.
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Set Duration ID =XXXX <<< set any two Bytes Hex value to the user, this will be the association ID
The received AP compares recalculated and received FCS values, if they are equal then will proceed with the following steps:
Set properly the fields for IEEE 802.11 frame in chapter 1.3.
Address 1 field: Final receiver address MAC address (example: 1245CCDDEE88) Address 2: Originator Address, AP (Access point address)
CSEN 331 Programming Assignment
7
(example: AABBCCDDEEDD)
Address 3: Access point address (example: AABBCCDDEEDD)
FCS (Frame Check Sequence): use the FCS function in chapter 1.2.
5. Client sends RTS:
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Address 1 field: Final receiver address MAC address (example: AABBCCDDEEDD) Address 2: Originator Address, (example:1245CCDDEE88)
Address 3: Access point address (example: AABBCCDDEEDD)
Set type =01
Set sub type= 1011
Set Duration ID =4
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Calculate for this new frame the FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
6. AP (Access Point) sends CTS Response to Client:
Recalculate received FCS (Frame Check Sequence) using the FCS function in chapter 1.2. The received AP compares recalculated and received FCS values, if they are equal then will proceed with the following steps to prepare the frame.
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Address 1 field: Final receiver address MAC address (example: 1245CCDDEE88) Address 2: Originator address, is AP (example: AABBCCDDEEDD)
Address 3: Access Point address (example: AABBCCDDEEDD)
Set Type = 01
Set Sub Type = 1100
Set Duration ID =3
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Calculate for this new frame the FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
7. Client sends one Data Frame:
The received client compares recalculated and received FCS values, if they are equal then will proceed with the following steps:
Address 1 field: Final receiver address MAC address (example: AABBCCDDEEDD) Address 2: Originator Address, (example:1245CCDDEE88)
Address 3: Access point address (example: AABBCCDDEEDD) Set Type = 10
Set Sub Type = 0000
Set Duration ID =2
The 802.11 payload can be any hex value the maximum length is 2312 Bytes, if less than this value fills in the rest with 0XFF.
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
CSEN 331 Programming Assignment
8
Calculate for this new frame the FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
8. AP (Access Point) sends ACK to Client:
Recalculate FCS (Frame Check Sequence) using the FCS function in chapter 1.2. to calculate FCS.
The received AP compares recalculated and received FCS values, if they are equal then will proceed with the following steps to send ACK:
Address 1 field: Final receiver address MAC address (example: 1245CCDDEE88) Address 2: Originator address, is AP (example: AABBCCDDEEDD)
Address 3: Access Point address (example: AABBCCDDEEDD)
Set Type = 01
Set Sub Type = 1101
Set Duration ID =1
Set properly the fields for IEEE 802.11 frame in chapter 1.4.
Calculate for this new frame the FCS (Frame Check Sequence) using the FCS function in chapter 1.2.
++++++++++++++++++++++++++++++++++++++++++++++++ 9. FCS Error handling:
NOTE: After successful transmission of data frame which client sends and receive of ACK (Above items 7 and 8), the client should generate a frame with wrong
checksum, filling FCS field with some data which is not calculated by FCS (Frame Check Sequence) function in chapter 1.2.
The AP (Access Point) should generate an error message for FCS (Frame Check Sequence) error after recalculation of checksum which recognizes this value is not equal to the received FCS (Frame Check Sequence).
AP (Access Point) generates the error message “FCS (Frame Check Sequence) Error” and displays on the screen.
***************************************************
10. Sending Multiple Frame Procedure:
Client sends five fragmented frames (Frame 1, 2, 3, 4, 5) which are fragments of a file to the AP.
Prior client sending the 5 frames, send one time the RTS frame with Duration ID =12, AP response CTS with Duration ID =11 (This procedure will allocate time for the 5 frames and ACKs transmissions)
For each DATA frame sent from client Duration ID will be decremented, and for each frame sent from AP Duration ID will be decremented.
The AP acknowledges with ACK frame the correct frame received from client by sending five ACK frames.
Set the parameters in IEEE 802.11 header properly for client and AP (see chapter 7 and 8) in addition you need to set the more fragment bit properly.
CSEN 331 Programming Assignment
9
The client then sends another five fragmented frames (Frame 1, 2, 3, 4, 5) to the AP, emulating one correct frame and four frames with errors.
The server acknowledges with ACK each correct frame sent from client, and with corresponding error message displayed on the screen “No ACK Received for Frame No.X” for the frames with errors (Total of four error message).
The client will start an ack_timer at the time each frame is sent to AP, if the ACK frmae for each frame has not been received during ack_timer period by client before expiration of timer then client should retransmit again the frame that was sent before.
The timer can be set at 3 seconds (recommended) and a retry_ack_counter should be used for resending the frame. If the ACK for the frame does not arrive before the ack_timer times out, the client will retransmit the frame and restart the ack_timer, and the ack_timer should be reset for a total of 3 times (retry_ack_counter = 3).
If no ACK is received from the AP after resending the same frame 3 times, the client should generate the following message and display on the screen:
“No ACK received from AP”.
Error handling:
NOTE: All four error handling messages should be simulated and displayed on the screen, the error response messages should be included in a (.pdf, .png, .jpg) file and turned in with your source code.
CSEN 331 Programming Assignment
10
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!