I am using an Arduino Ethernet which uses the W5100 ethernet controller.
I want to send LLDP packets to do PoE+ power negotiation.
One issue is that when I send LLDP to the PoE Switch, it reports CRC error.
My question is whether or not the W5100 appends FCS to the MACRAW packets automatically, or do I have to add it to the payload myself?
Here is my Arduino code:
[code]#include <SPI.h> // needed for Ethernet library communication with the W5100 (Arduino ver>0018)
#include <Ethernet.h>
#include <utility/w5100.h>
SOCKET s; // our socket that will be opened in RAW mode
//LLDP packet
byte buf = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, // lldp multicast mac address
0x90, 0xA2, 0xDA, 0x0F, 0x06, 0xD9, // arduino mac address
0x88, 0xCC, //ethertype
0x02, 0x07, //Chassis ID TLV (type 1, length 7)
0x04, // Chassis ID Subtype: Mac Address
0x90, 0xA2, 0xDA, 0x0F, 0x06, 0xD9, // arduino mac address
0x04, 0x04, // Port ID TLV (type 2, length 4)
0x05, // Interface Name
0x31, 0x2f, 0x37, // 1/7
0x06, 0x02, // Time to Live TLV (type 3, length 2)
0x00, 0x78, // 120 seconds
//4-wire Power-via-MDI
0xfe, 0x05, // Optional TLV (type 127, length 5)
0x00, 0x01, 0x42, //Cisco OUI Identifier
0x01, //Cisco Subtype
B00000001,/*PSE/PD Capabilities
Reserved Bits 7:4
PSE Spare Pair Operational State: Bit3
0=Disable
1=Enable
PD Spare Pais Desired State: Bit 2
0=Disable
1=Enable
Spare Pair Detection/Classification required: Bit 1
0=Disable
1=Enable
UPOE Supported: Bit 0
0=Disable
1=Enable */
// DTE Power via MDI TLV
0xfe, 0x0c, // Optional TLV (type 127, length 12)
0x00, 0x12, 0x0f, // 802 OUI
0x02, // 802.3 subtype
B00000000, /* MDI Power Support
Reserved: Bits 7:4
PSE Pair Control Ability Supported: Bit 3
0 = Not supported
1 = Supported
PSE MDI Power State Enabled: Bit 2
0 = Disabled
1 = Enabled
PSE MDI Power Support: Bit 1
0 = Not supported
1 = Supported
Port Class: Bit 0
0 = PD
1 = PSE */
0x01, // PSE Power Pair (pethPsePortPowerPairs IETF RFC 3621)
0x05, // Power Class (pethPsePortPowerClassifications IETF RFC 3621)
B01010011, /* Type/Source/Priority
Power type: Bits 7:6
11 = Type 1 PD
10 = Type 1 PSE
01 = Type 2 PD
00 = Type 2 PSE
Power source: Bits 5:4
Where power type = PD
11 = PSE and local
10 = Local
01 = PSE
00 = Unknown
Where power type = PSE
11 = Reserved
10 = Backup source
01 = Primary power source
00 = Unknown
Reserved: Bits 3:2
Power Priority: Bits 1:0
11 = Low
10 = High
01 = Critical
00 = Unknown (default) */
0x01, 0x90, // PD requested power value 1 to 510 decimal * 0.1 Watts (40W)
0x00, 0x00, // PSE allocated power value 1 to 510 decimal * 0.1 Watts
0x00, 0x00 // End of LLDP (type 0, length 0)
// ADD CRC HERE?
};
int buflen; // length of data to send
void setup() {
// initialize the w5100 chip and open a RAW socket
W5100.init();
W5100.writeSnMR(s, SnMR::MACRAW);
W5100.execCmdSn(s, Sock_OPEN);
}
void loop() {
buflen=sizeof(buf); // we will be sending ‘buflen’ bytes across the wire
// filling buffer with some data …
// sending buffer
W5100.send_data_processing(s, buf, buflen);
W5100.execCmdSn(s, Sock_SEND_MAC);
delay(5000);
}[/code]