cse 461 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Section 1: UDP, TCP, and addresses PowerPoint Presentation
Download Presentation
Section 1: UDP, TCP, and addresses

Loading in 2 Seconds...

play fullscreen
1 / 8

Section 1: UDP, TCP, and addresses - PowerPoint PPT Presentation


  • 63 Views
  • Uploaded on

CSE 461. Section 1: UDP, TCP, and addresses. Addressing. Project 0 requires sending your own IP address to another client Problem: getting own IP address can be hard How can we do it?. Getting own IP address: hostname method. Steps. Python example. Get the computer’s host name

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Section 1: UDP, TCP, and addresses' - anika-morris


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
addressing
Addressing
  • Project 0 requires sending your ownIP address to another client
  • Problem: getting own IP addresscan be hard
  • How can we do it?
getting own ip address hostname method
Getting own IP address: hostname method

Steps

Python example

  • Get the computer’s host name
  • Resolve it into an IP address

import socket

name = socket.gethostname()

ip = socket.gethostbyname(name)

  • Sometimes doesn’t work depending on hostname configuration and/or will just return local host (127.0.0.1)
getting own ip address connect to server method
Getting own IP address: connect to server method

Steps

Python example

  • Create a socket
  • Connect to known server on internet
  • Get socket address

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

s.connect((‘gmail.com’,80))

ip = s.getsockname()[0]

  • Useful when previous method doesn’t work
  • Similar methods exist for other languages as well
other methods
Other Methods
  • getaddrinfo()
    • E.g., socket.getaddrinfo(name, 0)
    • Can return other network interfaces that you don’t want (e.g., IPv6)
  • Querying outside URL
    • E.g., urllib2.urlopen(‘http://abstract.cs.washington.edu/~zahorjan/ip.cgi’).read()
    • Best method (if you have a dedicated server to tell you your IP)
ports
Ports
  • Addresses specific toapplications/serviceson a system
  • 16-bit numbers (from0 to 165535)
well known ports
Well-Known Ports
  • Many applications/services have designated ports
  • Examples:
    • ftp: 21
    • ssh: 22
    • telnet: 23
    • http: 80
  • Ports from 0 to 1023 are “well-known ports” (don’t use them for protocols you make up!)
  • Can see a list of your system’s well known ports in /etc/services (Linux/Unix)
hostnames map to ip addresses
Hostnames map to IP addresses
  • Hosts contact DNS (Domain Name System) servers to get IP address of a given name
  • E.g., ‘www.gmail.com’ maps to 173.194.33.118
  • nslookup demo