1 |
hedin |
15 |
/*********************************************************************
|
2 |
|
|
*
|
3 |
|
|
* TCP Performance Test
|
4 |
|
|
* Module for Microchip TCP/IP Stack
|
5 |
|
|
* -Establishes a connection and then sends out dummy packets
|
6 |
|
|
* from ROM memory
|
7 |
|
|
* -Reference: None. This is for testing only.
|
8 |
|
|
*
|
9 |
|
|
*********************************************************************
|
10 |
|
|
* FileName: TCPPerformanceTest.c
|
11 |
|
|
* Dependencies: TCPIP.h
|
12 |
|
|
* Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F
|
13 |
|
|
* Complier: Microchip C18 v3.02 or higher
|
14 |
|
|
* Microchip C30 v2.01 or higher
|
15 |
|
|
* Company: Microchip Technology, Inc.
|
16 |
|
|
*
|
17 |
|
|
* Software License Agreement
|
18 |
|
|
*
|
19 |
|
|
* Copyright © 2002-2007 Microchip Technology Inc. All rights
|
20 |
|
|
* reserved.
|
21 |
|
|
*
|
22 |
|
|
* Microchip licenses to you the right to use, modify, copy, and
|
23 |
|
|
* distribute:
|
24 |
|
|
* (i) the Software when embedded on a Microchip microcontroller or
|
25 |
|
|
* digital signal controller product (“Device”) which is
|
26 |
|
|
* integrated into Licensee’s product; or
|
27 |
|
|
* (ii) ONLY the Software driver source files ENC28J60.c and
|
28 |
|
|
* ENC28J60.h ported to a non-Microchip device used in
|
29 |
|
|
* conjunction with a Microchip ethernet controller for the
|
30 |
|
|
* sole purpose of interfacing with the ethernet controller.
|
31 |
|
|
*
|
32 |
|
|
* You should refer to the license agreement accompanying this
|
33 |
|
|
* Software for additional information regarding your rights and
|
34 |
|
|
* obligations.
|
35 |
|
|
*
|
36 |
|
|
* THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT
|
37 |
|
|
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
|
38 |
|
|
* LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
39 |
|
|
* PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
40 |
|
|
* MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
|
41 |
|
|
* CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
|
42 |
|
|
* PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
|
43 |
|
|
* BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
|
44 |
|
|
* THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
|
45 |
|
|
* SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
|
46 |
|
|
* (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
|
47 |
|
|
*
|
48 |
|
|
*
|
49 |
|
|
* Author Date Comment
|
50 |
|
|
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
51 |
|
|
* Howard Schlunder 01/29/07 Original
|
52 |
|
|
********************************************************************/
|
53 |
|
|
#define __TCPPERFORMANCETEST_C
|
54 |
|
|
|
55 |
|
|
#include "TCPIP Stack/TCPIP.h"
|
56 |
|
|
#if defined(STACK_USE_TCP_PERFORMANCE_TEST)
|
57 |
|
|
|
58 |
|
|
#define PERFORMANCE_PORT 12345
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
/*********************************************************************
|
62 |
|
|
* Function: void TCPPerformanceTask(void)
|
63 |
|
|
*
|
64 |
|
|
* PreCondition: Stack is initialized()
|
65 |
|
|
*
|
66 |
|
|
* Input: None
|
67 |
|
|
*
|
68 |
|
|
* Output: None
|
69 |
|
|
*
|
70 |
|
|
* Side Effects: None
|
71 |
|
|
*
|
72 |
|
|
* Overview: Opens a TCP socket, listens for a connection, and
|
73 |
|
|
* then transmits some big data
|
74 |
|
|
*
|
75 |
|
|
* Note: None
|
76 |
|
|
********************************************************************/
|
77 |
|
|
void TCPPerformanceTask(void)
|
78 |
|
|
{
|
79 |
|
|
static TCP_SOCKET MySocket = INVALID_SOCKET;
|
80 |
|
|
static DWORD_VAL dwVLine;
|
81 |
|
|
BYTE buffer[12];
|
82 |
|
|
WORD w;
|
83 |
|
|
|
84 |
|
|
// Start the TCP server, listening on PERFORMANCE_PORT
|
85 |
|
|
if(MySocket == INVALID_SOCKET)
|
86 |
|
|
{
|
87 |
|
|
MySocket = TCPListen(PERFORMANCE_PORT);
|
88 |
|
|
|
89 |
|
|
// Abort operation if no UDP sockets are available
|
90 |
|
|
// If this ever happens, incrementing MAX_UDP_SOCKETS in
|
91 |
|
|
// StackTsk.h may help (at the expense of more global memory
|
92 |
|
|
// resources).
|
93 |
|
|
if(MySocket == INVALID_SOCKET)
|
94 |
|
|
return;
|
95 |
|
|
|
96 |
|
|
dwVLine.Val = 0;
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
// See how many bytes we can write to the TX FIFO
|
100 |
|
|
w = TCPIsPutReady(MySocket);
|
101 |
|
|
|
102 |
|
|
// Constant data in RAM
|
103 |
|
|
buffer[0] = '0';
|
104 |
|
|
buffer[1] = 'x';
|
105 |
|
|
buffer[10] = ':';
|
106 |
|
|
buffer[11] = ' ';
|
107 |
|
|
|
108 |
|
|
// Transmit as much data as the TX FIFO will allow
|
109 |
|
|
while(w >= 62u)
|
110 |
|
|
{
|
111 |
|
|
// Convert line counter to ASCII hex string
|
112 |
|
|
buffer[2] = btohexa_high(dwVLine.v[3]);
|
113 |
|
|
buffer[3] = btohexa_low(dwVLine.v[3]);
|
114 |
|
|
buffer[4] = btohexa_high(dwVLine.v[2]);
|
115 |
|
|
buffer[5] = btohexa_low(dwVLine.v[2]);
|
116 |
|
|
buffer[6] = btohexa_high(dwVLine.v[1]);
|
117 |
|
|
buffer[7] = btohexa_low(dwVLine.v[1]);
|
118 |
|
|
buffer[8] = btohexa_high(dwVLine.v[0]);
|
119 |
|
|
buffer[9] = btohexa_low(dwVLine.v[0]);
|
120 |
|
|
|
121 |
|
|
// Place all data in the TCP TX FIFO
|
122 |
|
|
TCPPutArray(MySocket, buffer, sizeof(buffer));
|
123 |
|
|
TCPPutROMArray(MySocket, (ROM BYTE*)"The fox smoked crack and died. This is 62 bytes.\r\n", 50);
|
124 |
|
|
|
125 |
|
|
dwVLine.Val++;
|
126 |
|
|
w -= 62;
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
// Send everything immediately
|
130 |
|
|
TCPFlush(MySocket);
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
#endif //#if defined(STACK_USE_TCP_PERFORMANCE_TEST)
|