TCP连接的三次握手过程中,Server端需要做的事情是:接受连接请求,确认和发起自己的连接,这是通过一条ACK+SYN报文完成的。
如果Server端不使用TCP/IP协议栈和Socket接口函数完成连接,而是通过组装以太网报文完成连接,需要注意:
完整代码:
variables
{
ethernetPacket ppkt;
}
on ethernetPacket *
{
if (this.dir != 0)//must be ecu send
return;
if (this.destination != ethGetMacAddressAsNumber("02:00:00:00:00:52") &&
this.destination != ethGetMacAddressAsNumber("FF:FF:FF:FF:FF:FF"))
return;
if (this.arp.IsAvailable())
{
if (this.arp.protDestinationAddr == ipGetAddressAsNumber("192.168.0.52"))
{
if (this.arp.operati