Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; '(using': 0.07; 'cache': 0.07; 'hosts': 0.07; 'subject:code': 0.07; 'tries': 0.07; 'host,': 0.09; 'keys,': 0.09; 'kumar': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; 'suggest': 0.14; '"new': 0.16; '#delete': 0.16; '#this': 0.16; '>on': 0.16; 'added.': 0.16; 'address)': 0.16; 'deleted,': 0.16; 'detected': 0.16; 'exists,': 0.16; 'host"': 0.16; 'itself,': 0.16; 'message-id:@4ax.com': 0.16; 'nodes': 0.16; 'nodes.': 0.16; 'only)': 0.16; 'outdated': 0.16; 'presume': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:post': 0.16; 'timeout': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'value.': 0.19; 'entered': 0.20; 'seems': 0.21; 'appears': 0.22; 'otherwise,': 0.22; 'print': 0.22; 'config': 0.24; 'parse': 0.24; 'url:home': 0.24; 'visible': 0.24; '(or': 0.24; 'post': 0.26; 'asking': 0.27; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'host': 0.29; 'correct': 0.29; 'announcement': 0.30; "i'm": 0.30; 'code': 0.31; 'url:wiki': 0.31; 'claiming': 0.31; 'clock': 0.31; 'node': 0.31; 'request,': 0.31; 'url:wikipedia': 0.31; 'anyone': 0.31; 'probably': 0.32; 'supposed': 0.32; 'mac': 0.33; 'ourselves': 0.33; 'skip:# 10': 0.33; 'actual': 0.34; 'could': 0.34; 'case,': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; "didn't": 0.36; 'entry': 0.36; 'possible': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'january': 0.37; 'seconds': 0.37; 'so,': 0.37; 'being': 0.38; 'received:76': 0.38; 'lists.': 0.38; 'somebody': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'structure': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'subject:Can': 0.60; 'hardware': 0.61; 'identify': 0.61; 'lower': 0.61; 'new': 0.61; 'traffic': 0.61; 'simple': 0.61; 'address': 0.63; 'show': 0.63; 'information': 0.63; 'confirm': 0.64; 'provide': 0.64; '(that': 0.65; 'afraid': 0.65; 'here': 0.66; 'direct': 0.67; 'broadcast': 0.68; 'invalid': 0.68; 'address,': 0.75; 'probe': 0.91; 'simulation': 0.91; 'responses': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Can post a code but afraid of plagiarism Date: Wed, 22 Jan 2014 22:36:32 -0500 Organization: IISS Elusive Unicorn References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: adsl-76-249-17-113.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 102 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390448199 news.xs4all.nl 2843 [2001:888:2000:d::a6]:48021 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64562 On Wed, 22 Jan 2014 08:33:30 -0800 (PST), indar kumar declaimed the following: >On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote: >> Hi, >> >> >> >> I want to show a code for review but afraid of plagiarism issues. Kindly, suggest how can I post it for review here without masking it visible for public > >Description of each of the commands: The following appears to be only ONE "command" >• config > >? Parameters: >? is the host's ARP cache timeout, in seconds >? Actions: >? Update simulator's configuration database. >• If already exists, its information should be updated. Otherwise, it should >be added. >? Print “ connected.” >? Have the host send a gratuitous ARP request . http://en.wikipedia.org/wiki/Address_Resolution_Protocol#ARP_announcements >• If any other hosts have an outdated entry for the MAC or IP address, they should >update their caches. >• If there are any responses to that request, that means that somebody else has this IP >address. If that is the case, you should print: >Error: detected IP address conflict. It will be disconnected. That does not follow ARP protocol... BEFORE claiming the IP address, the "new host" is supposed to send an ARP Probe http://en.wikipedia.org/wiki/Address_Resolution_Protocol#ARP_probe Sending the probe (using a local "IP" address of 0.0.0.0, but with the correct hardware MAC address) asking if anyone is using the IP address the local configuration is claiming is supposed to be the test to confirm no one else has the same IP. If no one responds with the configuration IP address, THEN the local host can send an ARP announcement claiming the IP address, which other nodes then use to update their cache lists. Note that an ARP announcement is used to provide the local MAC/IP pair to OTHER nodes. It does not answer how the local node obtains the information of the other nodes. It may be possible to have the nodes receiving a broadcast ARP announcement respond with a direct (that is, TO the original sender only) -- but that could result in an infinite loop if the original then tries to respond back... Note that "host id" is NOT part of the ARP protocol. I'm going to presume that no actual network traffic (or even interprocess communication) is being used here -- just a simple single threaded program. If so, "host id" would probably be used as a dictionary key to identify the ARP cache for that simulated host. The data value (nothing currently seems to be using the cache timeout value so I'm going to ignore it) would be, itself, a dictionary using IP values as keys, with the corresponding MAC address as the data value. OTOH: since you do need to keep the IP and MAC of the host... The structure is probably going to look like: { hostid : (hostMAC, hostIP, hostTimeout, { otherIP : otherMAC, ...}), ...} Pseudo-code (and not even using Python syntax [not validated REXX either]) do forever parse pull host MAC IP timeout simulation.host.cache = {} #create/reset this host's cache say "sending ARP probe" MAC ff:ff:ff:ff:ff:ff 0.0.0.0 IP foreach node in simulation if node.hostid = host continue #skip ourselves else if node.hostIP = IP #this IP is assigned elsewhere say "sending ARP response" node.MAC MAC node.hostIP IP say "error" simulation.host = "" #delete the config host, invalid if host in simulation #it didn't get deleted, so the IP must be available say "sendign ARP announcement" MAC 0:0:0:0:0:0 IP IP foreach node in simulation if node.hostid = host continue else #update cache with new MAC/IP pair Of course, if the IP changed, but not the MAC, the old IP with the MAC will be left behind... This is where the timeout would come into play, if each entry had a time-to-purge entry (clock time when entered + timeout value); then whenever the cache was checked/updated you'd delete any entry that had a purge time lower than the current clock time. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/