Code Monkey home page Code Monkey logo

network-programming-examples's Introduction

IPv4 and IPv6 raw sockets programming

Introduction :

Low level socket programming in C.

--

ARP

--

IPv4

# ICMPv4:
  • When create a ICMP socket socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), the kernel will fill the Ethernet and IP header automatically.

  • Using ancillary data to specify the option content for only a single datagram.

  • More details on using ancillary data, please refer to Linux Socket Programming by Example - Chapter 17.

Code Descriptions
icmpv4_echo__icmp_socket.c Send echo request (with TTL)).
icmpv4_echo__icmp_socket_ancillary.c Send echo request using ancillary data (with TTL)).
icmpv4_echo__raw_socket.c Create a Raw socket(IP_HDRINCL) to send echo request (with TTL).

--

IPv6

# IPv6:
  • Fragmentation.

  • Hop-by-Hop Extension Header.

# ICMPv6:
  • IPv6 sockets api RFC3493 and RFC3542.

  • When create a ICMPv6 socket socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), the kernel will fill the Ethernet, IP header and ICMPv6 header chuckseum automatically.

  • All the fields in IPv6 header and all the extension headers can be set by ancillary data or setsockopt().

  • There is No option similar to the IPv4 IP_HDRINCL socket option.

  • Using ancillary data to specify the option content for a single datagram.

Code Descriptions
icmpv6_echo__icmpv6_socket.c Send echo request (with hoplimit).
icmpv6_echo__icmpv6_socket_ancillary.c Send echo request using ancillary data (with hoplimit).
  • Neighbor Discovery RFC4861.

  • IPv6 Neighbor Discovery (using multicast address, IPv6 do NOT have broadcast address).

  • Neighbor Solicitation/Advertisement and Router Solicitation/Advertisement

Code Descriptions
icmpv6_ns__icmpv6_socket_ancillary.c Send neighbor solicitation request (with hoplimit).
icmpv6_na__icmpv6_socket_ancillary.c Send neighbor advertisement request (with hoplimit).
icmpv6_rs__icmpv6_socket_ancillary.c Send router solicitation request (with hoplimit).
icmpv6_ra__icmpv6_socket_ancillary.c Send router advertisement request (with hoplimit).
# Tunneling IPv6 over IPv4:

--

TCP4

Code Descriptions
tcp4_syn__eth_socket.c Send TCP SYN packet (construct from ethernet layer).

--

Miscellaneous

Code Descriptions
getaddrinfo.c Use getaddrinfo() to identify an Internet hostname.
bind_dev.c Bind a socket to a network interface(eth0, eth1 ...).
iovec.c How iovec work in ancillary data.
get_ifs_ips.c List all the interfaces and ip address.
get_mtu.c Retrieve MTU of a interface.

--

network-programming-examples's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

silogood

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.