Hi I have an embedded device which is 2 different port. One is communicate with raw socket another device. Other port is using TCP/IP packet type. When I plug these two ports into the switch which is same vlan it cause a network problem. My device can not connect TCP/IP socket for a while(~ 15second) Also my Raw Socket couldn't communicate with other raw socket device(Other device raw socket also plug same switch). There is shown below WireShark log wireshark pcap tcp packet drop
But if I managed the switch different Vlan's. I mean configure Tcp ports different and raw ports different Vlan. Then problem is solved.
Here is my raw socket source code;
int createRawSocket( char* sznetwork_interface_name ) { int i,ioctl_sock,ifindex, raw_sock=0;
ioctl_sock = socket ( AF_INET, SOCK_DGRAM, 0 );
if ( ioctl_sock < 0 )
{
printf("\nFailed to create ioctl_sock socket\n");
return -1;
}
/*Create raw socket*/
raw_sock = socket ( AF_PACKET, SOCK_RAW, htons ( ETH_P_ALL ));
if ( raw_sock < 0 )
{
printf("\nFailed to create raw_sock socket\n");
return -1;
}
strncpy ( abc_config.ifr.ifr_name, sznetwork_interface_name, sizeof (abc_config.ifr.ifr_name ));
/*Get the interface index*/
if ( ioctl ( ioctl_sock, SIOCGIFINDEX, &abc_config.ifr ) != 0 )
{
printf ("\nFailed to call ioctl 3\n");
return -1;
}
ifindex = abc_config.ifr.ifr_ifindex;
printf("Successfully got RAW interface index: %i\n\r", ifindex);
/*
* prepare sockaddr_ll
*/
abc_config.socket_address.sll_family = AF_PACKET;
abc_config.socket_address.sll_ifindex = abc_config.ifr.ifr_ifindex;
/*Bind to the raw socket*/
if( bind(raw_sock, (struct sockaddr *)&abc_config.socket_address, sizeof(abc_config.socket_address)) < 0 )
{
printf("\nFailed to bind \n");
return -1;
}
/*
* retrieve corresponding MAC
*/
if (ioctl(raw_sock, SIOCGIFHWADDR, &abc_config.ifr) == -1) {
perror("SIOCGIFINDEX");
close(raw_sock);
return ERROR;
}
abc_config.abc_raw_socket = raw_sock;
abc_config.abc_raw_state = RAW_READY;
return raw_sock;}
First I was consider htons ( ETH_P_ALL ) cause all incoming packet allowing. This is causing the traffic to increase and I thought the connection cannot be established Then I changed the socket initializing with the raw_sock = socket ( AF_PACKET, SOCK_RAW, IPPROTO_RAW); this time any kind of packet wasn't received. My etherytpe of raw packet for transmit : 0xcd03 and receive: 0xdd04.
By the way embedded device has a Marvell 88E6097, 8 FE + 3 GE Stackable Ethernet Switch with QoS and 802.1Q inside the circuit. Raw and TCP socket connected this swicth.
What can be the problem ?
Thank's a lot.
I solved the problem via bridge method. Here is the bridge command which is added linux device.
brctl addbr br1
brctl addif br1 eth3
ifconfig br1 up