Day 7: Special Addresses

slateobservantNetworking and Communications

Oct 26, 2013 (4 years and 2 months ago)

203 views

Agenda



Internet Address Pair


IP Address


Port Address


Network Address Translation (NAT)


Domain Name

Internet Address

Part I

Two Parts

2=1


IP Address


0.0.0.0


255.255.255.255


Port


0
-
64 k


The full
Internet Address

pair


<IP>:<Port>


10.10.125.5:80


Type in your web browser (demo)

IP Address

P.O.er There

IP Address


Size & Form


IPv4


Current
Standard
-

Legacy


32 bits total


8 bit sections (base10 = 0
-
255)


255.255.255.255



IPv6


Emerging Standard


128 bits total (4 x IPv4)


16 bit sections (hex = 0
-
FFFF)


FFFF:0000:FFFF:0000:FFFF:0000:FFFF:0000

IP Address

Formatting


Convert IP address to network format


Inet_addr
(char * stringFormat)


Returns: struct in_addr


Fails if not an IP address


Some confusing number completion intelligence


“125.126.4”




125.126.0.4


“125.4”




125.0.0.4


“125.126.12844”



125.126.128.44


Inet_ntoa

(struct in_addr)


Returns an ASCII string


htons

(short HostOrderShort)


Returns the short in network byte order (i.e., swapped for Windows)


Example



SOCKADDR_IN addr;



addr.sin_family


= AF_INET;



addr.sin_addr.s_addr

= inet_addr(“159.151.11.3”);



addr.sin_port


= htons(80);


IP Address

Positional Meaning


35.1.9.7


Network Prefix


35


Subnet


1


9


Host


7


IP Addressing

Special Addresses


255.255.255.255


INADDR_NONE == INADDR_BROADCAST


Must setup a DATAGRAM for limited broadcast


0


INADDR_ANY == ADDR_ANY


sin_addr.s_addr set to this before bind() so it assigns default.


127.0.0.1


INADDR_LOOPBACK


Send to self


*.*.*.{240
-
255}


Directed Broadcast to a specific subnet


*.*.*.{224
-
239}


Multicast group IP


IP Addressing

Types of addresses


Unicast


Address assigned to an individual


Static


You assign your own (uncommon these days)


DHCP (Dynamic Host Configuration Protocol)


Server assigned address


APIPA (Automatic Private IP Addressing)


Used by routers servicing a single DHCP assigned address


Default if DHCP not available


This is
NOT

your MAC address on your NIC


Multicast


Address to a list of addresses


Temporary groups


Broadcast


Limited = everyone on your local net


Directed = send to a subnet

Port

Not your ordinary desert wine.

Ports

The other half of the address


16 bit number = 0
-

65,536


Receiving Port


Must specify a
specific

port to listen on


Sending Port


Send on any available port (sockets decides)


Can specify send port, but may conflict


Ports

Known & Not So Known


Well Known Ports


0
-
1024


Internet Assigned Number Authority (IANA)


The Registrar


Reserved for standard services (FTP, WWW, SMTP, Telnet, …)


Can use for anything (not recommended)


Often filtered by network hardware


IP address ignored and packet redirected to specific protocol server


Examples


HTTP

= Port 80

(web server)


FTP

= Port ?

(check answer at
www.iana.net
)



Registered Port Numbers


1024
-
65,536


Not controlled by IANA


Some common services use 1024
-
10,000


Be safe, stay high


Hippie Slogan or Good Advice?


10k
-
64k

Firewalls

Keep Out!

Types of Firewalls


Packet Filter



Proxies



Circuit Gateways


NAT

A baby Mosquito?

Network Address Translation



What is it for?


Multiple NIC’s share the same IP
Address



Who does this?


Routers at work/home sharing one IP
Address



How does it do it?


Each NIC assigned an APIPA address


APIPA + Port
α

converted to Shared IP + Port
β


Router maintains the translation table and redirects incoming
traffic accordingly.


NAT in action

LAN Address

WAN Address

192.168.1.1:200

24.15.1.118:200

192.168.1.1:201

24.15.1.118:201

192.168.1.2:199

24.15.1.118:199

192.168.1.2:200

24.15.1.118:
4000
*

Figure 1 Network Address Translation at work.


NAT Traversal


Port Forwarding


Port always assigned to 1 computer


Port Triggering


Starting application temporarily forwards port


DMZ


All traffic also goes to specific computer


Determining WAN IP


From computer on the other side of router


IP Helper API, router
config

table

Domain Name

www.yahoo.com

chuck.toonedin.com


Domain Name Resolution

Facilities


Local Host Table (i.e. a cache)


<win>
\
SYSTEM32
\
DRIVERS
\
ETC
\
HOSTS

(demo)


Fast, customizable


Doesn’t scale, gets out of synch with changes


Domain Name Service (DNS) Server


Off site server


Faster updates, hands off, scales


Slower, no control on updates, not always available


Propagation takes time (hrs


weeks)


Case Study


Use DNS if available


Store last used and defaults when not


Ping Demo


Plethora of other custom services


Network Information Service (
unix
)


NetBIOS over TCP/IP


Windows NLA: Network Location Awareness (mobile computing)