Professional Documents
Culture Documents
VI - C - 39 - ADN - Pracitcal 1
VI - C - 39 - ADN - Pracitcal 1
, NAGPUR
(An Autonomous Institute under UGC Act 1956)
Department of Computer Science & Engg.
Subject: ADN
Session: 2020-21
Student Details:
Roll Number 02
Name Rutuja Dhengle
Semester VI
Section C
Subject ADN
Practical 1
Theory: -
An Internet Protocol address (IP address) is a numerical label assigned to each device
connected to a computer network that uses the Internet Protocol for communication. An
IP address serves two main functions: host or network interface identification and
location addressing.
The IP address space is managed globally by the Internet Assigned Numbers Authority
(IANA), and by five regional Internet registries (RIRs) responsible in their designated
territories for assignment to local Internet registries, such as Internet service providers
(ISPs), and other end users.
Program:
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
int main()
{
unsigned char ip_address[15];
int fd;
struct ifreq ifr;
struct sockaddr_in *addr;
struct ifaddrs *id;
int val;
val = getifaddrs(&id);
printf("Network Interface Name :- %s\n",id->ifa_name);
printf("Network Address of %s :- %d\n",id->ifa_name,id->ifa_addr);
printf("Network Data :- %d \n",id->ifa_data);
/*Read IP Address*/
printf("Enter Ip Address: ");
scanf("%s",ip_address);
memset((unsigned char*)ip_address,0x20,15);
/*Extracting Ip Address*/
return 0;
Output: