Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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????


List of 29 messages in thread
TopicAuthorDate
Ethernet Connectivity with 8051            01/01/70 00:00      
   Ethernet boards            01/01/70 00:00      
   If you want to ease your design            01/01/70 00:00      
   SiLabs CP2200            01/01/70 00:00      
      thnks            01/01/70 00:00      
         All UDP is in the stack.            01/01/70 00:00      
         Try..            01/01/70 00:00      
            Clickable Links            01/01/70 00:00      
   help!!!!!!!!!!!!!!!!!!1            01/01/70 00:00      
      Network Layers            01/01/70 00:00      
      Help???????????????            01/01/70 00:00      
   SILabs gives you the code            01/01/70 00:00      
   8051 and ethernet....            01/01/70 00:00      
   Finding Nemo!            01/01/70 00:00      
   help....programming rtl8019??            01/01/70 00:00      
      RTFM            01/01/70 00:00      
      help on interfacing rtl8091 with p89v51rd2            01/01/70 00:00      
   can i go around this way????            01/01/70 00:00      
      Waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay too simplistic!!            01/01/70 00:00      
         CMX at three grand a pop            01/01/70 00:00      
            correct and            01/01/70 00:00      
   why complicate stuff???KISS=keep it simple stupid            01/01/70 00:00      
      Try this as already suggested CD220x            01/01/70 00:00      
         Clickable            01/01/70 00:00      
      But some things are just not simple!            01/01/70 00:00      
         thnks a lot..andy            01/01/70 00:00      
            tutorial            01/01/70 00:00      
               awesome suggestion            01/01/70 00:00      
                  why didn't you look there in the first place?            01/01/70 00:00      

Back to Subject List