Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
Multicast being sent over hardware address of default gateway address instead of ethernet multicast address

I have this code to send multicast messages to a group. There are no errors while running the program but when I monitor packets in Wireshark the ethernet destination of my packets are of my default gateway instead of something like 01-00-5e-xx-xx-xx

The code:


#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>

void main(int argc, char **argv){
    int sockfd;
    struct in_addr interface;
    struct sockaddr_in group;
    char readbuf[1024];

    if((sockfd=socket(AF_INET,SOCK_DGRAM,0))<0){
        perror("socket error");
    }

    memset(&group,0,sizeof(group));
    group.sin_family=AF_INET;
    group.sin_addr.s_addr=inet_addr("244.244.244.1");
    group.sin_port=htons(5555);



    char loop=0;
    if(setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_LOOP,&loop,sizeof(loop))<0){
        perror("setsockopt error(IP_MULTICAST_LOOP)");
    }

    interface.s_addr=inet_addr("192.168.1.69");
    if(setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_IF,&interface,sizeof(interface))<0){
        perror("setsockopt error(IP_MULTICAST_IF)");
    }

    for(;;){
        fgets(readbuf,sizeof(readbuf),stdin);
        if(sendto(sockfd,readbuf,sizeof(readbuf),0,(struct sockaddr *)&group,sizeof(struct sockaddr))==-1){
            perror("sendto error");
        }
    }

}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

244.244.244.1 is not a valid multicast address.

Multicast address are in the range of 224.0.0.1 - 239.255.255.255. The address you're sending to is not in that range. So the outgoing MAC address is not a multicast MAC.

Change the destination IP to be in the range of multicast IP addresses and you'll see a proper multicast MAC address.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda