??? 02/01/07 13:50 Read: times |
#131880 - can i go around this way???? Responding to: ???'s previous message |
thank you sir
but my project requires me to send simple udp data(a number infact) with proper headers for ethernet,IP,UDP. cant i deal it the way below. can you help me out how to go about writing i/o to the NIC device.datasheet does not give the procedure to configure the device but the registers and specifications. Cant i write a code similar to below just going on writing to the NIC i/o write with proper header structures if i would know the ip address and mac address of the source(microcontroller) and destination(PC).would this work?? ///////////////////////////////////// // Ethernet Header //////////////////////////////////// // Send Destination (6 bytes) // MAC address of Router of Embedded Lab (00-00-1d-bc-79-d7) ioWrite(RxTxData, 0x00); ioWrite(RxTxData+1, 0x00); ioWrite(RxTxData, 0x1d); ioWrite(RxTxData+1, 0xbc); ioWrite(RxTxData, 0x79); ioWrite(RxTxData+1, 0xd7); // Send Source (6 bytes) // MAC address of my laptop (00-00-86-45-b7-b2) ioWrite(RxTxData, 0x00); ioWrite(RxTxData+1, 0x00); ioWrite(RxTxData, 0x86); ioWrite(RxTxData+1, 0x45); ioWrite(RxTxData, 0xb7); ioWrite(RxTxData+1, 0xb2); // Send Protocol Type (2 bytes) // 0x0806 (ARP) // 0x0800 (IP) ioWrite(RxTxData, 0x08); ioWrite(RxTxData+1, 0x00); ///////////////////////////////////// // IP Header ///////////////////////////////////// // Version Header Length (1 byte) // Using IPv4 ioWrite(RxTxData, 0x45); // Service (1 byte) // Normally set to zero because not used ioWrite(RxTxData+1, 0x00); // Length (2 bytes) // 33 byte length ioWrite(RxTxData, 0x00); ioWrite(RxTxData+1, 0x21); // Identifier (2 bytes) // 0x0000 ioWrite(RxTxData, 0x00); ioWrite(RxTxData+1, 0x00); // Flags Fragment offset (2 bytes) // 0x4000 ioWrite(RxTxData, 0x40); ioWrite(RxTxData+1, 0x00); // Time to Live (1 byte) // 63 ioWrite(RxTxData, 0x3f); // Protocol (1 byte) // ICMP (1), TCP (6), UDP (17) // UDP 0x11 = 17 ioWrite(RxTxData+1, 0x11); // Checksum (2 bytes) // 0xb273 // Checksum is 0xffffh - the sum of all IP header info ioWrite(RxTxData, 0xb2); ioWrite(RxTxData+1, 0x73); // Source Address (4 bytes) // IP address 138.23.204.32 (arbitrary) ioWrite(RxTxData, 0x8a); // 138 ioWrite(RxTxData+1, 0x17); // 23 ioWrite(RxTxData, 0xcc); // 204 ioWrite(RxTxData+1, 0x20); // 32 // Destination Address (4 bytes) // IP address 138.23.169.9 (hill) ioWrite(RxTxData, 0x8a); // 138 ioWrite(RxTxData+1, 0x17); // 23 ioWrite(RxTxData, 0xa9); // 169 ioWrite(RxTxData+1, 0x09); // 9 ///////////////////////////////////// // UDP Header ///////////////////////////////////// // Source Port (2 bytes) // Port 47098 (b7fa) ioWrite(RxTxData, 0xb7); ioWrite(RxTxData+1, 0xfa); // Destination Port (2 bytes) // Port 4950 (1356h) ioWrite(RxTxData, 0x13); ioWrite(RxTxData+1, 0x56); // Message Length (2 bytes) // 13 bytes going to be sent ioWrite(RxTxData, 0x00); ioWrite(RxTxData+1, 0x0d); // Checksum (2 bytes) // 0x0000 (no checksum used) ioWrite(RxTxData, 0x00); ioWrite(RxTxData+1, 0x00); // Write Message(DATA) ioWrite(RxTxData,DATA); ioWrite(RxTxData+1, 0x00); io write is function to write to NIC.would this work???? |